/* ============================================================
   ERP Bug Tracker – Stylesheet
   ============================================================ */

:root {
  --sidebar-w: 240px;
  --topbar-h: 56px;
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --primary-light: #e0e7ff;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #0284c7;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --sidebar-bg: #1e1b4b;
  --sidebar-text: #c7d2fe;
  --sidebar-active: #4f46e5;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body { font-family: 'Segoe UI', system-ui, sans-serif; font-size: 14px;
       background: var(--bg); color: var(--text); line-height: 1.6; }

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

/* ── Shell ───────────────────────────────────────────────── */

.app-shell { display: flex; min-height: 100vh; }

/* ── Sidebar ─────────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-w); background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; height: 100vh;
  z-index: 200; transition: transform .25s;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 20px 16px;
  font-size: 18px; font-weight: 700;
  color: #fff; border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-brand i { color: #818cf8; font-size: 20px; }

.sidebar-nav { list-style: none; padding: 12px 0; flex: 1; }

.nav-section {
  padding: 16px 20px 6px;
  font-size: 11px; font-weight: 600; letter-spacing: .06em;
  color: rgba(255,255,255,.35); text-transform: uppercase;
}

.nav-item a, .nav-btn-logout {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px; color: var(--sidebar-text);
  border: none; background: none; width: 100%;
  font-size: 14px; cursor: pointer; border-radius: 0;
  transition: background .15s, color .15s;
}
.nav-item a:hover, .nav-btn-logout:hover {
  background: rgba(255,255,255,.08); color: #fff; text-decoration: none;
}
.nav-item.active a {
  background: var(--sidebar-active); color: #fff;
}
.nav-item i { width: 18px; text-align: center; }

/* ── Main area ───────────────────────────────────────────── */

.main-area {
  margin-left: var(--sidebar-w); flex: 1;
  display: flex; flex-direction: column; min-height: 100vh;
}

/* ── Topbar ──────────────────────────────────────────────── */

.topbar {
  height: var(--topbar-h); background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px;
  padding: 0 20px; position: sticky; top: 0; z-index: 100;
}
.sidebar-toggle { display: none; background: none; border: none;
  font-size: 18px; cursor: pointer; color: var(--text-muted); }
.topbar-title { flex: 1; font-weight: 600; font-size: 16px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }

.user-chip { display: flex; align-items: center; gap: 8px;
  color: var(--text-muted); font-size: 13px; }
.user-chip i { font-size: 20px; color: var(--primary); }

/* ── Role badges ─────────────────────────────────────────── */

