/* ============================================================
   TICI Lab Budget Portal – style.css
   Responsive | IST Timezone | Lab Green + Blue Theme
   ============================================================ */

/* ── Reset & Variables ────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:    #1a5276;
  --primary-dk: #154360;
  --primary-lt: #2e86c1;
  --accent:     #1e8449;
  --accent-lt:  #27ae60;
  --bg:         #f0f4f8;
  --card-bg:    #ffffff;
  --sidebar-bg: #0d2137;
  --sidebar-txt:#c8d8e8;
  --sidebar-act:#2e86c1;
  --text:       #1c2833;
  --text-muted: #717d7e;
  --border:     #d5d8dc;
  --danger:     #e74c3c;
  --warning:    #f39c12;
  --success:    #27ae60;
  --info:       #2980b9;
  --navbar-h:   60px;
  --sidebar-w:  240px;
  --radius:     8px;
  --shadow:     0 2px 8px rgba(0,0,0,.10);
  --shadow-md:  0 4px 16px rgba(0,0,0,.14);
}

html { font-size: 15px; scroll-behavior: smooth; }
body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

a { color: var(--primary-lt); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Utilities ────────────────────────────────────────────── */
.d-none     { display: none !important; }
.d-flex     { display: flex !important; }
.d-md-flex  { display: none !important; }
.d-md-none  { display: flex !important; }
.w-100      { width: 100%; }
.me-1       { margin-right: .3rem; }
.mt-1       { margin-top: .5rem; }
.mt-2       { margin-top: 1rem; }
.mt-3       { margin-top: 1.5rem; }
.mb-2       { margin-bottom: 1rem; }
.mb-3       { margin-bottom: 1.5rem; }
.text-right { text-align: right; }
.text-center{ text-align: center; }
.text-muted { color: var(--text-muted); font-size: .85rem; }
.text-danger{ color: var(--danger); }
.text-success{color: var(--success); }
.text-warning{color: var(--warning); }
.fw-bold    { font-weight: 600; }
.small      { font-size: .82rem; }

@media (min-width: 768px) {
  .d-md-flex  { display: flex !important; }
  .d-md-none  { display: none !important; }
  .d-none.d-md-flex { display: flex !important; }
}

/* ── Navbar ───────────────────────────────────────────────── */
.navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  height: var(--navbar-h);
  background: var(--primary);
  box-shadow: var(--shadow-md);
}
.navbar-inner {
  display: flex; align-items: center; height: 100%;
  padding: 0 1rem; gap: 1rem;
}
.navbar-brand { display: flex; align-items: center; gap: .6rem; flex-shrink: 0; }
.brand-icon {
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(255,255,255,.15);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.1rem;
}
.brand-title { color: #fff; font-weight: 700; font-size: 1rem; line-height: 1.2; }
.brand-sub   { color: rgba(255,255,255,.6); font-size: .7rem; }

.navbar-center { display: flex; align-items: center; gap: .8rem; flex: 1; justify-content: center; }
.navbar-right  { display: flex; align-items: center; gap: .5rem; margin-left: auto; }

.fy-badge {
  background: rgba(255,255,255,.15); color: #fff;
  padding: .25rem .7rem; border-radius: 20px; font-size: .8rem; white-space: nowrap;
}
.office-select {
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.25);
  color: #fff; padding: .3rem .6rem; border-radius: 6px; font-size: .85rem;
  cursor: pointer; min-width: 170px;
}
.office-select option { background: var(--primary-dk); color: #fff; }
.office-filter-form { display: inline-flex; }

.user-name { color: rgba(255,255,255,.85); font-size: .85rem; }
.btn-logout {
  color: rgba(255,255,255,.7); background: transparent; border: none;
  font-size: 1.1rem; cursor: pointer; padding: .3rem .5rem;
  border-radius: 4px; transition: color .2s;
}
.btn-logout:hover { color: #fff; text-decoration: none; }

.hamburger {
  background: transparent; border: none; color: #fff;
  font-size: 1.2rem; cursor: pointer; padding: .3rem .5rem;
  border-radius: 4px;
}

/* ── Layout ───────────────────────────────────────────────── */
.layout {
  display: flex; min-height: calc(100vh - var(--navbar-h) - 40px);
  margin-top: var(--navbar-h);
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--sidebar-bg);
  position: fixed; top: var(--navbar-h); bottom: 40px;
  left: -var(--sidebar-w); overflow-y: auto;
  transition: transform .3s ease;
  z-index: 900;
  transform: translateX(calc(-1 * var(--sidebar-w)));
}
.sidebar.open { transform: translateX(0); }
.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 899;
}
.sidebar-overlay.show { display: block; }

