/* =========================================================
   SUPPORTDESK CRM
   Responsive CRM Dashboard
========================================================= */

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

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --bg: #f5f7fb;
    --white: #ffffff;
    --text: #172033;
    --muted: #6b7280;
    --border: #e5e7eb;

    --open-bg: #dcfce7;
    --open-text: #15803d;

    --progress-bg: #fef3c7;
    --progress-text: #b45309;

    --closed-bg: #e0e7ff;
    --closed-text: #4338ca;

    --high-bg: #fee2e2;
    --high-text: #dc2626;

    --medium-bg: #fef3c7;
    --medium-text: #d97706;

    --low-bg: #dcfce7;
    --low-text: #16a34a;

    --danger: #dc2626;
}

body {
    font-family:
        Inter,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}


/* =========================================================
   APP LAYOUT
========================================================= */

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


/* =========================================================
   SIDEBAR
========================================================= */

.sidebar {
    width: 250px;
    min-height: 100vh;
    background: var(--white);
    border-right: 1px solid var(--border);

    display: flex;
    flex-direction: column;

    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;

    padding: 28px 22px;

    border-bottom: 1px solid var(--border);
}

.brand-icon {
    width: 42px;
    height: 42px;

    border-radius: 12px;

    background: var(--primary);
    color: white;

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 22px;
    font-weight: 800;
}

.brand h2 {
    font-size: 18px;
    line-height: 1.2;
}

.brand span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-top: 3px;
}


/* Navigation */

.sidebar-nav {
    padding: 22px 14px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;

    padding: 13px 15px;

    margin-bottom: 7px;

    border-radius: 10px;

    color: #4b5563;
    text-decoration: none;

    font-size: 14px;
    font-weight: 600;

    transition: 0.2s ease;
}

.nav-item span {
    font-size: 19px;
}

.nav-item:hover {
    background: #f3f6ff;
    color: var(--primary);
}

.nav-item.active {
    background: #eff6ff;
    color: var(--primary);
}


/* Sidebar bottom */

.sidebar-bottom {
    margin-top: auto;

    padding: 18px;

    border-top: 1px solid var(--border);

    display: flex;
    align-items: center;
    gap: 10px;
}

.status-dot {
    width: 10px;
    height: 10px;

    border-radius: 50%;

    background: #22c55e;
}

.sidebar-bottom strong {
    display: block;
    font-size: 12px;
}

.sidebar-bottom small {
    display: block;
    color: var(--muted);
    font-size: 11px;
    margin-top: 2px;
}


/* =========================================================
   MAIN CONTENT
========================================================= */

.main-content {
    flex: 1;
    min-width: 0;

    padding: 32px 38px;
}


/* =========================================================
   TOPBAR
========================================================= */

.topbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;

    gap: 20px;

    margin-bottom: 30px;
}

.eyebrow {
    color: var(--primary);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1.5px;
    margin-bottom: 6px;
}

.topbar h1 {
    font-size: 30px;
    line-height: 1.2;
}

.subtitle {
    color: var(--muted);
    margin-top: 7px;
    font-size: 14px;
}


/* =========================================================
   BUTTONS
========================================================= */

.primary-btn,
.secondary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;

    text-decoration: none;

    border-radius: 9px;

    font-size: 14px;
    font-weight: 700;

    cursor: pointer;

    transition: 0.2s ease;
}

.primary-btn {
    background: var(--primary);
    color: white;

    padding: 12px 18px;

    border: none;
}

.primary-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.secondary-btn {
    background: white;
    color: var(--primary);

    border: 1px solid #bfdbfe;

    padding: 10px 15px;
}

.secondary-btn:hover {
    background: #eff6ff;
}


/* =========================================================
   STATS
========================================================= */

.stats-grid {
    display: grid;

    grid-template-columns:
        repeat(5, minmax(0, 1fr));

    gap: 15px;

    margin-bottom: 28px;
}

