* { box-sizing: border-box; }

[hidden] { display: none !important; }

/* Override hidden for notification toast */
.notification-toast:not([hidden]) {
  display: flex !important;
}

body {
  margin: 0;
  font-family: "Inter", sans-serif;
  background: linear-gradient(135deg, #eef2f7, #f9fafb);
  min-height: 100vh;
  color: #1f2937;
}

/* NOTIFICATION TOAST */
.notification-toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3000;
  animation: slideDown 0.3s ease-out;
  display: flex;
}

.notification-toast[hidden] {
  display: none;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@keyframes slideUp {
  from {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  to {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
  }
}

.notification-toast.hide {
  animation: slideUp 0.3s ease-out;
}

.notification-content {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  padding: 16px 24px;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  font-size: 16px;
  font-weight: 500;
  text-align: center;
  min-width: 300px;
}

.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px 20px;
  min-height: 100vh;
}

.dashboard-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: linear-gradient(135deg, #eef2f7, #f9fafb);
}

/* TOP HEADER */
.top-header {
  background: white;
  border-bottom: 1px solid #e5e7eb;
  padding: 16px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  flex: 1;
}

.header-title {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  color: #1f2937;
}

.header-right {
  display: flex;
  gap: 16px;
  align-items: center;
}

.header-btn {
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  background: white;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.header-btn:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
}

/* HEADER SECTIONS */
.header-section {
  position: relative;
}

.section-btn {
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  background: white;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.section-btn:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
}

.section-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 8px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  min-width: 180px;
  z-index: 1000;
  overflow: hidden;
}

.section-item-btn {
  display: block;
  width: 100%;
  padding: 12px 16px;
  border: none;
  background: white;
  text-align: left;
  font-size: 14px;
  font-weight: 500;
  color: #374151;
  cursor: pointer;
  transition: all 0.2s ease;
}

.section-item-btn:hover {
  background: #f3f4f6;
  color: #1f2937;
}

.section-item-btn:not(:last-child) {
  border-bottom: 1px solid #f3f4f6;
}

/* PROFILE SECTION */
.profile-section {
  position: relative;
}

.profile-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  background: white;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.profile-btn:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
}

.profile-icon {
  font-size: 16px;
}

.profile-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  min-width: 280px;
  z-index: 1000;
  overflow: hidden;
}

.profile-info {
  padding: 16px;
  border-bottom: 1px solid #e5e7eb;
}

.info-item {
  display: flex;
  flex-direction: column;
  margin-bottom: 12px;
}

.info-item:last-child {
  margin-bottom: 0;
}

.info-label {
  font-size: 12px;
  color: #6b7280;
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.info-value {
  font-size: 14px;
  color: #1f2937;
  font-weight: 500;
}

.user-switcher-section {
  padding: 12px 16px;
  border-bottom: 1px solid #e5e7eb;
}

.user-switcher-section label {
  font-size: 12px;
  color: #6b7280;
  font-weight: 600;
  text-transform: uppercase;
  display: block;
  margin-bottom: 8px;
}

.user-switcher-section select {
  width: 100%;
  padding: 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  color: #1f2937;
  background: white;
  cursor: pointer;
}

.user-switcher-section select:hover {
  border-color: #9ca3af;
}

.logout-btn {
  width: 100%;
  padding: 12px;
  border: none;
  background: #ef4444;
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
}

.logout-btn:hover {
  background: #dc2626;
}

/* MODAL */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}

#edit-user-modal,
#edit-location-modal,
#edit-company-modal {
  z-index: 600;
}

.modal-content {
  background: white;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px;
  border-bottom: 1px solid #e5e7eb;
}

.modal-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: #1f2937;
}

.close-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #6b7280;
  transition: color 0.2s ease;
}

.close-btn:hover {
  color: #1f2937;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.form-section {
  margin-bottom: 32px;
}

.form-section h3 {
  margin-top: 0;
  margin-bottom: 16px;
  font-size: 16px;
  font-weight: 600;
  color: #1f2937;
}

.locations-section {
  margin-top: 24px;
}

.locations-section h3 {
  margin-top: 0;
  margin-bottom: 16px;
  font-size: 16px;
  font-weight: 600;
  color: #1f2937;
}

.card {
  background: #ffffff;
  padding: 28px;
  border-radius: 14px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08);
  width: 100%;
  max-width: 100%;
  margin-bottom: 24px;
}