.role-badge {
  padding: 2px 8px; border-radius: 20px; font-size: 11px;
  font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
}
.role-admin     { background: #fef3c7; color: #92400e; }
.role-developer { background: #dbeafe; color: #1e40af; }
.role-user      { background: #f0fdf4; color: #166534; }

/* ── Notification bell ───────────────────────────────────── */

.notif-wrap { position: relative; }
.notif-btn {
  position: relative; background: none; border: none;
  font-size: 18px; cursor: pointer; color: var(--text-muted);
  padding: 6px;
}
.notif-btn:hover { color: var(--primary); }
.notif-badge {
  position: absolute; top: 2px; right: 2px;
  background: var(--danger); color: #fff;
  border-radius: 50%; font-size: 10px;
  min-width: 16px; height: 16px; display: flex;
  align-items: center; justify-content: center;
  font-weight: 700; padding: 0 3px;
}
.notif-dropdown {
  position: absolute; right: 0; top: calc(100% + 8px);
  width: 320px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-md); z-index: 500;
}
.notif-header { padding: 12px 16px; font-weight: 600; border-bottom: 1px solid var(--border); }
.notif-item {
  display: block; padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text); transition: background .1s;
}
.notif-item:hover { background: #f8fafc; text-decoration: none; }
.notif-item.read { opacity: .65; }
.notif-msg { font-size: 13px; }
.notif-time { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.notif-empty { padding: 16px; text-align: center; color: var(--text-muted); }

/* ── Page content ────────────────────────────────────────── */

.page-content { padding: 24px; flex: 1; }

/* ── Alerts ──────────────────────────────────────────────── */

.alert {
  padding: 12px 16px; border-radius: var(--radius);
  margin-bottom: 16px; position: relative; padding-right: 36px;
  font-size: 14px;
}
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.alert-error, .alert-danger   { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.alert-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }
.alert-close { position: absolute; right: 12px; top: 10px;
  background: none; border: none; cursor: pointer; font-size: 18px; opacity: .6; }
.alert-close:hover { opacity: 1; }

/* ── Cards ───────────────────────────────────────────────── */

.card { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border);
  font-weight: 600; display: flex; align-items: center; gap: 10px; }
.card-body { padding: 20px; }
.card-footer { padding: 14px 20px; border-top: 1px solid var(--border); background: #f8fafc; }

/* ── Stat cards ──────────────────────────────────────────── */

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; text-align: center;
}
.stat-card .stat-value { font-size: 32px; font-weight: 700; color: var(--primary); }
.stat-card .stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.stat-card.stat-danger  .stat-value { color: var(--danger); }
.stat-card.stat-warning .stat-value { color: var(--warning); }
.stat-card.stat-success .stat-value { color: var(--success); }
.stat-card.stat-info    .stat-value { color: var(--info); }

/* ── Tables ──────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { background: #f8fafc; padding: 10px 14px; text-align: left;
  font-weight: 600; color: var(--text-muted); border-bottom: 2px solid var(--border);
  white-space: nowrap; }
td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: #f8fafc; }
.table-actions { display: flex; gap: 6px; align-items: center; }

/* ── Badges ──────────────────────────────────────────────── */

.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600; letter-spacing: .03em; white-space: nowrap;
}
.badge-open       { background: #dbeafe; color: #1e40af; }
.badge-progress   { background: #fef3c7; color: #92400e; }
.badge-review     { background: #ede9fe; color: #5b21b6; }
.badge-resolved   { background: #d1fae5; color: #065f46; }
.badge-closed     { background: #f1f5f9; color: #475569; }
.badge-rejected   { background: #fee2e2; color: #991b1b; }
.badge-critical   { background: #fee2e2; color: #991b1b; }
.badge-high       { background: #ffedd5; color: #9a3412; }
.badge-medium     { background: #fef3c7; color: #92400e; }
.badge-low        { background: #f0fdf4; color: #166534; }
.badge-secondary  { background: #f1f5f9; color: #475569; }
.badge-bug        { background: #fee2e2; color: #991b1b; }
.badge-task       { background: #dbeafe; color: #1e40af; }
.badge-feature    { background: #d1fae5; color: #065f46; }
.badge-improvement { background: #ede9fe; color: #5b21b6; }

/* ── Buttons ─────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; cursor: pointer;
  border: 1px solid transparent; transition: all .15s;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: #f1f5f9; }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-danger  { background: var(--danger);  color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-xs { padding: 2px 8px; font-size: 11px; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ── Forms ───────────────────────────────────────────────── */

.form-group { margin-bottom: 18px; }
.form-row { display: grid; gap: 16px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

label { display: block; font-weight: 500; margin-bottom: 5px; font-size: 13px; }
label .required { color: var(--danger); margin-left: 2px; }

input[type=text], input[type=email], input[type=password], input[type=date],
input[type=number], textarea, select {
  width: 100%; padding: 8px 12px; font-size: 14px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  transition: border-color .15s;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}
.has-error input, .has-error select, .has-error textarea {
  border-color: var(--danger);
}
.help-block { font-size: 12px; color: var(--danger); margin-top: 4px; }
textarea { resize: vertical; min-height: 100px; }

.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Page header ─────────────────────────────────────────── */

.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 20px; gap: 16px; flex-wrap: wrap;
}
.page-header h1 { font-size: 22px; font-weight: 700; }
.page-header p { color: var(--text-muted); font-size: 13px; margin-top: 3px; }

/* ── Ticket detail ───────────────────────────────────────── */

.ticket-meta-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px;
  margin-bottom: 20px;
}
.meta-item { background: #f8fafc; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; }
.meta-item .meta-label { font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.meta-item .meta-value { margin-top: 4px; font-weight: 500; }

.comment-thread { display: flex; flex-direction: column; gap: 12px; }
.comment-item {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 14px;
  background: var(--surface);
}
.comment-item.internal { background: #fffbeb; border-color: #fde68a; }
.comment-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.comment-author { font-weight: 600; font-size: 13px; }
.comment-time { font-size: 12px; color: var(--text-muted); }
.comment-body { font-size: 14px; white-space: pre-wrap; }

.history-list { display: flex; flex-direction: column; gap: 6px; }
.history-item { font-size: 12px; color: var(--text-muted); padding: 6px 0;
  border-bottom: 1px solid var(--border); display: flex; gap: 6px; }
.history-item:last-child { border-bottom: 0; }
.history-field { font-weight: 600; color: var(--text); }

/* ── Attachments ─────────────────────────────────────────── */

.attachment-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.attachment-item {
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; text-align: center; width: 120px;
  background: #f8fafc; font-size: 11px;
}
.attachment-item img { width: 100%; height: 80px; object-fit: cover; display: block; }
.attachment-item .attach-icon { font-size: 28px; padding: 16px; color: var(--text-muted); display: block; }
.attachment-name { padding: 4px 6px; word-break: break-all; }
.attachment-size { color: var(--text-muted); padding-bottom: 6px; }

/* ── Filter bar ──────────────────────────────────────────── */

.filter-bar {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 16px;
}
.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; align-items: end; }
.filter-actions { display: flex; gap: 8px; margin-top: 4px; align-items: center; }

/* ── Search highlight ────────────────────────────────────── */

.ticket-no { font-family: monospace; font-weight: 600; color: var(--primary); }

/* ── Status change inline ────────────────────────────────── */

.status-quick select { width: auto; padding: 4px 8px; font-size: 12px; }

/* ── Login page ──────────────────────────────────────────── */

.auth-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #1e1b4b 100%);
}
.auth-box {
  background: var(--surface); border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  padding: 40px; width: 100%; max-width: 400px;
}
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo i { font-size: 40px; color: var(--primary); }
.auth-logo h1 { font-size: 20px; font-weight: 700; margin-top: 10px; }
.auth-logo p { color: var(--text-muted); font-size: 13px; }

/* ── Pagination ──────────────────────────────────────────── */

.pagination { display: flex; gap: 4px; list-style: none; flex-wrap: wrap; }
.pagination .page-item .page-link {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; height: 32px; padding: 0 8px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px; color: var(--text); background: var(--surface);
  text-decoration: none; transition: all .15s;
}
.pagination .page-item.active .page-link { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .page-item .page-link:hover { background: var(--primary-light); }

/* ── Tabs ────────────────────────────────────────────────── */

.tab-nav { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab-nav a {
  padding: 10px 18px; font-size: 13px; font-weight: 500;
  color: var(--text-muted); border-bottom: 2px solid transparent;
  margin-bottom: -2px; transition: all .15s; text-decoration: none;
}
.tab-nav a:hover  { color: var(--primary); }
.tab-nav a.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Empty state ─────────────────────────────────────────── */

.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state i { font-size: 48px; margin-bottom: 12px; display: block; opacity: .4; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 6px; }

/* ── Responsive ──────────────────────────────────────────── */

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-area { margin-left: 0; }
  .sidebar-toggle { display: block; }
  .form-row.cols-2, .form-row.cols-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Misc ────────────────────────────────────────────────── */

.divider { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.flex-1 { flex: 1; }
.d-inline { display: inline; }
.fw-600 { font-weight: 600; }
.small { font-size: 12px; }
