/* ICD Tracker - Soft Canvas Design
   ============================================ */

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

:root {
    --bg: #FAFAF8;
    --surface: #FFFFFF;
    --surface2: #F3F2EE;
    --border: #E8E6E1;
    --border-hover: #D1CFC9;
    --accent: #5B4CD2;
    --accent-bg: #EDEBFA;
    --accent-text: #3D32A0;
    --teal: #0D9373;
    --teal-bg: #E1F5EE;
    --teal-text: #085041;
    --coral: #D85A30;
    --coral-bg: #FAECE7;
    --coral-text: #712B13;
    --amber: #BA7517;
    --amber-bg: #FAEEDA;
    --amber-text: #633806;
    --red: #E24B4A;
    --red-bg: #FCEBEB;
    --red-text: #791F1F;
    --text: #1A1A1A;
    --text2: #6B6B6B;
    --text3: #9B9B9B;
    --shadow: 0 1px 3px rgba(0,0,0,.04), 0 4px 12px rgba(0,0,0,.03);
    --shadow-hover: 0 2px 8px rgba(0,0,0,.07);
    --radius: 10px;
    --radius-lg: 14px;
    --sidebar-width: 260px;
    --font: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-display: 'Fraunces', Georgia, serif;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

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

/* === Layout === */
.app-shell {
    min-height: 100vh;
}

/* === Sidebar === */
.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 20px 14px;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-width);
    overflow-y: auto;
    z-index: 100;
    transition: transform .3s ease;
}

.logo { display: flex; align-items: center; gap: 10px; padding: 0 8px; margin-bottom: 28px; }
.logo-mark {
    width: 36px; height: 36px; border-radius: 10px;
    background: var(--accent); display: flex; align-items: center; justify-content: center;
}
.logo-mark svg { width: 18px; height: 18px; }
.logo-text { font-family: var(--font-display); font-size: 17px; font-weight: 600; }
.logo-text span { font-family: var(--font); font-size: 12px; color: var(--text3); font-weight: 400; display: block; margin-top: -2px; }

.nav-section { font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text3); padding: 0 10px; margin: 22px 0 6px; font-weight: 500; }

.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: var(--radius); font-size: 13.5px;
    color: var(--text2); cursor: pointer; transition: .15s; margin-bottom: 2px;
    text-decoration: none;
}
.nav-item:hover { background: var(--surface2); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent-bg); color: var(--accent); font-weight: 500; }

.nav-icon { width: 18px; text-align: center; font-size: 14px; opacity: .6; flex-shrink: 0; }
.nav-item.active .nav-icon { opacity: 1; }

.nav-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.nav-count {
    margin-left: auto; font-size: 11px;
    background: var(--surface2); color: var(--text3);
    padding: 2px 9px; border-radius: 20px; font-weight: 500;
}
.nav-item.active .nav-count { background: rgba(91,76,210,.15); color: var(--accent); }

/* === Main Content === */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 28px 32px;
    min-height: 100vh;
}

/* === Header === */
.page-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 28px; flex-wrap: wrap; gap: 16px; }
.page-header h1 { font-family: var(--font-display); font-size: 24px; font-weight: 600; line-height: 1.2; }
.page-header .subtitle { font-size: 13px; color: var(--text3); margin-top: 4px; }
.header-actions { display: flex; gap: 8px; align-items: center; }

/* === Buttons === */
.btn {
    padding: 8px 18px; border-radius: var(--radius);
    border: 1px solid var(--border); background: var(--surface);
    color: var(--text); font-size: 13px; cursor: pointer;
    font-family: var(--font); transition: .15s;
    display: inline-flex; align-items: center; gap: 7px;
    box-shadow: var(--shadow); white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 2px 8px rgba(91,76,210,.25); }
.btn-primary:hover { opacity: .9; color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-danger { border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red-bg); }

/* === Stat Cards === */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 28px; }
.stat-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 16px 18px; box-shadow: var(--shadow);
    overflow: hidden;
}
.stat-card .label { font-size: 11px; color: var(--text3); margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.stat-card .label i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.stat-card .value { font-size: 26px; font-weight: 600; letter-spacing: -.5px; }
.stat-card .sub { font-size: 11px; color: var(--text3); margin-top: 4px; }

/* === Tabs / Filters === */
.tabs {
    display: flex; gap: 4px; margin-bottom: 18px;
    background: var(--surface2); border-radius: var(--radius); padding: 3px; width: fit-content;
}
.tab {
    padding: 7px 18px; border-radius: 8px; font-size: 13px;
    color: var(--text2); cursor: pointer; border: none;
    background: transparent; font-family: var(--font); transition: .12s;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface); color: var(--text); font-weight: 500; box-shadow: var(--shadow); }