.stat-card {
    background: var(--white);

    border: 1px solid var(--border);

    border-radius: 13px;

    padding: 18px;

    display: flex;
    align-items: center;

    gap: 13px;

    box-shadow:
        0 2px 8px rgba(15, 23, 42, 0.03);
}

.stat-icon {
    width: 42px;
    height: 42px;

    flex-shrink: 0;

    border-radius: 10px;

    background: #eff6ff;
    color: var(--primary);

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 18px;
    font-weight: 800;
}

.open-icon {
    background: var(--open-bg);
    color: var(--open-text);
}

.progress-icon {
    background: var(--progress-bg);
    color: var(--progress-text);
}

.closed-icon {
    background: var(--closed-bg);
    color: var(--closed-text);
}

.overdue-icon {
    background: var(--high-bg);
    color: var(--high-text);
}

.stat-card span {
    display: block;

    color: var(--muted);

    font-size: 12px;
    font-weight: 600;

    margin-bottom: 4px;
}

.stat-card strong {
    display: block;

    font-size: 24px;
    line-height: 1;
}

.overdue-card {
    border-color: #fecaca;
}


/* =========================================================
   TICKETS SECTION
========================================================= */

.tickets-section {
    background: var(--white);

    border: 1px solid var(--border);

    border-radius: 15px;

    overflow: hidden;

    box-shadow:
        0 3px 12px rgba(15, 23, 42, 0.04);
}

.section-header {
    padding: 24px 24px 18px;

    display: flex;
    align-items: center;
    justify-content: space-between;
}

.section-header h2 {
    font-size: 19px;
}

.section-header p {
    color: var(--muted);

    font-size: 13px;

    margin-top: 5px;
}


/* =========================================================
   FILTER BAR
========================================================= */

.filter-bar {
    display: grid;

    grid-template-columns:
        minmax(250px, 1fr)
        170px
        170px;

    gap: 10px;

    padding: 0 24px 20px;
}

.search-box {
    position: relative;
}

.search-icon {
    position: absolute;

    left: 13px;
    top: 50%;

    transform: translateY(-50%);

    color: #9ca3af;

    font-size: 20px;

    pointer-events: none;
}

.search-box input,
.filter-bar select {
    width: 100%;

    height: 44px;

    border: 1px solid var(--border);

    border-radius: 9px;

    background: white;

    outline: none;

    font-size: 13px;

    color: var(--text);
}

.search-box input {
    padding: 0 14px 0 40px;
}

.filter-bar select {
    padding: 0 12px;
}

.search-box input:focus,
.filter-bar select:focus {
    border-color: #93c5fd;

    box-shadow:
        0 0 0 3px rgba(37, 99, 235, 0.08);
}


/* =========================================================
   TABLE
========================================================= */

.table-wrapper {
    width: 100%;

    overflow-x: auto;

    border-top: 1px solid var(--border);
}

table {
    width: 100%;

    border-collapse: collapse;

    min-width: 950px;
}

thead {
    background: #f8fafc;
}

th {
    padding: 13px 16px;

    text-align: left;

    font-size: 11px;

    text-transform: uppercase;

    letter-spacing: 0.6px;

    color: #6b7280;

    font-weight: 800;

    border-bottom: 1px solid var(--border);
}

td {
    padding: 15px 16px;

    border-bottom: 1px solid #f0f1f3;

    font-size: 13px;

    vertical-align: middle;
}

tbody tr {
    transition: 0.15s ease;
}

tbody tr:hover {
    background: #fafcff;
}

.ticket-number {
    color: var(--primary);

    font-weight: 800;
}

.customer-name {
    font-weight: 700;
}

.customer-email {
    color: var(--muted);

    font-size: 11px;

    margin-top: 3px;
}

.issue-title {
    font-weight: 650;

    max-width: 230px;
}

.issue-description {
    color: var(--muted);

    font-size: 11px;

    margin-top: 3px;

    max-width: 230px;

    white-space: nowrap;

    overflow: hidden;

    text-overflow: ellipsis;
}


