/* =====================================================================
   CoreDesk Design System
   Modern High-End SaaS UI (Core PHP, MySQL, Vanilla JS)
   Clean Dot-Grid Background & Vibrant Royal Blue Palette
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
    /* Brand Colors (Exact Match to User Reference) */
    --primary: #4457ff;
    --primary-hover: #3244e8;
    --primary-subtle: #eef2ff;
    --primary-dark: #2d3bbd;
    --accent: #6366f1;

    /* Backgrounds & Dot Grid (Subtle low-opacity texture) */
    --bg-page: #ffffff;
    --dot-color: rgba(148, 163, 184, 0.32);
    --bg-surface: #ffffff;
    --bg-surface-subtle: #f8fafc;
    --border-subtle: #e2e8f0;
    --border-card: #e5eaf2;

    /* Text Hierarchy */
    --text-heading: #0f172a;
    --text-body: #334155;
    --text-muted: #64748b;
    --text-subtlest: #94a3b8;

    /* Status Pills */
    --status-open-bg: #eef2ff;
    --status-open-text: #4338ca;
    --status-open-border: #c7d2fe;

    --status-progress-bg: #fef3c7;
    --status-progress-text: #b45309;
    --status-progress-border: #fde68a;

    --status-resolved-bg: #ecfdf5;
    --status-resolved-text: #047857;
    --status-resolved-border: #a7f3d0;

    --status-closed-bg: #f1f5f9;
    --status-closed-text: #475569;
    --status-closed-border: #cbd5e1;

    /* Priorities */
    --priority-critical-bg: #fef2f2;
    --priority-critical-text: #dc2626;
    --priority-critical-border: #fecaca;

    --priority-high-bg: #fff7ed;
    --priority-high-text: #ea580c;
    --priority-high-border: #ffedd5;

    --priority-medium-bg: #f0fdf4;
    --priority-medium-text: #16a34a;
    --priority-medium-border: #dcfce7;

    --priority-low-bg: #f8fafc;
    --priority-low-text: #64748b;
    --priority-low-border: #e2e8f0;

    /* Elevations */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-card: 0 2px 12px -2px rgba(68, 87, 255, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-elevated: 0 12px 32px -4px rgba(68, 87, 255, 0.08), 0 4px 12px -2px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 8px 24px -2px rgba(68, 87, 255, 0.12);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-pill: 9999px;
}

/* =====================================================================
   Base Reset with Exact Dot Pattern Background
   ===================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #ffffff;
    background-image: radial-gradient(circle, var(--dot-color) 1.5px, transparent 1.5px);
    background-size: 30px 30px;
    background-attachment: fixed;
    color: var(--text-body);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s ease;
}

a:hover {
    color: var(--primary-hover);
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text-heading);
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.25;
}

/* Container */
.container {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 0 24px;
}

/* =====================================================================
   Top Navigation Bar (Clean & Elevated)
   ===================================================================== */
.site-navbar {
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-card);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 72px;
}

.brand-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 22px;
    font-weight: 800;
    color: var(--text-heading);
    text-decoration: none;
    letter-spacing: -0.03em;
}

.brand-wrap:hover {
    text-decoration: none;
}

.brand-highlight {
    color: var(--primary);
}

.nav-links-menu {
    display: flex;
    align-items: center;
    gap: 28px;
}

.nav-item-link {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    transition: color 0.15s ease;
}

.nav-item-link:hover, .nav-item-link.active {
    color: var(--text-heading);
    text-decoration: none;
}

.nav-right-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

/* Hero Pill Badge */
.hero-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--primary-subtle);
    color: var(--primary);
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 18px;
    border: 1px solid #dbeafe;
}

.hero-pill-dot {
    width: 7px;
    height: 7px;
    background-color: var(--primary);
    border-radius: 50%;
}

/* =====================================================================
   Buttons (Vibrant Royal Blue)
   ===================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    text-decoration: none;
    line-height: 1.25;
}

.btn:hover {
    text-decoration: none;
}

.btn-primary {
    background-color: var(--primary);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(68, 87, 255, 0.25);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(68, 87, 255, 0.35);
}

.btn-secondary {
    background-color: #ffffff;
    color: var(--text-heading);
    border-color: var(--border-subtle);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    background-color: #f8fafc;
    border-color: #cbd5e1;
    transform: translateY(-1px);
}

.btn-subtle {
    background-color: transparent;
    color: var(--text-muted);
}

.btn-subtle:hover {
    background-color: rgba(68, 87, 255, 0.06);
    color: var(--primary);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
    border-radius: var(--radius-sm);
}

/* Form Controls */
.form-control {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-heading);
    background-color: #ffffff;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.form-control:focus {
    background-color: #ffffff;
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(68, 87, 255, 0.15);
}

