@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;500;600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,300&display=swap');

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

:root {
    --bg: #0d0f14;
    --surface: #151820;
    --surface2: #1c2030;
    --surface3: #232840;
    --border: #2a3050;
    --border2: #3a4570;
    --accent: #6366f1;
    --accent2: #818cf8;
    --accent-glow: rgba(99,102,241,0.15);
    --text: #e8eaf6;
    --text2: #9ca3c7;
    --text3: #6b7498;
    --low: #22c55e;
    --medium: #f59e0b;
    --high: #f97316;
    --urgent: #ef4444;
    --open: #6366f1;
    --progress: #0ea5e9;
    --review: #a855f7;
    --completed: #22c55e;
    --closed: #6b7498;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --shadow: 0 4px 24px rgba(0,0,0,0.4);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
    --transition: 0.2s ease;
}

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 15px;
    line-height: 1.6;
}

h1, h2, h3, h4, h5 {
    font-family: 'Syne', sans-serif;
    font-weight: 700;
    letter-spacing: -0.02em;
}

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

input, textarea, select {
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
}

/* ===== LAYOUT ===== */
.app-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-logo {
    padding: 28px 24px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}

.logo-icon {
    width: 38px;
    height: 38px;
    background: var(--accent);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.logo-text {
    font-family: 'Syne', sans-serif;
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--text);
}

.sidebar-nav {
    padding: 16px 12px;
    flex: 1;
}

.nav-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text3);
    padding: 0 12px;
    margin: 16px 0 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text2);
    transition: all var(--transition);
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    margin-bottom: 2px;
    text-decoration: none;
}

.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--accent-glow); color: var(--accent2); }
.nav-item .icon { font-size: 16px; width: 20px; text-align: center; }

.nav-badge {
    margin-left: auto;
    background: var(--urgent);
    color: white;
    border-radius: 20px;
    padding: 1px 7px;
    font-size: 11px;
    font-weight: 700;
}

.sidebar-user {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    color: white;
    flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text3); }

.logout-btn {
    color: var(--text3);
    font-size: 16px;
    padding: 4px;
    transition: color var(--transition);
    cursor: pointer;
    background: none;
    border: none;
}
.logout-btn:hover { color: var(--urgent); }

/* ===== MAIN ===== */
.main-content {
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 700;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.content-area {
    padding: 32px;
    flex: 1;
}

/* ===== CARDS / STATS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    position: relative;
    overflow: hidden;
    transition: border-color var(--transition);
}

.stat-card:hover { border-color: var(--border2); }

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
}

.stat-card.accent::before { background: var(--accent); }
.stat-card.blue::before { background: var(--progress); }
.stat-card.green::before { background: var(--completed); }
.stat-card.orange::before { background: var(--high); }
.stat-card.red::before { background: var(--urgent); }

.stat-value {
    font-family: 'Syne', sans-serif;
    font-size: 2.2rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 6px;
}

.stat-label {
    font-size: 13px;
    color: var(--text2);
    font-weight: 500;
}

.stat-icon {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 28px;
    opacity: 0.15;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    border: none;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: white;
}
.btn-primary:hover { background: #5558e5; color: white; transform: translateY(-1px); box-shadow: 0 4px 16px rgba(99,102,241,0.4); }

.btn-secondary {
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--surface3); border-color: var(--border2); color: var(--text); }

.btn-danger {
    background: rgba(239,68,68,0.15);
    color: var(--urgent);
    border: 1px solid rgba(239,68,68,0.3);
}
.btn-danger:hover { background: var(--urgent); color: white; }

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-icon {
    padding: 8px;
    border-radius: var(--radius-xs);
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text2);
    cursor: pointer;
    font-size: 16px;
    transition: all var(--transition);
}
.btn-icon:hover { background: var(--surface3); color: var(--text); }

/* ===== FORMS ===== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 1rem;
    font-weight: 700;
}

.form-group { margin-bottom: 16px; }

.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-control {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text);
    transition: border-color var(--transition);
    outline: none;
    appearance: none;
}

.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.form-control::placeholder { color: var(--text3); }

textarea.form-control { resize: vertical; min-height: 100px; }

select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24'%3E%3Cpath stroke='%236b7498' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    padding-right: 36px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ===== TABLE ===== */
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.table-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.search-input {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 14px 8px 36px;
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    outline: none;
    transition: border-color var(--transition);
    width: 220px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24'%3E%3Cpath stroke='%236b7498' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 10px center;
    background-size: 16px;
}

.search-input:focus { border-color: var(--accent); }

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    padding: 12px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text3);
    background: var(--surface2);
    border-bottom: 1px solid var(--border);
}