/* =========================================================
   BADGES
========================================================= */

.status-badge,
.priority-badge,
.sla-badge {
    display: inline-flex;

    align-items: center;
    justify-content: center;

    border-radius: 999px;

    padding: 5px 9px;

    font-size: 11px;

    font-weight: 800;

    white-space: nowrap;
}


/* Status */

.status-open {
    background: var(--open-bg);
    color: var(--open-text);
}

.status-progress {
    background: var(--progress-bg);
    color: var(--progress-text);
}

.status-closed {
    background: var(--closed-bg);
    color: var(--closed-text);
}


/* Priority */

.priority-high {
    background: var(--high-bg);
    color: var(--high-text);
}

.priority-medium {
    background: var(--medium-bg);
    color: var(--medium-text);
}

.priority-low {
    background: var(--low-bg);
    color: var(--low-text);
}


/* SLA */

.sla-ok {
    background: var(--open-bg);
    color: var(--open-text);
}

.sla-warning {
    background: var(--progress-bg);
    color: var(--progress-text);
}

.sla-overdue {
    background: var(--high-bg);
    color: var(--high-text);
}


/* =========================================================
   ACTION BUTTON
========================================================= */

.view-btn {
    display: inline-flex;

    align-items: center;
    justify-content: center;

    padding: 7px 11px;

    border-radius: 7px;

    border: 1px solid #dbeafe;

    background: #eff6ff;

    color: var(--primary);

    text-decoration: none;

    font-size: 11px;

    font-weight: 800;

    white-space: nowrap;

    transition: 0.2s ease;
}

.view-btn:hover {
    background: var(--primary);

    color: white;
}


/* =========================================================
   EMPTY STATE
========================================================= */

.empty-state {
    display: none;

    text-align: center;

    padding: 60px 20px;
}

.empty-icon {
    width: 55px;
    height: 55px;

    margin: 0 auto 15px;

    border-radius: 50%;

    background: #eff6ff;

    color: var(--primary);

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 25px;
}

.empty-state h3 {
    font-size: 17px;
}

.empty-state p {
    color: var(--muted);

    font-size: 13px;

    max-width: 400px;

    margin: 7px auto 18px;

    line-height: 1.6;
}


/* =========================================================
   FOOTER
========================================================= */

.footer {
    display: flex;

    align-items: center;
    justify-content: space-between;

    color: #9ca3af;

    font-size: 11px;

    padding: 20px 2px;
}


/* =========================================================
   FORM STYLES
========================================================= */

.form-page {
    max-width: 900px;

    margin: 0 auto;
}

.form-card {
    background: white;

    border: 1px solid var(--border);

    border-radius: 15px;

    padding: 28px;

    box-shadow:
        0 3px 12px rgba(15, 23, 42, 0.04);
}

.form-grid {
    display: grid;

    grid-template-columns:
        1fr 1fr;

    gap: 20px;
}

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

.form-group.full {
    grid-column: 1 / -1;
}

.form-group label {
    display: block;

    font-size: 13px;

    font-weight: 700;

    margin-bottom: 7px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;

    border: 1px solid var(--border);

    border-radius: 9px;

    padding: 12px;

    font-family: inherit;

    font-size: 13px;

    outline: none;

    background: white;
}

.form-group textarea {
    min-height: 140px;

    resize: vertical;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #93c5fd;

    box-shadow:
        0 0 0 3px rgba(37, 99, 235, 0.08);
}

.form-help {
    color: var(--muted);

    font-size: 11px;

    margin-top: 5px;
}

.form-actions {
    display: flex;

    align-items: center;

    justify-content: flex-end;

    gap: 10px;

    padding-top: 8px;
}


/* =========================================================
   SLA INFO
========================================================= */

.sla-info {
    background: #eff6ff;

    border: 1px solid #dbeafe;

    border-radius: 10px;

    padding: 13px;

    margin-bottom: 20px;

    font-size: 12px;

    color: #1e40af;

    line-height: 1.6;
}


