/* ============================================================
   TKCA AquaTrack — Maintenance Management System
   style.css
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@300;400;600;700;800&family=Poppins:wght@400;500;600;700&display=swap');

/* ── CSS VARIABLES (logo color palette) ── */
:root {
  --teal:        #5BBFC4;
  --teal-dark:   #3D9EA3;
  --teal-light:  #D0EDEF;
  --sage:        #A8D5B5;
  --sage-light:  #E1F2E6;
  --yellow:      #EDE86B;
  --yellow-light:#FAFAD2;
  --coral:       #E8786B;
  --coral-dark:  #C85A4E;
  --peach:       #E89C82;
  --peach-light: #FAE8DF;
  --gray-light:  #CECECE;
  --gray-bg:     #F5F7F8;
  --white:       #FFFFFF;
  --text-dark:   #2C3E50;
  --text-mid:    #5A6A7A;
  --text-light:  #8A9BAA;
  --shadow-sm:   0 2px 8px rgba(91,191,196,0.12);
  --shadow-md:   0 4px 20px rgba(91,191,196,0.18);
  --shadow-lg:   0 8px 40px rgba(44,62,80,0.12);
  --radius-sm:   8px;
  --radius-md:   14px;
  --radius-lg:   20px;
  --radius-xl:   28px;
  --font-main:   'Nunito', sans-serif;
  --font-head:   'Poppins', sans-serif;
  --transition:  all 0.25s cubic-bezier(0.4,0,0.2,1);
  --sidebar-w:   240px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-main);
  background: var(--gray-bg);
  color: var(--text-dark);
  min-height: 100vh;
  line-height: 1.6;
}

/* ── LAYOUT ── */
.app-shell {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: var(--sidebar-w);
  background: var(--white);
  border-right: 2px solid var(--teal-light);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  overflow-y: auto;
  transition: transform 0.3s ease;
}
.sidebar-brand {
  padding: 20px 16px;
  border-bottom: 2px solid var(--teal-light);
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.sidebar-brand img {
  width: 40px; height: 40px;
  border-radius: 50%;
  object-fit: cover;
}
.sidebar-brand-text {
  line-height: 1.2;
}
.sidebar-brand-text .app-name {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--teal-dark);
}
.sidebar-brand-text .app-sub {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--coral);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.sidebar-section {
  padding: 8px 0;
}
.sidebar-section-label {
  padding: 12px 16px 4px;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-light);
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-mid);
  transition: var(--transition);
  border-left: 3px solid transparent;
}
.sidebar-link:hover {
  background: var(--teal-light);
  color: var(--teal-dark);
  border-left-color: var(--teal);
}
.sidebar-link.active {
  background: var(--teal-light);
  color: var(--teal-dark);
  border-left-color: var(--teal-dark);
}
.sidebar-link svg, .sidebar-link .nav-icon {
  width: 18px; height: 18px; flex-shrink: 0;
}
.sidebar-link .badge-count {
  margin-left: auto;
  background: var(--coral);
  color: white;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 1px 7px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px;
  border-top: 2px solid var(--teal-light);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-dark);
}
.sidebar-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--teal-light);
  color: var(--teal-dark);
  font-weight: 800;
  font-size: 0.9rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-user-info .name {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-dark);
}
.sidebar-user-info .role {
  font-size: 0.72rem;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── MAIN CONTENT ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  background: var(--white);
  border-bottom: 2px solid var(--teal-light);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.topbar-title {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text-dark);
}
.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.burger-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  color: var(--teal-dark);
}
.burger-btn:hover { background: var(--teal-light); }

.page-body {
  padding: 28px 24px 60px;
  flex: 1;
}
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}
.page-header h1 {
  font-family: var(--font-head);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-dark);
}
.page-header p {
  font-size: 0.9rem;
  color: var(--text-mid);
  margin-top: 3px;
}

/* ── CARDS ── */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header {
  padding: 16px 20px 14px;
  border-bottom: 2px solid var(--gray-bg);
  display: flex;
  align-items: center;
  gap: 10px;
}
.card-header h2 {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-dark);
}
.card-icon {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  background: var(--teal-light);
  color: var(--teal-dark);
  flex-shrink: 0;
  font-size: 1rem;
}
.card-body { padding: 20px; }

