/* Dashboard Layout Base */
html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.dashboard-body {
  display: flex;
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  background-color: var(--bg-color);
  font-family: var(--font-family);
  overflow-x: hidden;
  overflow-y: auto;
}

.dashboard-container {
  display: flex;
  width: 100%;
  max-width: 100%;
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 260px;
  height: 100vh;
  background-color: var(--secondary-color);
  color: #fff;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: transform 0.3s ease;
  z-index: 1000;
  box-shadow: 2px 0 10px rgba(0,0,0,0.1);
}

.sidebar-header {
  height: 80px;
  display: flex;
  align-items: center;
  padding: 0 2rem;
  background-color: #1a2226; /* Darker navy for header */
  border-bottom: 2px solid var(--primary-color);
}

.sidebar-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: #fff;
  margin: 0;
  letter-spacing: -0.5px;
}

.sidebar-nav {
  flex-grow: 1;
  padding: 2rem 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 1rem 2rem;
  color: #B0BEC5;
  text-decoration: none;
  transition: all 0.2s ease;
  gap: 1.25rem;
  font-weight: 600;
  font-size: 0.95rem;
  border-left: 4px solid transparent;
}

.nav-item:hover, .nav-item.active {
  background-color: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-left-color: var(--accent-color);
  padding-left: 2.25rem;
}

.sidebar-footer {
  padding: 1.5rem 2rem;
  border-top: 1px solid rgba(255,255,255,0.1);
}

/* Main Content Area */
.main-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin-left: 260px;
  width: calc(100% - 260px);
  max-width: 100%;
  height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
}