td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    vertical-align: middle;
}

tr:last-child td { border-bottom: none; }

tbody tr:hover { background: var(--surface2); }

/* ===== BADGES ===== */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-low { background: rgba(34,197,94,0.15); color: var(--low); }
.badge-medium { background: rgba(245,158,11,0.15); color: var(--medium); }
.badge-high { background: rgba(249,115,22,0.15); color: var(--high); }
.badge-urgent { background: rgba(239,68,68,0.15); color: var(--urgent); }

.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.status-open { background: rgba(99,102,241,0.15); color: var(--open); }
.status-progress { background: rgba(14,165,233,0.15); color: var(--progress); }
.status-review { background: rgba(168,85,247,0.15); color: var(--review); }
.status-completed { background: rgba(34,197,94,0.15); color: var(--completed); }
.status-closed { background: rgba(107,116,152,0.15); color: var(--closed); }

/* ===== TICKET DETAIL ===== */
.ticket-detail-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 24px;
    align-items: start;
}

.ticket-meta-list { list-style: none; }
.ticket-meta-list li {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.ticket-meta-list li:last-child { border-bottom: none; }
.meta-key { color: var(--text3); font-weight: 500; }

.comment {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.comment-bubble {
    flex: 1;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.comment-author { font-weight: 600; font-size: 14px; }
.comment-date { font-size: 12px; color: var(--text3); }
.comment-text { font-size: 14px; color: var(--text2); white-space: pre-wrap; }

/* ===== ALERTS ===== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-success { background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.3); color: #4ade80; }
.alert-error { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: #f87171; }
.alert-info { background: rgba(99,102,241,0.1); border: 1px solid rgba(99,102,241,0.3); color: var(--accent2); }

/* ===== LOGIN PAGE ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at 60% 30%, rgba(99,102,241,0.08) 0%, transparent 60%),
                radial-gradient(ellipse at 20% 80%, rgba(168,85,247,0.05) 0%, transparent 50%),
                var(--bg);
}

.login-box {
    width: 100%;
    max-width: 420px;
    padding: 48px 40px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 24px 80px rgba(0,0,0,0.5);
}

.login-logo {
    text-align: center;
    margin-bottom: 36px;
}

.login-logo-icon {
    width: 56px;
    height: 56px;
    background: var(--accent);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    margin: 0 auto 16px;
}

.login-title { font-size: 1.7rem; text-align: center; }
.login-sub { text-align: center; color: var(--text3); font-size: 14px; margin-top: 6px; }

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text3);
}

.empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }
.empty-text { font-size: 15px; }

/* ===== NOTIFICATIONS ===== */
.notif-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 12px;
    align-items: flex-start;
    transition: background var(--transition);
}
.notif-item:hover { background: var(--surface2); }
.notif-item.unread { border-left: 3px solid var(--accent); }
.notif-dot { width: 8px; height: 8px; background: var(--accent); border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.notif-msg { font-size: 14px; margin-bottom: 3px; }
.notif-time { font-size: 12px; color: var(--text3); }

/* ===== FILTER BAR ===== */
.filter-bar {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.filter-select {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 7px 12px;
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
    outline: none;
    cursor: pointer;
    transition: border-color var(--transition);
}

.filter-select:focus { border-color: var(--accent); }

/* ===== FILE ATTACHMENTS ===== */
.attachment-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    margin-bottom: 6px;
    font-size: 13px;
}

.attachment-icon { font-size: 18px; }
.attachment-name { flex: 1; color: var(--text2); }
.attachment-size { color: var(--text3); font-size: 12px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .app-layout { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    .content-area { padding: 16px; }
    .ticket-detail-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ===== UTILS ===== */
.text-muted { color: var(--text3); }
.text-sm { font-size: 13px; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.ml-auto { margin-left: auto; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