.sidebar-inner { display: flex; flex-direction: column; height: 100%; padding: .5rem 0 1rem; }
.sidebar-office-filter { padding: .5rem .8rem 0; }

.nav-section {
  padding: .8rem 1rem .3rem;
  color: rgba(255,255,255,.35); font-size: .68rem;
  text-transform: uppercase; letter-spacing: .08em; list-style: none;
}
.nav-menu { list-style: none; flex: 1; }
.nav-link {
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem 1rem; color: var(--sidebar-txt);
  font-size: .87rem; transition: background .2s, color .2s;
  border-left: 3px solid transparent;
}
.nav-link:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.nav-link.active {
  background: rgba(46,134,193,.2); color: #fff;
  border-left-color: var(--sidebar-act);
}
.nav-link i { width: 18px; text-align: center; font-size: .9rem; }

.sidebar-footer {
  padding: .6rem 1rem;
  color: rgba(255,255,255,.35); font-size: .72rem;
  border-top: 1px solid rgba(255,255,255,.08);
}

/* Sidebar open on desktop */
@media (min-width: 768px) {
  .sidebar { transform: translateX(0); position: fixed; }
  .sidebar-overlay { display: none !important; }
  .main-content { margin-left: var(--sidebar-w); }
}

/* ── Main Content ─────────────────────────────────────────── */
.main-content { flex: 1; padding: 1.2rem; min-width: 0; }

/* ── Page Header ──────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: .5rem;
  margin-bottom: 1.2rem;
  padding-bottom: .8rem;
  border-bottom: 2px solid var(--border);
}
.page-header h1 { font-size: 1.3rem; font-weight: 700; color: var(--primary); }
.page-header h1 i { margin-right: .4rem; }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--card-bg); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.1rem; margin-bottom: 1.2rem;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: .8rem; margin-bottom: .8rem;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 1rem; font-weight: 600; color: var(--primary); }
.card-title i { margin-right: .4rem; }

/* ── Stat Cards (Dashboard) ──────────────────────────────── */
.stat-grid {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin-bottom: 1.2rem;
}
.stat-card {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 1rem 1.1rem; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: .3rem;
  border-left: 4px solid var(--primary-lt);
}
.stat-card.green  { border-left-color: var(--accent-lt); }
.stat-card.orange { border-left-color: var(--warning); }
.stat-card.red    { border-left-color: var(--danger); }
.stat-card.teal   { border-left-color: #1abc9c; }

.stat-label { font-size: .75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-size: 1.45rem; font-weight: 700; color: var(--text); line-height: 1.2; }
.stat-sub   { font-size: .75rem; color: var(--text-muted); }

/* ── Office Cards ─────────────────────────────────────────── */
.office-grid {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.office-card {
  background: var(--card-bg); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.office-card-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-lt));
  color: #fff; padding: .8rem 1rem;
  display: flex; align-items: center; gap: .5rem;
}
.office-card-header i { font-size: 1.2rem; }
.office-card-body { padding: 1rem; }