h1 { margin: 0; font-size: 28px; font-weight: 700; }
.subtitle { margin-top: 6px; margin-bottom: 24px; color: #6b7280; }
h2 { margin: 0; font-size: 22px; font-weight: 600; }
h3 { margin-top: 0; margin-bottom: 16px; font-size: 18px; }

.label {
  display: block;
  font-size: 12px;
  color: #6b7280;
  margin: 0 0 6px 2px;
}

input, select, textarea {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 14px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  font-size: 14px;
  background: white;
}

textarea {
  min-height: 90px;
  resize: vertical;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #2563eb;
}

.primary-btn {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: none;
  background: #2563eb;
  color: white;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

.primary-btn:hover { background: #1e40af; }

.secondary-btn {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  background: white;
  font-size: 14px;
  cursor: pointer;
  height: 42px;
}

.secondary-btn:hover { background: #f3f4f6; }

.error-text { margin-top: 12px; color: #dc2626; font-size: 14px; }

.pill {
  display: inline-block;
  margin-top: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 12px;
  font-weight: 600;
}

.muted {
  color: #6b7280;
  font-size: 14px;
}

.dashboard { width: 100%; max-width: 100%; padding: 32px; margin: 0 auto; }

.dashboard-header {
  display: none;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 10px;
  align-items: end;
}

.form-grid .full {
  grid-column: 1 / -1;
}

/* Locations list */
.locations-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.location-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fafafa;
}

.location-name {
  font-weight: 600;
  color: #111827;
}

.company-info {
  flex: 1;
}

.company-name {
  font-weight: 600;
  color: #111827;
}

.company-actions {
  display: flex;
  gap: 8px;
}

/* TABLE */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}

.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

thead { background: #f3f4f6; }

th, td {
  padding: 12px;
  font-size: 14px;
  text-align: left;
  vertical-align: top;
}

th { font-weight: 600; color: #374151; }

th.sortable {
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease;
}

th.sortable:hover {
  background-color: #e5e7eb;
}

tbody tr { border-bottom: 1px solid #e5e7eb; }
tbody tr:last-child { border-bottom: none; }

/* Mobile responsive - keep desktop layout with better touch targets */
@media (max-width: 768px) {
  .top-header {
    padding: 12px 16px;
  }

  .header-title {
    font-size: 18px;
  }

  .header-right {
    gap: 8px;
    flex-wrap: wrap;
  }

  /* Ensure dropdown containers maintain relative positioning */
  .header-section {
    position: relative;
  }

  .section-btn,
  .header-btn,
  .profile-btn {
    padding: 10px 14px;
    font-size: 13px;
    white-space: nowrap;
    min-height: 44px;
  }

  /* Keep dropdowns as absolute positioned overlays like desktop */
  .section-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 8px;
    min-width: 200px;
  }

  /* Ensure dropdowns are hidden by default */
  .section-dropdown[hidden],
  .profile-dropdown[hidden] {
    display: none !important;
  }
}

/* End mobile menu */

/* FullCalendar overrides */
#schedule-modal .modal-content {
  max-width: 1400px;
  width: 95vw;
  max-height: 90vh;
}

#calendar {
  min-height: 600px;
  width: 100%;
}

/* Ensure calendar renders properly */
.fc {
  width: 100%;
}

.fc-view-harness {
  height: auto !important;
  min-height: 500px;
}

.fc-scrollgrid {
  border: 1px solid #e5e7eb !important;
}

.fc .fc-toolbar-title {
  font-size: 28px;
  font-weight: 700;
  color: #1f2937;
}

.fc .fc-button {
  background: #111827;
  border: none;
  color: #fff;
  border-radius: 8px;
}
.fc .fc-button:hover { background: #374151; }

.fc .fc-col-header-cell {
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  font-weight: 600;
  color: #374151;
}

.fc .fc-daygrid-day {
  border: 1px solid #e5e7eb;
}

.fc .fc-daygrid-day-number {
  color: #111827;
  font-weight: 600;
}

.fc .fc-daygrid-day-frame {
  padding: 8px;
  min-height: 120px; /* make boxes tall like Google calendar */
}

.fc .fc-daygrid-event {
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 12px;
}

.edit-btn {
  background: #3b82f6 !important;
  border: none !important;
  color: white !important;
  padding: 6px 10px !important;
  border-radius: 8px !important;
  font-size: 12px !important;
  cursor: pointer !important;
  transition: background-color 0.15s ease !important;
  outline: none !important;
}

.edit-btn:hover { 
  background: #1d4ed8 !important;
}

.edit-btn.small {
  padding: 6px 10px !important;
  font-size: 12px !important;
}

.danger-btn {
  background: #ef4444;
  border: none;
  color: white;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.danger-btn:hover { 
  background: #b91c1c; 
}

.danger-btn.small {
  padding: 6px 10px;
  font-size: 12px;
}

.edit-btn {
  background: #3b82f6;
  border: none;
  color: white;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.edit-btn:hover {
  background: #1d4ed8;
}

.edit-btn.small {
  padding: 6px 10px;
  font-size: 12px;
}

@media (max-width: 640px) {
  * {
    -webkit-tap-highlight-color: transparent;
  }

  body {
    padding: 0;
  }

  .login-container {
    padding: 20px 16px;
    min-height: 100vh;
  }

  .card {
    padding: 16px;
    margin-bottom: 16px;
    border-radius: 12px;
  }

  h1 { font-size: 24px; }
  h2 { font-size: 18px; }
  h3 { font-size: 16px; }

  .top-header {
    flex-direction: column;
    gap: 12px;
    padding: 12px 16px;
  }

  .header-title {
    font-size: 20px;
  }

  .header-right {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-start;
  }

  .header-section {
    flex: 0 0 auto;
    position: relative;
  }

  .header-btn,
  .profile-section {
    flex: 0 0 auto;
  }

  .header-btn {
    padding: 10px 12px;
    font-size: 13px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .profile-btn {
    padding: 10px 12px;
    font-size: 13px;
    height: 44px;
  }

  .profile-dropdown {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    margin-top: 0;
    border-radius: 16px 16px 0 0;
    min-width: auto;
    width: 100%;
    max-height: 60vh;
    z-index: 1001;
    transform: none;
  }

  .modal-content {
    width: 95%;
    max-height: 90vh;
    border-radius: 12px;
  }

  .modal-header {
    padding: 16px;
  }

  .modal-header h2 {
    font-size: 18px;
  }

  .modal-body {
    padding: 16px;
  }

  .close-btn {
    font-size: 28px;
    padding: 4px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .dashboard {
    padding: 16px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  input, select, textarea {
    padding: 14px 12px;
    font-size: 16px;
    min-height: 44px;
    border-radius: 8px;
  }

  textarea {
    min-height: 100px;
  }

  .primary-btn {
    padding: 14px 12px;
    font-size: 15px;
    min-height: 44px;
    border-radius: 8px;
  }

  .secondary-btn {
    padding: 12px 14px;
    min-height: 44px;
    font-size: 13px;
  }

  .danger-btn {
    padding: 8px 12px;
    min-height: 40px;
    font-size: 13px;
  }

  .header-btn {
    white-space: nowrap;
    font-size: 12px;
  }

  .profile-icon {
    font-size: 18px;
  }

  /* Ensure section dropdowns stay positioned under their buttons */
  .section-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 8px;
  }

  /* Table responsive */
  table {
    font-size: 12px;
  }

  th, td {
    padding: 8px;
  }

  .table-wrapper {
    margin: -16px -16px 0 -16px;
    width: calc(100% + 32px);
  }

  .location-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 12px;
  }

  .location-name {
    width: 100%;
    font-size: 14px;
  }

  .location-row button {
    width: 100%;
    text-align: center;
  }

  .user-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 12px;
  }

  .user-info {
    width: 100%;
  }

  .user-row button {
    width: 100%;
    text-align: center;
  }

  .info-item {
    margin-bottom: 10px;
  }

  .info-label {
    font-size: 11px;
    margin-bottom: 4px;
  }

  .info-value {
    font-size: 13px;
  }

  .logout-btn {
    padding: 12px;
    font-size: 14px;
    min-height: 44px;
  }

  .profile-info {
    padding: 16px;
  }

  .form-section h3,
  .locations-section h3 {
    font-size: 15px;
    margin-bottom: 12px;
  }

  .label {
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  .login-container {
    padding: 16px 12px;
  }

  .card {
    padding: 14px;
    border-radius: 10px;
  }

  h1 { font-size: 22px; }

  .header-title {
    font-size: 18px;
  }

  .header-right {
    grid-template-columns: 1fr 1fr;
  }

  input, select, textarea {
    padding: 12px 10px;
    font-size: 16px;
  }

  .primary-btn {
    padding: 12px 10px;
    font-size: 14px;
  }
}
