/* Echoterra Helpdesk — app.css */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117; --surface: #1a1d27; --surface2: #22263a;
  --border: #2d3150; --accent: #4f6ef7; --accent2: #38bdf8;
  --green: #10b981; --red: #ef4444; --yellow: #f59e0b; --purple: #8b5cf6;
  --text: #e2e8f0; --muted: #8892b0;
  --sidebar-w: 220px; --radius: 10px;
}

body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

/* ── Shell ── */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w);
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; height: 100vh; overflow-y: auto; z-index: 100;
}
.sidebar-logo { padding: 20px 16px; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.sidebar-logo strong { color: var(--text); }
.nav-links { list-style: none; padding: 10px 0; flex: 1; }
.nav-links li a { display: flex; align-items: center; gap: 8px; padding: 8px 16px; color: var(--muted); text-decoration: none; border-radius: 6px; margin: 1px 8px; transition: all .15s; }
.nav-links li a:hover { background: var(--surface2); color: var(--text); }
.nav-links li.active a { background: var(--accent); color: #fff; }
.nav-section { padding: 14px 16px 4px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--border); }
.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; align-items: center; }
.logout-btn { color: var(--muted); text-decoration: none; font-size: 12px; }
.logout-btn:hover { color: var(--red); }
.main-content { margin-left: var(--sidebar-w); flex: 1; padding: 28px; }
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 22px; font-weight: 700; }

/* ── Cards ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.card-title { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 14px; }

/* ── Stats ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat-card .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.stat-card .value { font-size: 26px; font-weight: 700; margin-top: 6px; }
.stat-card .sub   { font-size: 11px; color: var(--muted); margin-top: 4px; }
.stat-card.green .value { color: var(--green); }
.stat-card.red .value   { color: var(--red); }
.stat-card.blue .value  { color: var(--accent2); }
.stat-card.yellow .value{ color: var(--yellow); }
.stat-card.purple .value{ color: var(--purple); }

/* ── Table ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 10px 14px; text-align: left; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* ── Badges ── */
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; color: #fff; white-space: nowrap; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 7px; font-size: 13px; font-weight: 500; border: none; cursor: pointer; text-decoration: none; transition: all .15s; white-space: nowrap; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #3d5ce0; }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #0da874; }
.btn-danger  { background: var(--red); color: #fff; }
.btn-warning { background: var(--yellow); color: #000; }
.btn-ghost   { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ── Forms ── */
.form-grid   { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-group  { display: flex; flex-direction: column; gap: 5px; margin-bottom: 4px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--muted); }
.form-group input, .form-group select, .form-group textarea {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); border-radius: 7px; padding: 9px 12px; font-size: 13px;
  font-family: inherit; outline: none; transition: border .15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--accent); }
.form-group textarea { resize: vertical; min-height: 80px; }
.form-group.full { grid-column: 1 / -1; }
.form-actions { margin-top: 20px; display: flex; gap: 10px; align-items: center; }

/* ── Toolbar ── */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.search-input { background: var(--surface2); border: 1px solid var(--border); color: var(--text); border-radius: 7px; padding: 8px 12px; font-size: 13px; width: 240px; font-family: inherit; outline: none; }
.search-input:focus { border-color: var(--accent); }

/* ── Ticket list row ── */
.ticket-row { cursor: pointer; }
.ticket-subject { font-weight: 600; color: var(--text); font-size: 13px; }
.ticket-meta    { font-size: 11px; color: var(--muted); margin-top: 2px; }
.priority-dot   { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.p-critical { background: var(--red); }
.p-high     { background: var(--yellow); }
.p-medium   { background: var(--accent); }
.p-low      { background: var(--muted); }

/* ── Timeline ── */
.timeline-item { display: flex; gap: 14px; margin-bottom: 20px; }
.timeline-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; color: #fff; }
.timeline-body  { flex: 1; }
.timeline-header { display: flex; justify-content: space-between; margin-bottom: 6px; }
.timeline-author { font-weight: 600; font-size: 13px; }
.timeline-time   { font-size: 11px; color: var(--muted); }
.timeline-content { background: var(--surface2); border-radius: 8px; padding: 12px 14px; font-size: 13px; line-height: 1.7; white-space: pre-wrap; }
.timeline-internal .timeline-content { border-left: 3px solid var(--yellow); }
.timeline-system .timeline-avatar { background: var(--border); }
.timeline-system .timeline-content { background: transparent; color: var(--muted); font-size: 12px; }

/* ── File list ── */
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.file-card { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; text-align: center; cursor: pointer; transition: border .15s; }
.file-card:hover { border-color: var(--accent); }
.file-card .file-icon { font-size: 32px; margin-bottom: 8px; }
.file-card .file-name { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-card .file-size { font-size: 10px; color: var(--border); margin-top: 2px; }

/* ── Migration queue ── */
.migration-item { display: flex; justify-content: space-between; align-items: center; padding: 12px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; }
.migration-item.done { opacity: .6; }
.migration-info .name { font-weight: 600; font-size: 13px; }
.migration-info .meta { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ── Alerts ── */
.alert { padding: 12px 16px; border-radius: 7px; margin-bottom: 16px; font-size: 13px; }
.alert-success { background: rgba(16,185,129,.12); border: 1px solid var(--green); color: var(--green); }
.alert-error   { background: rgba(239,68,68,.12);  border: 1px solid var(--red);   color: var(--red); }
.alert-info    { background: rgba(79,110,247,.12); border: 1px solid var(--accent); color: var(--accent2); }
.alert-warning { background: rgba(245,158,11,.12); border: 1px solid var(--yellow); color: var(--yellow); }

/* ── Progress ── */
.progress { height: 6px; background: var(--surface2); border-radius: 3px; overflow: hidden; margin: 6px 0; }
.progress-bar { height: 100%; background: var(--accent); border-radius: 3px; transition: width .4s; }
.progress-bar.green { background: var(--green); }

/* ── Login ── */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box  { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 40px; width: 380px; }
.login-box h1 { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.login-box .sub { color: var(--muted); font-size: 13px; margin-bottom: 28px; }

/* ── WO Import ── */
.wo-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 14px; margin-bottom: 10px; }
.wo-card.high-conf   { border-left: 3px solid var(--green); }
.wo-card.med-conf    { border-left: 3px solid var(--yellow); }
.wo-card.low-conf    { border-left: 3px solid var(--red); }
.wo-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.wo-card-subject { font-weight: 600; font-size: 13px; }
.wo-card-date { font-size: 11px; color: var(--muted); }
.wo-card-data { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-bottom: 10px; }
.wo-data-item .lbl { font-size: 10px; color: var(--muted); text-transform: uppercase; }
.wo-data-item .val { font-size: 13px; font-weight: 500; }

/* ── Empty states ── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }

/* ── Misc ── */
.flex { display: flex; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.mt-4 { margin-top: 16px; } .mb-4 { margin-bottom: 16px; }
.text-muted  { color: var(--muted); } .text-green { color: var(--green); }
.text-red    { color: var(--red); }   .text-yellow { color: var(--yellow); }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }

@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 16px; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
}