.form-control-sm {
    padding: 6px 10px;
    font-size: 13px;
}

/* =====================================================================
   Cards & Surfaces
   ===================================================================== */
.card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.card:hover {
    border-color: #cbd5e1;
}

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

.card-body {
    padding: 24px;
}

/* =====================================================================
   Metrics Cards (Clean Modern Grid)
   ===================================================================== */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.metric-card {
    background: #ffffff;
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.2s ease;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.metric-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.metric-value {
    font-size: 34px;
    font-weight: 800;
    color: var(--text-heading);
    letter-spacing: -0.03em;
    margin: 8px 0 4px;
    line-height: 1.1;
}

.metric-sub {
    font-size: 12.5px;
    color: var(--text-muted);
}

/* =====================================================================
   Table Styling
   ===================================================================== */
.table-container {
    background: #ffffff;
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

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

.table-responsive {
    overflow-x: auto;
    width: 100%;
}

.table-custom {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
    text-align: left;
}

.table-custom thead {
    background-color: #f8fafc;
    border-bottom: 1px solid var(--border-subtle);
}

.table-custom th {
    padding: 12px 20px;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    white-space: nowrap;
}

.table-custom td {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
}

.table-custom tr:hover td {
    background-color: #f8faff;
}

.ticket-key {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    font-size: 13px;
    color: var(--primary);
}

.ticket-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-heading);
}

.ticket-title:hover {
    color: var(--primary);
}

/* Status Pills */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.status-open {
    background: var(--status-open-bg);
    color: var(--status-open-text);
    border: 1px solid var(--status-open-border);
}

.status-inprogress {
    background: var(--status-progress-bg);
    color: var(--status-progress-text);
    border: 1px solid var(--status-progress-border);
}

.status-resolved {
    background: var(--status-resolved-bg);
    color: var(--status-resolved-text);
    border: 1px solid var(--status-resolved-border);
}

.status-closed {
    background: var(--status-closed-bg);
    color: var(--status-closed-text);
    border: 1px solid var(--status-closed-border);
}

/* Priority Pills */
.priority-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 11.5px;
    font-weight: 600;
}

.priority-critical {
    background: var(--priority-critical-bg);
    color: var(--priority-critical-text);
    border: 1px solid var(--priority-critical-border);
}

.priority-high {
    background: var(--priority-high-bg);
    color: var(--priority-high-text);
    border: 1px solid var(--priority-high-border);
}

.priority-medium {
    background: var(--priority-medium-bg);
    color: var(--priority-medium-text);
    border: 1px solid var(--priority-medium-border);
}

.priority-low {
    background: var(--priority-low-bg);
    color: var(--priority-low-text);
    border: 1px solid var(--priority-low-border);
}

.category-tag {
    background: #f1f5f9;
    color: #475569;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 11.5px;
    font-weight: 500;
}

/* =====================================================================
   Conversation Thread & Dual-Pane Workspace
   ===================================================================== */
.workspace-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 24px;
    align-items: start;
}

.thread-stream {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.reply-card {
    background: #ffffff;
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

.reply-card.internal-note {
    background: #fffdf5;
    border-color: #fde68a;
}

.reply-header {
    padding: 12px 18px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.reply-card.internal-note .reply-header {
    background: #fef3c7;
    border-bottom-color: #fde68a;
}

.reply-body {
    padding: 18px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-heading);
    white-space: pre-wrap;
}

/* User Avatar Initial */
.avatar-initial {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Toasts */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast-alert {
    min-width: 300px;
    padding: 12px 18px;
    background: #0f172a;
    color: #ffffff;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-elevated);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13.5px;
    font-weight: 500;
    animation: fadeIn 0.2s ease;
}

.toast-alert.toast-success {
    border-left: 4px solid #10b981;
}

.toast-alert.toast-error {
    border-left: 4px solid #ef4444;
}

/* Footer */
.site-footer {
    margin-top: auto;
    background: #ffffff;
    border-top: 1px solid var(--border-card);
    padding: 24px 0;
    font-size: 13px;
    color: var(--text-muted);
}

.footer-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

@media (max-width: 900px) {
    .workspace-grid {
        grid-template-columns: 1fr;
    }
    .navbar-inner {
        flex-direction: column;
        height: auto;
        padding: 16px 0;
        gap: 14px;
    }
}
