/* ApexDesk ITSM - Modern SaaS Design System */

:root {
    --primary: #2563EB;
    --primary-hover: #1D4ED8;
    --primary-light: #EFF6FF;
    --dark: #0F172A;
    --dark-surface: #1E293B;
    --sidebar-bg: #0F172A;
    --body-bg: #F8FAFC;
    --card-bg: #FFFFFF;
    --text-main: #0F172A;
    --text-muted: #64748B;
    --border-color: #E2E8F0;
    --success: #16A34A;
    --warning: #F59E0B;
    --danger: #DC2626;
    --info: #06B6D4;
    --purple: #8B5CF6;
}

[data-bs-theme="dark"] {
    --body-bg: #0B0F19;
    --card-bg: #131B2E;
    --dark-surface: #1A243B;
    --sidebar-bg: #090D16;
    --text-main: #F1F5F9;
    --text-muted: #94A3B8;
    --border-color: #222F49;
    --primary-light: rgba(37, 99, 235, 0.15);
}

body {
    background-color: var(--body-bg);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* App Wrapper */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.app-sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    color: #94A3B8;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    z-index: 1030;
}

.sidebar-header {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-menu {
    padding: 16px 12px;
    flex-grow: 1;
    overflow-y: auto;
}

.sidebar-heading {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748B;
    padding: 12px 14px 6px;
    font-weight: 700;
}

.nav-link-item {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    color: #94A3B8;
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 2px;
    transition: all 0.2s;
}

.nav-link-item i {
    width: 20px;
    margin-right: 12px;
    font-size: 16px;
}

.nav-link-item:hover {
    color: #FFFFFF;
    background: rgba(255, 255, 255, 0.06);
}

.nav-link-item.active {
    color: #FFFFFF;
    background: var(--primary);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

/* Main Content */
.app-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Navbar */
.app-navbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.global-search-input {
    background: var(--body-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 8px 16px 8px 38px;
    font-size: 14px;
    width: 320px;
    color: var(--text-main);
    transition: all 0.2s;
}

.global-search-input:focus {
    width: 420px;
    background: var(--card-bg);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
    outline: none;
}

.search-icon-pos {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

/* Cards */
.card-saas {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card-saas:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.06), 0 4px 6px -2px rgba(0, 0, 0, 0.03);
}

/* KPI Card */
.kpi-card {
    padding: 20px 24px;
    border-radius: 14px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.kpi-icon-box {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.kpi-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.kpi-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}

.kpi-trend {
    font-size: 12px;
    font-weight: 600;
}

/* Threaded Conversation Timeline */
.timeline-stream {
    position: relative;
    padding-left: 20px;
}

.timeline-stream::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 15px;
    bottom: 15px;
    width: 2px;
    background: var(--border-color);
}

.message-item {
    position: relative;
    margin-bottom: 24px;
}

.message-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 18px 22px;
}

/* CRITICAL: Internal Note Styling */
.internal-note-card {
    background: #FEF3C7 !important;
    border: 2px dashed #F59E0B !important;
    color: #78350F !important;
}

[data-bs-theme="dark"] .internal-note-card {
    background: #2D2415 !important;
    border: 2px dashed #F59E0B !important;
    color: #FDE68A !important;
}

.internal-note-badge {
    background: #D97706;
    color: #FFFFFF;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* SLA Pulsing Animation */
@keyframes pulse-danger {
    0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.7); }
    70% { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

.animate-pulse {
    animation: pulse-danger 2s infinite;
}

/* Stopwatch Floating Widget */
.stopwatch-widget {
    background: #0F172A;
    color: #FFFFFF;
    border-radius: 10px;
    padding: 12px 18px;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.stopwatch-display {
    font-family: 'Courier New', Courier, monospace;
    font-size: 20px;
    font-weight: 700;
    color: #38BDF8;
}

/* Responsive Table */
@media (max-width: 768px) {
    .app-sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        bottom: 0;
    }
    .app-sidebar.show {
        left: 0;
    }
    .global-search-input, .global-search-input:focus {
        width: 180px;
    }
}