/* === Ticket List === */
.ticket-list { display: flex; flex-direction: column; gap: 6px; }
.ticket-row {
    display: grid;
    grid-template-columns: 65px 1fr 95px 85px 90px 40px;
    align-items: center; padding: 14px 16px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; font-size: 13px; cursor: pointer;
    transition: .15s; box-shadow: var(--shadow); text-decoration: none; color: inherit;
}
.ticket-row:hover {
    border-color: var(--accent); transform: translateY(-1px);
    box-shadow: var(--shadow-hover); text-decoration: none;
}
.ticket-id { font-size: 12px; color: var(--text3); font-weight: 500; }
.ticket-title { font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* === Tags / Badges === */
.tag {
    padding: 4px 12px; border-radius: 20px; font-size: 11px;
    font-weight: 500; display: inline-block; white-space: nowrap;
}
.tag-bug { background: var(--coral-bg); color: var(--coral-text); }
.tag-feature { background: var(--teal-bg); color: var(--teal-text); }
.tag-task { background: var(--amber-bg); color: var(--amber-text); }

.status-badge { font-size: 12px; font-weight: 500; }
.status-open { color: var(--coral); }
.status-in_progress { color: var(--teal); }
.status-review { color: var(--accent); }
.status-resolved { color: var(--teal); }
.status-closed { color: var(--text3); }

.priority-dot { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text2); }
.priority-dot i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.priority-critical i { background: var(--red); }
.priority-high i { background: var(--coral); }
.priority-medium i { background: var(--amber); }
.priority-low i { background: var(--text3); }

/* === Avatar === */
.avatar {
    width: 28px; height: 28px; border-radius: 50%;
    font-size: 10px; font-weight: 600; display: flex;
    align-items: center; justify-content: center; color: #fff; flex-shrink: 0;
}
.avatar-sm { width: 24px; height: 24px; font-size: 9px; }
.avatar-lg { width: 40px; height: 40px; font-size: 14px; }

/* === Forms === */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--text); }
.form-input, .form-select, .form-textarea {
    width: 100%; padding: 10px 14px; border: 1px solid var(--border);
    border-radius: var(--radius); font-family: var(--font); font-size: 14px;
    background: var(--surface); color: var(--text); transition: .15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91,76,210,.1);
}
.form-textarea { resize: vertical; min-height: 100px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-hint { font-size: 12px; color: var(--text3); margin-top: 4px; }

/* === Card === */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.card-header {
    padding: 18px 22px; border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
}
.card-header h2 { font-size: 16px; font-weight: 600; }
.card-body { padding: 22px; }

/* === Ticket Detail === */
.ticket-detail-grid { display: grid; grid-template-columns: 1fr 300px; gap: 24px; }
.ticket-meta-table { width: 100%; font-size: 13px; }
.ticket-meta-table td { padding: 8px 0; }
.ticket-meta-table td:first-child { color: var(--text3); width: 110px; }

/* === Timeline / Activity === */
.timeline { position: relative; padding-left: 24px; }
.timeline::before {
    content: ''; position: absolute; left: 7px; top: 8px; bottom: 8px;
    width: 2px; background: var(--border);
}
.timeline-item { position: relative; padding-bottom: 20px; }
.timeline-dot {
    position: absolute; left: -24px; top: 4px;
    width: 16px; height: 16px; border-radius: 50%;
    background: var(--surface); border: 2px solid var(--border);
    z-index: 1;
}
.timeline-dot.created { border-color: var(--accent); background: var(--accent-bg); }
.timeline-dot.resolved { border-color: var(--teal); background: var(--teal-bg); }
.timeline-dot.commented { border-color: var(--accent); background: var(--accent-bg); }
.timeline-dot.status_changed { border-color: var(--amber); background: var(--amber-bg); }
.timeline-dot.assigned { border-color: var(--teal); background: var(--teal-bg); }
.timeline-content { font-size: 13px; color: var(--text2); }
.timeline-content strong { color: var(--text); font-weight: 500; }
.timeline-time { font-size: 11px; color: var(--text3); margin-top: 2px; }
.timeline-comment {
    margin-top: 8px; padding: 12px 16px; background: var(--surface2);
    border-radius: var(--radius); font-size: 13px; color: var(--text);
}

/* === Resolution Recap (Jira-style) === */
.resolution-card {
    background: var(--teal-bg); border: 1px solid rgba(13,147,115,.2);
    border-radius: var(--radius-lg); padding: 20px 22px; margin-bottom: 24px;
}
.resolution-card .badge {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--teal); color: #fff; padding: 4px 14px;
    border-radius: 20px; font-size: 12px; font-weight: 500; margin-bottom: 12px;
}
.resolution-card h3 { font-size: 15px; font-weight: 600; color: var(--teal-text); margin-bottom: 8px; }
.resolution-card p { font-size: 13px; color: var(--teal-text); line-height: 1.6; }
.resolution-meta {
    display: flex; gap: 24px; margin-top: 14px; padding-top: 14px;
    border-top: 1px solid rgba(13,147,115,.15);
}
.resolution-meta div { font-size: 12px; }
.resolution-meta .label { color: rgba(8,80,65,.6); margin-bottom: 2px; }
.resolution-meta .val { color: var(--teal-text); font-weight: 500; }