/* ── STATS GRID ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 20px 18px;
  box-shadow: var(--shadow-sm);
  border-top: 4px solid var(--teal);
  transition: var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-number {
  font-family: var(--font-head);
  font-size: 2rem;
  font-weight: 800;
  color: var(--teal-dark);
  line-height: 1;
}
.stat-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 6px;
}
.stat-trend {
  font-size: 0.78rem;
  color: var(--text-light);
  margin-top: 4px;
}

/* ── BADGES ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  border: 2px solid transparent;
  transition: var(--transition);
  white-space: nowrap;
}
.btn-primary {
  background: var(--teal-dark);
  color: var(--white);
  border-color: var(--teal-dark);
}
.btn-primary:hover { background: var(--teal); border-color: var(--teal); }
.btn-coral {
  background: var(--coral);
  color: var(--white);
  border-color: var(--coral);
}
.btn-coral:hover { background: var(--coral-dark); border-color: var(--coral-dark); }
.btn-outline {
  background: transparent;
  color: var(--teal-dark);
  border-color: var(--teal);
}
.btn-outline:hover { background: var(--teal-light); }
.btn-ghost {
  background: transparent;
  color: var(--text-mid);
  border-color: #E0E4E8;
}
.btn-ghost:hover { background: var(--gray-bg); color: var(--text-dark); }
.btn-danger {
  background: var(--coral-dark);
  color: white;
  border-color: var(--coral-dark);
}
.btn-danger:hover { background: #a8362c; }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-xs { padding: 3px 8px; font-size: 0.72rem; }
.btn-lg { padding: 12px 24px; font-size: 0.98rem; }
.btn-block { width: 100%; justify-content: center; }
.btn svg { width: 15px; height: 15px; }

/* ── FORMS ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-full { grid-column: 1 / -1; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label {
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--text-mid);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.form-label .req { color: var(--coral); }
.form-control {
  padding: 10px 14px;
  border: 2px solid #E8ECEF;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 0.95rem;
  color: var(--text-dark);
  background: var(--white);
  transition: var(--transition);
  width: 100%;
  outline: none;
}
.form-control:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(91,191,196,0.15);
}
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 90px; }
.form-hint { font-size: 0.78rem; color: var(--text-light); margin-top: 3px; }

/* ── FILTER BAR ── */
.filter-bar {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}
.filter-bar .form-group { flex: 1; min-width: 140px; }
.filter-bar .form-label { margin-bottom: 4px; }