.top-header {
  height: 80px;
  background-color: #fff;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2.5rem;
  box-shadow: 0 2px 10px rgba(0,0,0,0.02);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.sidebar-toggle {
  background: none;
  border: none;
  font-size: 1.75rem;
  color: var(--secondary-color);
  cursor: pointer;
  display: none;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-weight: 700;
  color: var(--secondary-color);
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  background-color: var(--primary-color);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
}

.content-wrapper {
  padding: 2.5rem;
  overflow-y: auto;
  overflow-x: hidden;
  flex-grow: 1;
  max-width: 100%;
}

.dashboard-content {
  max-width: 100%;
}

.dashboard-section {
  display: none;
  animation: sectionFade 0.2s ease;
  margin-bottom: 24px;
}

.dashboard-section.active {
  display: block;
}

@keyframes sectionFade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-title {
  margin-bottom: 2.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.page-title h2 {
  margin: 0;
  font-size: 2rem;
  letter-spacing: -0.5px;
}

.module-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin: -0.5rem 0 1rem;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.module-search {
  position: relative;
  width: min(100%, 360px);
}

.module-search input {
  width: 100%;
  padding: 0.85rem 2.8rem 0.85rem 2.75rem;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: #fff;
  font-size: 0.95rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.module-search input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

.module-search-icon {
  position: absolute;
  top: 50%;
  left: 1rem;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.95rem;
  pointer-events: none;
}

.module-search-clear {
  position: absolute;
  top: 50%;
  right: 0.55rem;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: rgba(38, 50, 56, 0.08);
  color: var(--secondary-color);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  display: none;
  align-items: center;
  justify-content: center;
}

.module-search-clear.visible {
  display: inline-flex;
}

.module-search-clear:hover {
  background: rgba(38, 50, 56, 0.14);
}

.search-empty-row td {
  text-align: center;
  color: var(--text-muted);
  padding: 1.5rem;
}

@media (max-width: 768px) {
  .module-toolbar {
    justify-content: stretch;
  }

  .module-search {
    width: 100%;
  }
}

/* Dashboard Cards */
.stat-card {
  background: #fff;
  padding: 2rem;
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 15px rgba(0,0,0,0.03);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 4px;
  background-color: var(--secondary-color);
}

.stat-card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 12px 30px rgba(38, 50, 56, 0.08); /* Dark navy shadow */
  border-color: var(--primary-color);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.stat-title {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 1rem;
}

.stat-value {
  font-size: 2.5rem;
  font-weight: 900;
  color: var(--secondary-color);
  letter-spacing: -1px;
}

/* Tables */
.table-container,
.table-wrapper {
  background: #fff;
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 15px rgba(0,0,0,0.03);
  width: 100%;
  overflow-x: auto;
  max-width: 100%;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

th, td {
  padding: 1rem 1.25rem;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9rem;
}

thead th {
  background-color: #F8FAFC;
  font-weight: 700;
  color: var(--secondary-color);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  position: sticky;
  top: 0;
  z-index: 10;
}

thead th:first-child { border-top-left-radius: var(--border-radius); }
thead th:last-child { border-top-right-radius: var(--border-radius); }

tr:hover td {
  background-color: #F1F5F9;
}

tr:last-child td:first-child { border-bottom-left-radius: var(--border-radius); }
tr:last-child td:last-child { border-bottom-right-radius: var(--border-radius); }

.site-table .site-id-column {
  width: 16%;
  font-weight: 700;
  color: var(--primary-color);
}

.site-table .customer-column {
  width: 15%;
}

.site-table .address-column {
  width: 30%;
}

.site-table .work-type-column {
  width: 12%;
}

.site-table .date-column {
  width: 10%;
}

.site-table .actions-column {
  width: 18%;
}

.phone-column {
  width: 15%;
}

.warranty-column {
  width: 15%;
}

.table-actions,
.action-buttons {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  justify-content: flex-start;
  width: 100%;
}

.site-table td.actions-column {
  white-space: normal;
}

.selected-row td {
  background-color: #eef2ff;
}

#siteDetailsSection {
  scroll-margin-top: 96px;
}

.btn {
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: 0.2s;
}

.btn:hover,
button:hover {
  transform: translateY(-1px);
}

.table-actions,
.action-buttons {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
  flex-wrap: wrap;
}

.btn-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: #fff;
  width: auto;
  min-width: 80px;
  text-align: center;
  padding: 0.5rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 8px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.btn-action:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.btn-view {
  border: 1.5px solid #6366F1;
  color: #6366F1;
}

.btn-view:hover {
  background-color: #6366F1;
  color: #fff;
}

.btn-edit {
  border: 1.5px solid #8B5CF6;
  color: #8B5CF6;
}

.btn-edit:hover {
  background-color: #8B5CF6;
  color: #fff;
}

.btn-delete {
  border: 1.5px solid #EF4444;
  color: #EF4444;
}

.btn-delete:hover {
  background-color: #EF4444;
  color: #fff;
}

.status-dropdown {
  border-radius: 8px;
  padding: 4px 10px;
  min-width: 130px;
  font-size: 13px;
}

.site-table .status-column select,
.status-column select {
  width: 100%;
  border-radius: 8px;
}

.status-badge {
  display: inline-block;
  white-space: nowrap;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}

.status-pending {
  background: #fff6d6;
  color: #8a6500;
}

.status-in-progress,
.status-processing,
.status-assigned,
.status-approved {
  background: #e8f1ff;
  color: #185abc;
}

.status-completed,
.status-delivered,
.status-active,
.status-available {
  background: #e8f8ef;
  color: #1f7a3f;
}

.status-cancelled,
.status-inactive,
.status-on-leave,
.status-rejected {
  background: #ffe9e9;
  color: #b42318;
}

.status-default {
  background: #f0f2f5;
  color: #44546f;
}

.loading-state,
.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-direction: column;
  text-align: center;
  color: var(--text-muted);
  padding: 20px 12px;
}

.loading-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #d9e2ef;
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.empty-state-icon {
  font-size: 20px;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.section {
  margin-bottom: 24px;
}

.card {
  padding: 20px;
  border-radius: 12px;
}

.card-dashboard,
.stat-card {
  border-radius: 12px;
  padding: 20px;
}

/* Priority Badges & Row Logic */
.badge {
  padding: 0.35rem 0.85rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: inline-block;
}

.badge-high {
  background-color: rgba(229, 57, 53, 0.1);
  color: var(--primary-color);
  border: 1px solid rgba(229, 57, 53, 0.2);
}

.badge-normal {
  background-color: rgba(76, 175, 80, 0.1);
  color: #2E7D32;
  border: 1px solid rgba(76, 175, 80, 0.2);
}

.priority-high-row td {
  background-color: #FFF5F5;
  border-bottom-color: #FFE0E0;
}

.priority-high-row:hover td {
  background-color: #FFEBEE !important;
}

/* Modal UI */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(38, 50, 56, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: #fff;
  padding: 2.5rem;
  border-radius: var(--border-radius);
  width: 90%;
  max-width: 500px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  border-top: 4px solid var(--primary-color);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.5rem;
}

.close-modal {
  background: none;
  border: none;
  font-size: 1.75rem;
  cursor: pointer;
  color: #78909C;
  line-height: 1;
}

.close-modal:hover {
  color: var(--primary-color);
}

/* Responsive Dashboard */
@media (max-width: 992px) {
  .dashboard-body {
    overflow-x: hidden;
    overflow-y: auto;
  }

  .sidebar {
    height: 100vh;
    transform: translateX(-100%);
  }

  .sidebar.show {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
    width: 100%;
    min-height: 100vh;
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .content-wrapper {
    overflow-y: auto;
    padding: 1rem;
  }

  .sidebar-toggle { display: block; }
}