/* === Notifications Dropdown === */
.notif-bell { position: relative; cursor: pointer; }
.notif-badge {
    position: absolute; top: -4px; right: -4px;
    background: var(--red); color: #fff; font-size: 9px; font-weight: 600;
    width: 18px; height: 18px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}
.notif-dropdown {
    position: absolute; top: 100%; right: 0; margin-top: 8px;
    width: 360px; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); box-shadow: 0 8px 32px rgba(0,0,0,.1);
    z-index: 200; display: none;
}
.notif-dropdown.open { display: block; }
.notif-dropdown-header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.notif-dropdown-header h3 { font-size: 14px; font-weight: 600; }
.notif-item { padding: 12px 18px; border-bottom: 1px solid var(--surface2); font-size: 13px; cursor: pointer; transition: .1s; display: block; color: inherit; }
.notif-item:hover { background: var(--surface2); text-decoration: none; }
.notif-item.unread { background: var(--accent-bg); }
.notif-item .time { font-size: 11px; color: var(--text3); margin-top: 2px; }

/* === Flash Messages === */
.flash { padding: 12px 18px; border-radius: var(--radius); margin-bottom: 18px; font-size: 13px; }
.flash-success { background: var(--teal-bg); color: var(--teal-text); }
.flash-error { background: var(--red-bg); color: var(--red-text); }
.flash-info { background: var(--accent-bg); color: var(--accent-text); }

/* === Empty State === */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text3); }
.empty-state h3 { font-size: 18px; color: var(--text2); margin-bottom: 8px; }
.empty-state p { font-size: 14px; margin-bottom: 20px; }

/* === Mobile Hamburger === */
.mobile-toggle {
    display: none; position: fixed; top: 14px; left: 14px;
    width: 40px; height: 40px; border-radius: var(--radius);
    background: var(--surface); border: 1px solid var(--border);
    box-shadow: var(--shadow); cursor: pointer; z-index: 200;
    align-items: center; justify-content: center; font-size: 18px;
}
.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.3); z-index: 90;
}

/* === Responsive === */
@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .ticket-detail-grid { grid-template-columns: 1fr; }
    .ticket-row { grid-template-columns: 55px 1fr 80px 40px; }
    .ticket-row .priority-dot,
    .ticket-row .status-badge { display: none; }
}

@media (max-width: 768px) {
    .main-content { margin-left: 0; padding: 70px 16px 24px; }

    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.open { display: block; }
    .mobile-toggle { display: flex; }

    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-card { padding: 12px 14px; }
    .stat-card .value { font-size: 22px; }

    .page-header { flex-direction: column; }
    .page-header h1 { font-size: 20px; }
    .header-actions { width: 100%; }
    .header-actions .btn { flex: 1; justify-content: center; }

    .ticket-row {
        grid-template-columns: 1fr auto;
        gap: 6px; padding: 12px 14px;
    }
    .ticket-row .ticket-id { grid-column: 1; }
    .ticket-row .ticket-title { grid-column: 1 / -1; }
    .ticket-row .tag { grid-column: 1; }
    .ticket-row .avatar { grid-column: 2; grid-row: 1; }
    .ticket-row .priority-dot,
    .ticket-row .status-badge { display: none; }

    .form-row { grid-template-columns: 1fr; }
    .tabs { width: 100%; overflow-x: auto; }
    .resolution-meta { flex-wrap: wrap; gap: 14px; }

    .notif-dropdown { width: calc(100vw - 32px); right: -60px; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .header-actions { flex-direction: column; }
    .header-actions .btn { width: 100%; }
}