/* =========================================================
   DETAIL PAGE
========================================================= */

.detail-grid {
    display: grid;

    grid-template-columns:
        2fr 1fr;

    gap: 20px;
}

.detail-card {
    background: white;

    border: 1px solid var(--border);

    border-radius: 14px;

    padding: 24px;

    box-shadow:
        0 3px 12px rgba(15, 23, 42, 0.04);
}

.detail-card h2 {
    font-size: 18px;

    margin-bottom: 20px;
}

.detail-row {
    padding: 13px 0;

    border-bottom: 1px solid #f1f5f9;
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    color: var(--muted);

    font-size: 11px;

    text-transform: uppercase;

    font-weight: 800;

    letter-spacing: 0.5px;

    margin-bottom: 5px;
}

.detail-value {
    font-size: 14px;

    line-height: 1.6;
}

.notes-list {
    display: flex;

    flex-direction: column;

    gap: 10px;

    margin-bottom: 18px;
}

.note {
    background: #f8fafc;

    border: 1px solid #eef2f7;

    border-radius: 9px;

    padding: 12px;
}

.note-text {
    font-size: 13px;

    line-height: 1.5;
}

.note-date {
    color: var(--muted);

    font-size: 10px;

    margin-top: 6px;
}


/* =========================================================
   LOADING
========================================================= */

.loading-row {
    text-align: center;

    padding: 35px;

    color: var(--muted);
}


/* =========================================================
   RESPONSIVE — TABLET
========================================================= */

@media (max-width: 1100px) {

    .sidebar {
        width: 210px;
    }

    .main-content {
        padding: 28px 24px;
    }

    .stats-grid {
        grid-template-columns:
            repeat(3, minmax(0, 1fr));
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

}


/* =========================================================
   RESPONSIVE — MOBILE
========================================================= */

@media (max-width: 768px) {

    .app {
        display: block;
    }

    .sidebar {
        width: 100%;

        height: auto;
        min-height: auto;

        position: static;

        border-right: none;

        border-bottom: 1px solid var(--border);
    }

    .brand {
        padding: 16px 18px;
    }

    .sidebar-nav {
        display: flex;

        padding: 10px 12px;

        gap: 7px;
    }

    .nav-item {
        margin-bottom: 0;

        flex: 1;

        justify-content: center;

        padding: 10px;
    }

    .sidebar-bottom {
        display: none;
    }

    .main-content {
        padding: 22px 15px;
    }

    .topbar {
        align-items: flex-start;

        flex-direction: column;

        margin-bottom: 22px;
    }

    .topbar h1 {
        font-size: 25px;
    }

    .primary-btn {
        width: 100%;
    }

    .stats-grid {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));

        gap: 10px;
    }

    .stat-card {
        padding: 14px;
    }

    .stat-card strong {
        font-size: 21px;
    }

    .stat-icon {
        width: 36px;
        height: 36px;
    }

    .filter-bar {
        grid-template-columns: 1fr;

        padding: 0 15px 16px;
    }

    .section-header {
        padding: 19px 15px 15px;
    }

    .tickets-section {
        border-radius: 12px;
    }

    .table-wrapper {
        overflow-x: auto;
    }

    table {
        min-width: 900px;
    }

    .footer {
        flex-direction: column;

        align-items: flex-start;

        gap: 5px;
    }

    .form-card {
        padding: 19px;
    }

    .form-grid {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .form-group.full {
        grid-column: auto;
    }

    .form-actions {
        flex-direction: column-reverse;
    }

    .form-actions a,
    .form-actions button {
        width: 100%;
    }

    .detail-card {
        padding: 18px;
    }

}


/* =========================================================
   VERY SMALL MOBILE
========================================================= */

@media (max-width: 420px) {

    .main-content {
        padding: 18px 11px;
    }

    .brand h2 {
        font-size: 16px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-card {
        padding: 13px 15px;
    }

    .topbar h1 {
        font-size: 23px;
    }

    .subtitle {
        font-size: 12px;
    }

   }
