/* ============================================================
   SVC TRACK – Global Stylesheet  (assets/style.css)
   Mobile-first responsive design
   ============================================================ */

/* ── CSS Variables ─────────────────────────────────────── */
:root {
  --pri:        #1e40af;
  --pri-dark:   #1e3a8a;
  --pri-light:  #dbeafe;
  --accent:     #f59e0b;
  --success:    #16a34a;
  --danger:     #dc2626;
  --warning:    #d97706;
  --info:       #0891b2;
  --bg:         #f1f5f9;
  --card-bg:    #ffffff;
  --border:     #e2e8f0;
  --text:       #1e293b;
  --muted:      #64748b;
  --sidebar-w:  250px;
  --topbar-h:   58px;
  --radius:     10px;
  --shadow:     0 1px 6px rgba(0,0,0,.08);
  --shadow-md:  0 4px 20px rgba(0,0,0,.12);
}

/* ── Reset / Base ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }
a { color: var(--pri); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* ── Typography ────────────────────────────────────────── */
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.1rem; }
.text-muted  { color: var(--muted) !important; }
.text-danger { color: var(--danger) !important; }
.text-success{ color: var(--success) !important; }
.fw-bold { font-weight: 700; }
.fw-semi { font-weight: 600; }
.small   { font-size: .82rem; }
.xs      { font-size: .72rem; }

/* ── Layout: Sidebar + Main ────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed; top: 0; left: 0; height: 100vh;
  width: var(--sidebar-w); background: var(--pri-dark);
  color: #fff; z-index: 1100; display: flex; flex-direction: column;
  overflow-y: auto; transition: transform .28s cubic-bezier(.4,0,.2,1);
}
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.45); z-index: 1099;
}
.sidebar-brand {
  padding: 1rem 1.1rem .9rem;
  background: rgba(0,0,0,.25);
  border-bottom: 1px solid rgba(255,255,255,.1);
  font-size: 1.05rem; font-weight: 700; letter-spacing: .5px;
  display: flex; align-items: center; gap: .5rem;
}
.sidebar-brand span { color: var(--accent); }
.sidebar-brand .close-btn {
  margin-left: auto; display: none; background: none; border: none;
  color: #fff; font-size: 1.2rem; cursor: pointer; padding: 2px 6px;
}
.sidebar-section {
  padding: .55rem 1rem .2rem;
  font-size: .68rem; text-transform: uppercase;
  letter-spacing: 1.2px; color: rgba(255,255,255,.4);
  margin-top: .4rem;
}
.sidebar nav a {
  display: flex; align-items: center; gap: .65rem;
  padding: .62rem 1.1rem; color: rgba(255,255,255,.78);
  font-size: .88rem; transition: all .18s;
  border-left: 3px solid transparent;
  text-decoration: none;
}
.sidebar nav a:hover,
.sidebar nav a.active {
  background: rgba(255,255,255,.1);
  color: #fff;
  border-left-color: var(--accent);
}
.sidebar nav a i { width: 18px; text-align: center; }
.sidebar-footer {
  margin-top: auto;
  padding: .8rem 1rem;
  border-top: 1px solid rgba(255,255,255,.1);
  font-size: .8rem; color: rgba(255,255,255,.5);
}

/* ── Main Content ──────────────────────────────────────── */
.main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  position: sticky; top: 0; z-index: 900;
  height: var(--topbar-h);
  background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: .75rem;
  padding: 0 1.25rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.topbar .hamburger {
  display: none; background: none; border: none; cursor: pointer;
  font-size: 1.25rem; color: var(--text); padding: 4px 6px;
}
.topbar-title { font-weight: 700; font-size: 1rem; flex: 1; }
.topbar-user {
  display: flex; align-items: center; gap: .5rem;
  font-size: .83rem;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--pri); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .82rem; flex-shrink: 0;
}
.topbar-user .uname { line-height: 1.2; }
.topbar-user .urole { color: var(--muted); font-size: .72rem; }

.page-body { padding: 1.25rem; flex: 1; }