.progress-bar-wrap { background: #e8edf0; border-radius: 10px; height: 8px; margin: .3rem 0; }
.progress-bar-fill {
  height: 8px; border-radius: 10px;
  background: linear-gradient(90deg, var(--accent-lt), var(--primary-lt));
  transition: width .5s ease;
}
.progress-bar-fill.over { background: linear-gradient(90deg, var(--warning), var(--danger)); }

/* ── Tables ───────────────────────────────────────────────── */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
thead th {
  background: var(--primary); color: #fff;
  padding: .6rem .8rem; text-align: left;
  font-weight: 600; white-space: nowrap;
}
thead th:first-child { border-radius: var(--radius) 0 0 0; }
thead th:last-child  { border-radius: 0 var(--radius) 0 0; }
tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:hover { background: #f4f7fb; }
tbody td { padding: .55rem .8rem; vertical-align: middle; }
tfoot td {
  padding: .6rem .8rem; font-weight: 700;
  background: #eaf0f6; border-top: 2px solid var(--primary-lt);
}

.badge {
  display: inline-block; padding: .18rem .55rem;
  border-radius: 12px; font-size: .74rem; font-weight: 600;
}
.badge-success { background: #d5f5e3; color: #1e8449; }
.badge-warning { background: #fef9e7; color: #b7770d; }
.badge-danger  { background: #fdecea; color: #c0392b; }
.badge-info    { background: #d6eaf8; color: #1a5276; }
.badge-default { background: #eaecee; color: #555; }

/* ── Forms ────────────────────────────────────────────────── */
.form-grid {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.form-group { display: flex; flex-direction: column; gap: .3rem; }
.form-group label { font-size: .85rem; font-weight: 500; color: var(--text); }
.form-control {
  padding: .45rem .7rem; border: 1px solid var(--border);
  border-radius: 6px; font-size: .9rem; font-family: inherit;
  color: var(--text); background: #fff; width: 100%;
  transition: border-color .2s, box-shadow .2s;
}
.form-control:focus { outline: none; border-color: var(--primary-lt); box-shadow: 0 0 0 3px rgba(46,134,193,.15); }
select.form-control { cursor: pointer; }
textarea.form-control { min-height: 80px; resize: vertical; }

.form-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .5rem; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .45rem 1rem; border-radius: 6px;
  font-size: .88rem; font-weight: 500; font-family: inherit;
  cursor: pointer; border: none; transition: all .2s;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; filter: brightness(1.08); }
.btn-primary  { background: var(--primary-lt); color: #fff; }
.btn-success  { background: var(--accent-lt);  color: #fff; }
.btn-warning  { background: var(--warning);     color: #fff; }
.btn-danger   { background: var(--danger);      color: #fff; }
.btn-secondary{ background: #717d7e;            color: #fff; }
.btn-outline  { background: transparent; border: 1px solid var(--primary-lt); color: var(--primary-lt); }
.btn-sm { padding: .25rem .6rem; font-size: .8rem; }
.btn-icon { padding: .3rem .5rem; }

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem;
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  font-size: .9rem;
}
.alert-success { background: #d5f5e3; color: #1a5e2b; border-left: 4px solid var(--success); }
.alert-danger  { background: #fdecea; color: #922b21; border-left: 4px solid var(--danger); }
.alert-warning { background: #fef9e7; color: #7d6608; border-left: 4px solid var(--warning); }
.alert-info    { background: #d6eaf8; color: #1a4a78; border-left: 4px solid var(--info); }
.alert-close { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: inherit; opacity: .7; padding: 0 .2rem; }
.alert-close:hover { opacity: 1; }

/* ── Filters row ──────────────────────────────────────────── */
.filters-row {
  display: flex; gap: .7rem; flex-wrap: wrap; align-items: flex-end;
  margin-bottom: 1rem;
}
.filters-row .form-group { min-width: 140px; flex: 1; }

/* ── Month tabs ───────────────────────────────────────────── */
.month-tabs {
  display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: 1rem;
}
.month-tab {
  padding: .3rem .7rem; border-radius: 20px; font-size: .8rem;
  border: 1px solid var(--border); background: #fff; cursor: pointer;
  transition: all .2s; color: var(--text-muted);
}
.month-tab:hover { border-color: var(--primary-lt); color: var(--primary); }
.month-tab.active { background: var(--primary-lt); color: #fff; border-color: var(--primary-lt); font-weight: 600; }

/* ── Variance indicators ──────────────────────────────────── */
.var-danger  { color: var(--danger);  font-weight: 600; }
.var-warning { color: var(--warning); font-weight: 600; }
.var-success { color: var(--success); font-weight: 600; }

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 2000;
  align-items: center; justify-content: center; padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow-md); width: 100%; max-width: 580px;
  max-height: 90vh; overflow-y: auto;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.2rem; border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 1.05rem; font-weight: 600; color: var(--primary); }
.modal-close { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--text-muted); }
.modal-body  { padding: 1.2rem; }
.modal-footer { padding: .8rem 1.2rem; border-top: 1px solid var(--border); display: flex; gap: .5rem; justify-content: flex-end; }

/* ── Footer ───────────────────────────────────────────────── */
.app-footer {
  height: 40px; background: var(--primary-dk);
  display: flex; align-items: center;
}
.footer-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1rem; width: 100%; font-size: .75rem; color: rgba(255,255,255,.5);
}
@media (min-width: 768px) {
  .footer-inner { padding-left: calc(var(--sidebar-w) + 1rem); }
}

/* ── Responsive tweaks ────────────────────────────────────── */
@media (max-width: 767px) {
  .page-header h1 { font-size: 1.1rem; }
  .stat-value { font-size: 1.2rem; }
  .btn { font-size: .82rem; padding: .38rem .8rem; }
  .form-grid { grid-template-columns: 1fr; }
  table { font-size: .8rem; }
  thead th, tbody td, tfoot td { padding: .45rem .5rem; }
}

/* ── Print ────────────────────────────────────────────────── */
@media print {
  .navbar, .sidebar, .sidebar-overlay, .app-footer,
  .btn, .filters-row, .month-tabs, .hamburger { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}