/* ── TABLES ── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
thead th {
  background: var(--teal-dark);
  color: white;
  padding: 11px 14px;
  text-align: left;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 0.8rem;
  white-space: nowrap;
}
thead th:first-child { border-radius: 8px 0 0 0; }
thead th:last-child  { border-radius: 0 8px 0 0; }
tbody tr { border-bottom: 1px solid #F0F4F6; transition: var(--transition); }
tbody tr:hover { background: var(--teal-light); }
tbody td { padding: 10px 14px; vertical-align: middle; }
tbody td:last-child { white-space: nowrap; }

/* ── ALERTS ── */
.alert {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.alert-success { background: var(--sage-light); color: #2d7a4a; border-left: 4px solid var(--sage); }
.alert-error   { background: #FDE8E8; color: var(--coral-dark); border-left: 4px solid var(--coral); }
.alert-warning { background: var(--yellow-light); color: #7a6e10; border-left: 4px solid var(--yellow); }
.alert-info    { background: var(--teal-light); color: var(--teal-dark); border-left: 4px solid var(--teal); }

/* ── MODAL ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(44,62,80,0.55);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn 0.2s ease;
}
@keyframes modalIn {
  from { opacity:0; transform: scale(0.95) translateY(-10px); }
  to   { opacity:1; transform: scale(1) translateY(0); }
}
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 2px solid var(--gray-bg);
  display: flex;
  align-items: center;
  gap: 10px;
}
.modal-header h2 { font-family: var(--font-head); font-weight: 600; font-size: 1.1rem; }
.modal-close {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-light);
  font-size: 1.4rem;
  line-height: 1;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}
.modal-close:hover { background: var(--gray-bg); color: var(--text-dark); }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 2px solid var(--gray-bg);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ── TABS ── */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid #E8ECEF;
  margin-bottom: 20px;
  overflow-x: auto;
}
.tab-btn {
  padding: 10px 18px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  font-family: var(--font-main);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-mid);
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
}
.tab-btn:hover { color: var(--teal-dark); }
.tab-btn.active { color: var(--teal-dark); border-bottom-color: var(--teal-dark); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── KANBAN / WORK ORDER STATUS LANES ── */
.kanban {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  align-items: start;
}
.kanban-col {
  background: var(--gray-bg);
  border-radius: var(--radius-md);
  padding: 14px;
}
.kanban-col-header {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.kanban-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
}
.wo-card {
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--teal);
  cursor: pointer;
  transition: var(--transition);
}
.wo-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.wo-card-title { font-weight: 700; font-size: 0.88rem; margin-bottom: 6px; }
.wo-card-meta { font-size: 0.76rem; color: var(--text-light); display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

/* ── TIMELINE ── */
.timeline { position: relative; padding-left: 28px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 10px; top: 0; bottom: 0;
  width: 2px;
  background: var(--teal-light);
}
.timeline-item { position: relative; margin-bottom: 20px; }
.timeline-dot {
  position: absolute;
  left: -22px;
  top: 4px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--teal);
  border: 2px solid white;
  box-shadow: 0 0 0 2px var(--teal-light);
}
.timeline-time { font-size: 0.75rem; color: var(--text-light); margin-bottom: 4px; }
.timeline-content {
  background: var(--gray-bg);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.88rem;
}

/* ── PRIORITY INDICATORS ── */
.priority-bar {
  height: 4px;
  border-radius: 4px;
  margin-bottom: 8px;
}
.priority-low      { background: var(--sage); }
.priority-medium   { background: var(--yellow); }
.priority-high     { background: var(--peach); }
.priority-critical { background: var(--coral); }

/* ── PROGRESS BAR ── */
.progress { background: #E8ECEF; border-radius: 20px; height: 8px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 20px; background: var(--teal); transition: width 0.4s ease; }

/* ── KPI CARDS ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 22px 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
}
.kpi-teal::before   { background: var(--teal); }
.kpi-coral::before  { background: var(--coral); }
.kpi-sage::before   { background: var(--sage); }
.kpi-yellow::before { background: var(--yellow); }
.kpi-peach::before  { background: var(--peach); }
.kpi-value { font-family: var(--font-head); font-size: 2rem; font-weight: 800; color: var(--text-dark); line-height: 1; }
.kpi-label { font-size: 0.78rem; font-weight: 700; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 6px; }
.kpi-icon { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); font-size: 2.5rem; opacity: 0.08; }

/* ── PAGINATION ── */
.pagination { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 16px; }
.page-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  font-weight: 700; font-size: 0.85rem;
  text-decoration: none;
  color: var(--text-mid);
  border: 2px solid #E8ECEF;
  transition: var(--transition);
}
.page-btn:hover { background: var(--teal-light); color: var(--teal-dark); border-color: var(--teal); }
.page-btn.active { background: var(--teal-dark); color: white; border-color: var(--teal-dark); }

/* ── CALENDAR MINI ── */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-day {
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: default;
}
.cal-day.has-event {
  background: var(--teal-light);
  color: var(--teal-dark);
  cursor: pointer;
  font-weight: 800;
}
.cal-day.today { background: var(--teal-dark); color: white; }
.cal-day.overdue { background: #FDE8E8; color: var(--coral-dark); }

/* ── INVENTORY STOCK INDICATOR ── */
.stock-ok     { color: #2d7a4a; }
.stock-low    { color: #c05900; }
.stock-out    { color: var(--coral-dark); }
.stock-bar { width: 80px; height: 6px; background: #E8ECEF; border-radius: 6px; overflow: hidden; display: inline-block; vertical-align: middle; margin-left: 6px; }
.stock-fill { height: 100%; border-radius: 6px; }

/* ── CHART CONTAINERS ── */
.chart-container { position: relative; height: 280px; }

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; opacity: 0.4; }
.empty-state p { font-size: 0.95rem; }

/* ── MOBILE OVERLAY ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(44,62,80,0.5);
  z-index: 199;
}

/* ── PRINT ── */
@media print {
  .sidebar, .topbar, .burger-btn, .btn, .filter-bar,
  .no-print, .modal-overlay { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .page-body { padding: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ddd; break-inside: avoid; }
  thead th { background: var(--teal-dark) !important; color: white !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-w)));
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay.open { display: block; }
  .main-content { margin-left: 0; }
  .burger-btn { display: flex; align-items: center; }
  .page-body { padding: 16px 14px 60px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-full { grid-column: 1; }
  .kanban { grid-template-columns: 1fr; }
  .filter-bar { flex-direction: column; gap: 10px; }
  .filter-bar .form-group { width: 100%; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .page-header { flex-direction: column; }
  .topbar { padding: 0 14px; }
  table { font-size: 0.8rem; }
  thead th, tbody td { padding: 8px 10px; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .kpi-grid { grid-template-columns: 1fr; }
  .stat-number { font-size: 1.6rem; }
}