/* ── Cards ─────────────────────────────────────────────── */
.card {
  background: var(--card-bg); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.card-header {
  padding: .85rem 1.1rem; border-bottom: 1px solid var(--border);
  font-weight: 600; display: flex; align-items: center;
  justify-content: space-between; gap: .5rem; flex-wrap: wrap;
}
.card-header .title { display: flex; align-items: center; gap: .5rem; }
.card-body { padding: 1.1rem; }
.card-body.p0 { padding: 0; }

/* ── Grid helpers ──────────────────────────────────────── */
.row    { display: flex; flex-wrap: wrap; gap: 1rem; }
.col    { flex: 1 1 0; min-width: 0; }
.col-4  { flex: 0 0 calc(33.333% - .67rem); min-width: 220px; }
.col-5  { flex: 0 0 calc(40% - .5rem); }
.col-7  { flex: 0 0 calc(60% - .5rem); }
.col-8  { flex: 0 0 calc(66.666% - .67rem); }

/* ── Stat Cards ────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: .85rem; margin-bottom: 1.25rem;
}
.stat-card {
  background: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1rem 1.1rem;
  display: flex; align-items: center; gap: .8rem;
}
.stat-icon {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; flex-shrink: 0;
}
.stat-num  { font-size: 1.5rem; font-weight: 700; line-height: 1; }
.stat-lbl  { font-size: .75rem; color: var(--muted); }

/* ── Tables ─────────────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th {
  background: #f8fafc; color: var(--muted);
  font-size: .72rem; text-transform: uppercase;
  letter-spacing: .6px; padding: .7rem .9rem;
  white-space: nowrap; font-weight: 600;
  border-bottom: 1px solid var(--border);
}
tbody td { padding: .7rem .9rem; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafcff; }

/* ── Forms ──────────────────────────────────────────────── */
.form-group   { margin-bottom: 1rem; }
.form-label   { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .35rem; }
.form-label .req { color: var(--danger); }
.form-control {
  width: 100%; padding: .55rem .8rem;
  border: 1.5px solid var(--border); border-radius: 7px;
  background: #fff; color: var(--text);
  transition: border-color .18s, box-shadow .18s;
  font-size: .9rem;
}
.form-control:focus {
  outline: none; border-color: var(--pri);
  box-shadow: 0 0 0 3px rgba(30,64,175,.12);
}
.form-control.is-invalid { border-color: var(--danger); }
textarea.form-control { resize: vertical; min-height: 90px; }
.input-icon { position: relative; }
.input-icon i { position: absolute; top: 50%; left: .75rem; transform: translateY(-50%); color: var(--muted); font-size: .85rem; pointer-events: none; }
.input-icon .form-control { padding-left: 2.2rem; }

.form-row { display: flex; gap: .85rem; flex-wrap: wrap; }
.form-row .form-group { flex: 1 1 180px; }
.form-text { font-size: .78rem; color: var(--muted); margin-top: .25rem; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .52rem 1rem; border-radius: 7px; border: 1.5px solid transparent;
  cursor: pointer; font-weight: 600; font-size: .875rem;
  transition: all .18s; white-space: nowrap;
  text-decoration: none !important;
}
.btn:active { transform: scale(.97); }
.btn-primary   { background: var(--pri);     color: #fff; border-color: var(--pri); }
.btn-primary:hover { background: var(--pri-dark); border-color: var(--pri-dark); }
.btn-success   { background: var(--success); color: #fff; border-color: var(--success); }
.btn-danger    { background: var(--danger);  color: #fff; border-color: var(--danger); }
.btn-warning   { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-info      { background: var(--info);    color: #fff; border-color: var(--info); }
.btn-secondary { background: #e2e8f0; color: var(--text); border-color: #e2e8f0; }
.btn-secondary:hover { background: #cbd5e1; }
.btn-outline   { background: transparent; color: var(--pri); border-color: var(--pri); }
.btn-outline:hover { background: var(--pri-light); }
.btn-sm  { padding: .35rem .7rem; font-size: .8rem; border-radius: 6px; }
.btn-xs  { padding: .22rem .5rem; font-size: .75rem; border-radius: 5px; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { padding: .38rem .55rem; }

/* ── Badges ──────────────────────────────────────────────── */
.stbadge {
  display: inline-block; padding: 3px 9px; border-radius: 20px;
  font-size: .72rem; font-weight: 600; white-space: nowrap;
}
.badge-open        { background: #dbeafe; color: #1d4ed8; }
.badge-viewed      { background: #f3f4f6; color: #374151; }
.badge-assigned    { background: #fef3c7; color: #92400e; }
.badge-inprogress  { background: #d1fae5; color: #065f46; }
.badge-resolved    { background: #bbf7d0; color: #14532d; }
.badge-pending     { background: #fee2e2; color: #991b1b; }
.badge-closed      { background: #e5e7eb; color: #374151; }

.pribadge {
  font-size: .75rem; font-weight: 700; padding: 2px 8px;
  border-radius: 4px; display: inline-block;
}
.pri-low  { color: #16a34a; background: #f0fdf4; }
.pri-med  { color: #d97706; background: #fffbeb; }
.pri-high { color: #dc2626; background: #fef2f2; }
.pri-crit { color: #7c3aed; background: #f5f3ff; }

/* ── Alerts ──────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem; border-radius: 7px; font-size: .875rem;
  display: flex; align-items: flex-start; gap: .6rem;
  border-left: 4px solid;
}
.alert-success { background: #f0fdf4; border-color: var(--success); color: #166534; }
.alert-danger  { background: #fef2f2; border-color: var(--danger);  color: #991b1b; }
.alert-info    { background: #f0f9ff; border-color: var(--info);    color: #155e75; }
.alert-warning { background: #fffbeb; border-color: var(--warning); color: #92400e; }
.flash-wrap { position: fixed; top: 68px; right: 1rem; z-index: 9999; min-width: 280px; max-width: 360px; }

/* ── Modal ──────────────────────────────────────────────── */
.modal-bg {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 2000;
  align-items: center; justify-content: center;
  padding: 1rem;
}
.modal-bg.open { display: flex; }
.modal-box {
  background: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow-md); width: 100%; max-width: 480px;
  max-height: 92vh; overflow-y: auto;
  animation: modalIn .22s ease;
}
@keyframes modalIn { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-hdr {
  padding: 1rem 1.1rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-hdr h3 { font-size: 1rem; }
.modal-close { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--muted); padding: 2px 6px; border-radius: 4px; }
.modal-close:hover { background: #f1f5f9; }
.modal-body { padding: 1.1rem; }
.modal-footer { padding: .85rem 1.1rem; border-top: 1px solid var(--border); display: flex; gap: .6rem; justify-content: flex-end; flex-wrap: wrap; }

/* ── Comment thread ─────────────────────────────────────── */
.comment-item { display: flex; gap: .75rem; margin-bottom: 1.25rem; }
.comment-body { flex: 1; background: #f8fafc; padding: .7rem .9rem; border-radius: 8px; }
.comment-meta { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .3rem; margin-bottom: .35rem; }
.comment-msg  { font-size: .875rem; white-space: pre-wrap; word-break: break-word; }

/* ── Timeline (status history) ──────────────────────────── */
.timeline { list-style: none; padding: 0; }
.timeline li {
  display: flex; align-items: flex-start; gap: .65rem;
  padding: .55rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  font-size: .83rem;
}
.timeline li:last-child { border-bottom: none; }
.timeline li .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--pri); flex-shrink: 0; margin-top: .35rem;
}
.timeline-info { flex: 1; }
.timeline-time { color: var(--muted); font-size: .75rem; white-space: nowrap; }

/* ── File list ──────────────────────────────────────────── */
.file-list { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .4rem; }
.file-chip {
  background: var(--pri-light); color: var(--pri);
  border-radius: 6px; padding: 3px 10px; font-size: .78rem;
  display: flex; align-items: center; gap: .35rem;
  text-decoration: none;
}
.file-chip:hover { background: #bfdbfe; text-decoration: none; }

/* ── Detail grid ────────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: .75rem; margin-bottom: 1rem;
}
.detail-item .di-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-bottom: .2rem; }
.detail-item .di-val   { font-size: .875rem; font-weight: 600; }

/* ── Filter bar ─────────────────────────────────────────── */
.filter-bar { display: flex; flex-wrap: wrap; gap: .65rem; align-items: flex-end; }
.filter-bar .form-group { margin-bottom: 0; min-width: 130px; }
.filter-bar .form-label { font-size: .76rem; }
.filter-bar .form-control { font-size: .82rem; padding: .42rem .7rem; }

/* ── Auth pages ─────────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--pri-dark) 0%, var(--pri) 60%, #3b82f6 100%);
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.auth-card {
  background: #fff; border-radius: 14px; box-shadow: var(--shadow-md);
  width: 100%; max-width: 440px; overflow: hidden;
}
.auth-header {
  background: var(--pri-dark); color: #fff;
  padding: 1.8rem 1.5rem; text-align: center;
}
.auth-header .auth-icon {
  width: 60px; height: 60px; border-radius: 50%;
  background: rgba(255,255,255,.15);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; margin: 0 auto .9rem;
}
.auth-header h1 { font-size: 1.3rem; margin-bottom: .25rem; }
.auth-header p  { font-size: .85rem; opacity: .8; }
.auth-body { padding: 1.6rem 1.5rem; }
.auth-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); text-align: center; font-size: .85rem; }

/* ── Profile page ───────────────────────────────────────── */
.profile-avatar {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--pri); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem; font-weight: 700; margin: 0 auto 1rem;
}

/* ── Misc helpers ───────────────────────────────────────── */
.mb0 { margin-bottom: 0 !important; }
.mb1 { margin-bottom: .5rem; }
.mb2 { margin-bottom: 1rem; }
.mb3 { margin-bottom: 1.5rem; }
.mt1 { margin-top: .5rem; }
.mt2 { margin-top: 1rem; }
.gap2 { gap: .5rem; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.w100 { width: 100%; }
.hidden { display: none !important; }
.divider { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty-state i { font-size: 2.2rem; margin-bottom: .6rem; display: block; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .sidebar-brand .close-btn { display: block; }
  .main { margin-left: 0; }
  .topbar .hamburger { display: flex; }
  .col-4, .col-5, .col-7, .col-8 { flex: 0 0 100%; }
  .form-row { flex-direction: column; gap: 0; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar .form-group { min-width: 0; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .detail-grid { grid-template-columns: repeat(2, 1fr); }
  thead th:nth-child(n+5):not(:last-child) { display: none; }
  tbody td:nth-child(n+5):not(:last-child) { display: none; }
  .flash-wrap { left: 1rem; right: 1rem; min-width: unset; }
  .modal-box { max-width: 100%; margin: 0; }
  .page-body { padding: .85rem; }
}
@media (max-width: 420px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .auth-body { padding: 1.2rem 1rem; }
}
