/* GLOBAL BOX SIZING FIX */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* BASE STYLES */
body {
  margin: 0;
  font-family: 'Poppins', sans-serif;
  background: #f5f7fa;
}

/* LOGIN PAGE STYLES */
body.login-page {
  margin: 0;
  padding: 0;
  font-family: 'Poppins', sans-serif;
  background-color: #f78021;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

.login-box {
  background-color: #ffffff;
  border-radius: 16px;
  padding: 40px 30px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.login-logo {
  width: 140px;
  margin-bottom: 30px;
}

.login-box h2 {
  margin-bottom: 25px;
  color: #333;
  font-weight: 500;
}

.login-box input[type="text"],
.login-box input[type="password"] {
  width: 85%;
  padding: 6px 10px;
  margin-bottom: 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 13px;
  background-color: #f9f9f9;
  outline: none;
  transition: border 0.3s ease;
  font-size: 16px;
}

.login-box input[type="text"]:focus,
.login-box input[type="password"]:focus {
  border-color: #f78021;
  background-color: #fff;
}

.login-box .options {
  display: flex;
  justify-content: flex-start;
  font-size: 13px;
  color: #555;
  margin-bottom: 25px;
}

.login-box button {
  width: 100%;
  padding: 12px;
  background: #f78021;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: bold;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.3s ease;
}

.login-box button:hover {
  background: #e16f1b;
}

/* DASHBOARD STYLES */
.dashboard-container {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid #ddd;
  padding: 20px;
}

.sidebar .logo {
  display: block;
  width: 150px;
  max-width: 100%;
  height: auto;
  margin: 0 auto 40px;
}

.sidebar nav a {
  display: block;
  margin-bottom: 12px;
  text-decoration: none;
  color: #333;
  padding: 10px 12px;
  border-radius: 6px;
  transition: background 0.3s;
}

.sidebar nav a.active,
.sidebar nav a:hover {
  background: #f78021;
  color: #fff;
}

.main-content {
  flex: 1;
  padding: 30px;
  background-color: #f5f7fa;
  min-width: 0;
}

.main-content h2 {
  margin-bottom: 20px;
  color: #333;
  font-weight: 600;
}

.card {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  margin-top: 25px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* FORM STYLING */
.card form input,
.card form select,
.card form button,
.card form textarea,
.form-container input,
.form-container select,
.form-container button,
.form-container textarea {
  width: 100%;
  min-width: 100px;
  max-width: 100%;
  padding: 12px;
  font-size: 16px;
  border: 1px solid #ccc;
  border-radius: 8px;
  margin-top: 6px;
  margin-bottom: 16px;
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
}

input[type="time"],
input[type="date"],
input[type="number"],
.flatpickr-input {
  width: 100%;
  font-size: 16px;
  padding: 12px;
}

.card form label,
.form-container label,
.form-group label {
  font-weight: 500;
  display: block;
  margin-bottom: 6px;
  color: #333;
}

/* BUTTON STYLES */
.btn-primary,
button[type="submit"] {
  background: #f78021;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px 20px;
  font-weight: bold;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.3s ease;
}

.btn-primary:hover,
button[type="submit"]:hover {
  background: #e16f1b;
}

.btn-secondary {
  background: #95a5a6;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 12px 20px;
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.btn-small {
  padding: 5px 10px;
  font-size: 12px;
  border: none;
  border-radius: 3px;
  cursor: pointer;
}

.btn-success {
  background-color: #27ae60;
  color: white;
}

.btn-danger {
  background-color: #e74c3c;
  color: white;
}

/* SELECTION BUTTONS */
.selection-buttons {
  display: flex;
  gap: 20px;
  margin-top: 30px;
  flex-wrap: wrap;
}

.big-button {
  padding: 30px 50px;
  font-size: 1.5rem;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s;
  color: white;
  font-weight: bold;
}

.big-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.boa-button {
  background-color: #3498db;
}

.boa-button:hover {
  background-color: #2980b9;
}

.install-button {
  background-color: #e74c3c;
}

.install-button:hover {
  background-color: #c0392b;
}

/* FORM CONTAINER */
.form-container {
  background: white;
  padding: 30px;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  max-width: 800px;
  margin: 20px 0;
}

.form-section {
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 1px solid #eee;
}

.form-section:last-child {
  border-bottom: none;
}

.form-section h3 {
  margin-bottom: 15px;
  color: #2c3e50;
  font-weight: 600;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 15px;
}

.form-row.full-width {
  grid-template-columns: 1fr;
}

/* FILE UPLOAD */
.file-upload-area {
  border: 2px dashed #ddd;
  border-radius: 5px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.3s;
}

.file-upload-area:hover {
  border-color: #f78021;
}

.file-upload-area input[type="file"] {
  display: none;
}

.file-upload-label {
  display: block;
  cursor: pointer;
  color: #f78021;
  font-weight: 500;
}

.file-name {
  margin-top: 10px;
  color: #666;
  font-size: 14px;
}

/* TASK MANAGEMENT */
.tasks-container {
  margin-top: 20px;
}

.task-item {
  background: #f9f9f9;
  padding: 15px;
  border-radius: 5px;
  margin-bottom: 10px;
  border-left: 4px solid #f78021;
}

.task-item.completed {
  border-left-color: #27ae60;
  opacity: 0.7;
}

/* Record Card Styles */
.record-card {
  transition: transform 0.2s, box-shadow 0.2s;
}

.record-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.12) !important;
}

.info-item {
  padding: 8px 0;
}

.info-item:not(:last-child) {
  border-right: 1px solid #f0f0f0;
  padding-right: 20px;
}

@media (max-width: 768px) {
  .info-item:not(:last-child) {
    border-right: none;
    border-bottom: 1px solid #f0f0f0;
    padding-right: 0;
    padding-bottom: 15px;
    margin-bottom: 15px;
  }
}

.task-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.task-name {
  font-weight: 600;
  color: #2c3e50;
}

.task-actions {
  display: flex;
  gap: 10px;
}

/* EQUIPMENT INPUT */
.equipment-section {
  margin-top: 20px;
}

.equipment-input-group {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 15px;
}

.equipment-items {
  margin-top: 15px;
  padding-left: 20px;
}

.equipment-item {
  background: #f0f0f0;
  padding: 10px;
  border-radius: 5px;
  margin-bottom: 10px;
}

/* TEMPLATE SELECTOR */
.template-selector {
  margin-bottom: 20px;
}

.template-selector select {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 5px;
}

/* ALERT MESSAGES */
.alert {
  padding: 15px;
  border-radius: 5px;
  margin-bottom: 20px;
}

.alert-success {
  background-color: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.alert-error {
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.error-message {
  background-color: #fee;
  color: #c33;
  padding: 10px;
  border-radius: 5px;
  margin-bottom: 20px;
  border: 1px solid #fcc;
}

/* TABLE STYLES */
table {
  table-layout: auto;
  width: 100%;
  border-collapse: collapse;
}

td {
  padding: 4px;
  max-width: 100px;
  vertical-align: top;
  white-space: nowrap;
  overflow: hidden;
}

select {
  width: 100%;
  max-width: 100px;
  padding: 2px 4px;
  font-size: 0.8rem;
  box-sizing: border-box;
}

/* USER LIST */
.user-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
  max-height: 300px;
  overflow-y: auto;
  padding: 0.5em 0;
  border: 1px solid #ddd;
  border-radius: 8px;
}

.user-item {
  display: flex;
  align-items: center;
  gap: 0.5em;
  background: #f9f9f9;
  padding: 6px 10px;
  border-radius: 6px;
}

.user-item input[type="checkbox"] {
  appearance: auto;
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: #f78021;
}

.results-table {
  width: 100%;
  margin-top: 20px;
  border-collapse: collapse;
}

.results-table th,
.results-table td {
  border: 1px solid #ddd;
  padding: 10px;
  font-size: 14px;
}

.results-table th {
  background-color: #f0f0f0;
}

/* Hide mobile bottom nav on desktop by default */
.mobile-bottom-nav {
  display: none;
}

/* Hide mobile more menu on desktop */
.mobile-more-menu {
  display: none !important;
}

/* MOBILE APP STYLES - Bottom Navigation */
@media (max-width: 768px) {
  /* Safe area for iOS devices */
  body {
    padding-bottom: env(safe-area-inset-bottom);
  }

  /* Hide sidebar on mobile */
  .sidebar {
    display: none !important;
  }

  /* Full width container */
  .dashboard-container {
    flex-direction: column;
    min-height: 100vh;
    padding-bottom: 80px; /* Space for bottom nav */
  }

  /* Main content styling for mobile app */
  .main-content {
    width: 100%;
    padding: 16px;
    background: #f5f7fa;
    min-height: calc(100vh - 80px);
  }

  /* Card styling - more app-like */
  .card,
  .form-container {
    padding: 20px;
    margin-top: 16px;
    margin-bottom: 16px;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    background: #fff;
  }

  .card:first-child,
  .form-container:first-child {
    margin-top: 0;
  }

  /* Typography adjustments */
  h2 {
    font-size: 24px;
    margin-top: 0;
    margin-bottom: 20px;
    font-weight: 600;
  }

  /* Form elements - larger touch targets */
  .card form input,
  .card form select,
  .card form button,
  .card form textarea,
  .form-container input,
  .form-container select,
  .form-container button,
  .form-container textarea {
    font-size: 16px;
    padding: 14px;
    border-radius: 12px;
    border: 1px solid #e0e0e0;
    margin-bottom: 16px;
  }

  .card form button,
  .form-container button,
  .btn-primary {
    background: #f78021;
    color: #fff;
    font-weight: 600;
    border: none;
    margin-top: 8px;
    transition: all 0.2s;
  }

  .card form button:active,
  .form-container button:active,
  .btn-primary:active {
    transform: scale(0.98);
    background: #e16f1b;
  }

  .flatpickr-input {
    font-size: 16px;
    padding: 14px;
  }

  /* Bottom Navigation Bar - Show on mobile */
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #ffffff;
    border-top: 1px solid #e0e0e0;
    justify-content: space-around;
    align-items: center;
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
    z-index: 1000;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    height: 70px;
    max-height: calc(70px + env(safe-area-inset-bottom));
  }

  .mobile-bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #666;
    font-size: 11px;
    padding: 6px 12px;
    border-radius: 12px;
    transition: all 0.2s;
    flex: 1;
    min-width: 0;
  }

  .mobile-bottom-nav a span {
    font-size: 20px;
    margin-bottom: 4px;
    line-height: 1;
  }

  .mobile-bottom-nav a .nav-label {
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }

  .mobile-bottom-nav a.active {
    color: #f78021;
    background: rgba(247, 128, 33, 0.1);
    font-weight: 600;
  }

  .mobile-bottom-nav a.active span {
    transform: scale(1.1);
  }

  .mobile-bottom-nav a:active {
    transform: scale(0.95);
  }

  /* More Menu */
  .mobile-more-menu {
    display: none;
    position: fixed;
    bottom: 70px;
    left: 0;
    right: 0;
    background: white;
    border-top: 2px solid #ddd;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    z-index: 999;
    padding: 15px 0;
    max-height: 50vh;
    overflow-y: auto;
  }

  .mobile-more-menu.show {
    display: block !important;
  }

  .mobile-more-menu a {
    display: block;
    padding: 15px 20px;
    text-decoration: none;
    color: #333;
    font-size: 15px;
    border-bottom: 1px solid #eee;
    transition: background 0.2s;
  }

  .mobile-more-menu a:last-child {
    border-bottom: none;
  }

  .mobile-more-menu a:hover,
  .mobile-more-menu a:active {
    background: #f5f5f5;
  }

  .mobile-more-menu a span {
    margin-right: 10px;
    font-size: 18px;
  }

  /* Adjustments for tables on mobile */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
    margin: 16px 0;
  }

  table {
    font-size: 14px;
    width: 100%;
  }

  th, td {
    padding: 10px 8px;
    font-size: 13px;
  }

  /* Better touch targets */
  input[type="checkbox"],
  input[type="radio"] {
    width: 20px;
    height: 20px;
    min-width: 20px;
    min-height: 20px;
    margin: 0 8px 0 0;
    accent-color: #f78021;
    cursor: pointer;
  }
  
  /* Desktop checkbox styling */
  input[type="checkbox"] {
    width: 20px;
    height: 20px;
    min-width: 20px;
    min-height: 20px;
    cursor: pointer;
    accent-color: #f78021;
    -webkit-appearance: checkbox;
    -moz-appearance: checkbox;
    appearance: checkbox;
  }
  
  /* Ensure checkboxes are visible and functional */
  .task-checkbox,
  .task-item input[type="checkbox"] {
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    min-height: 20px !important;
    cursor: pointer !important;
    accent-color: #f78021 !important;
    -webkit-appearance: checkbox !important;
    -moz-appearance: checkbox !important;
    appearance: checkbox !important;
    border: 2px solid #ccc !important;
    border-radius: 3px !important;
    background-color: white !important;
    flex-shrink: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    display: inline-block !important;
    vertical-align: middle !important;
  }
  
  .task-checkbox:checked,
  .task-item input[type="checkbox"]:checked {
    background-color: #f78021 !important;
    border-color: #f78021 !important;
    accent-color: #f78021 !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='white' d='M13.854 3.646a.5.5 0 0 1 0 .708l-7 7a.5.5 0 0 1-.708 0l-3.5-3.5a.5.5 0 1 1 .708-.708L6.5 10.293l6.646-6.647a.5.5 0 0 1 .708 0z'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    background-size: 14px 14px !important;
  }

  /* Equipment checkbox styling */
  .equipment-checkbox {
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    min-height: 20px !important;
    cursor: pointer !important;
    accent-color: #f78021 !important;
    -webkit-appearance: checkbox !important;
    -moz-appearance: checkbox !important;
    appearance: checkbox !important;
    border: 2px solid #ccc !important;
    border-radius: 3px !important;
    background-color: white !important;
    flex-shrink: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .equipment-checkbox:checked {
    background-color: #f78021 !important;
    border-color: #f78021 !important;
    accent-color: #f78021 !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='white' d='M13.854 3.646a.5.5 0 0 1 0 .708l-7 7a.5.5 0 0 1-.708 0l-3.5-3.5a.5.5 0 1 1 .708-.708L6.5 10.293l6.646-6.647a.5.5 0 0 1 .708 0z'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    background-size: 14px 14px !important;
  }

  /* Smooth scrolling */
  html {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
  }

  /* Better form spacing */
  form {
    margin-bottom: 20px;
  }

  label {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin-bottom: 8px;
    display: block;
  }

  /* Button groups */
  .button-group {
    flex-direction: column;
    gap: 12px;
  }

  .copy-button,
  #uploadBtn {
    width: 100%;
    margin-top: 10px;
  }

  /* Big buttons (like clock in/out) */
  .big-button {
    width: 100%;
    padding: 18px;
    font-size: 18px;
    border-radius: 16px;
    margin-top: 16px;
  }

  /* Dropzone adjustments */
  .dropzone {
    padding: 20px;
  }

  /* Success messages */
  .success {
    padding: 12px;
    border-radius: 12px;
    margin-bottom: 16px;
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
  }

  /* Modal adjustments for mobile */
  #clockOutModal {
    padding: 20px;
  }

  #clockOutModal > div {
    width: 95%;
    max-width: 400px;
    margin: 0 auto;
  }

  /* Prevent text selection on nav items */
  .mobile-bottom-nav a {
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
  }

  /* App-like card shadows */
  .card,
  .form-container {
    transition: transform 0.2s, box-shadow 0.2s;
  }

  .card:active,
  .form-container:active {
    transform: scale(0.98);
  }

  /* Form row adjustments for mobile */
  .form-row {
    grid-template-columns: 1fr;
  }

  .selection-buttons {
    flex-direction: column;
  }
}

/* Smaller mobile devices */
@media (max-width: 480px) {
  .main-content {
    padding: 12px;
  }

  .card,
  .form-container {
    padding: 16px;
    border-radius: 12px;
  }

  h2 {
    font-size: 22px;
  }

  .mobile-bottom-nav a .nav-label {
    font-size: 10px;
  }

  .mobile-bottom-nav a span {
    font-size: 18px;
  }

  .login-box {
    width: 80%;
    padding: 30px 20px;
  }

  .login-logo {
    width: 120px;
  }

  .login-box h2 {
    font-size: 18px;
  }

  .login-box button {
    font-size: 14px;
  }
}
