/* HCDS Customer Success Command Center - Enhanced Styles with Theme System */

/* ================================
   CSS Custom Properties (Theme Tokens)
   ================================ */
:root {
    /* Dark Theme (Default) */
    --bg-main: #0F172A;
    --bg-surface: #111827;
    --bg-card: rgba(23, 32, 51, 0.8);
    --bg-card-solid: #172033;
    --bg-card-hover: rgba(30, 40, 60, 0.9);
    --border: #26344D;
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);

    --text-primary: #F8FAFC;
    --text-secondary: #94A3B8;
    --text-tertiary: #64748B;
    --text-muted: #475569;

    --primary: #3B82F6;
    --primary-hover: #2563EB;
    --primary-soft: rgba(59, 130, 246, 0.15);
    --primary-soft-hover: rgba(59, 130, 246, 0.25);

    --secondary: #06B6D4;
    --secondary-soft: rgba(6, 182, 212, 0.15);

    --success: #10B981;
    --success-soft: rgba(16, 185, 129, 0.15);

    --warning: #F59E0B;
    --warning-soft: rgba(245, 158, 11, 0.15);

    --danger: #EF4444;
    --danger-soft: rgba(239, 68, 68, 0.15);

    --info: #6366F1;
    --info-soft: rgba(99, 102, 241, 0.15);

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5);

    /* Glass Effect */
    --glass-bg: rgba(23, 32, 51, 0.8);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-blur: blur(20px);

    /* Annie Platform Color */
    --annie-primary: #6366F1;
    --annie-soft: rgba(99, 102, 241, 0.15);

    /* iSmartOffice Platform Color */
    --ismart-primary: #06B6D4;
    --ismart-soft: rgba(6, 182, 212, 0.15);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 200ms ease;
    --transition-slow: 300ms ease;
}

/* Light Theme */
[data-theme="light"] {
    --bg-main: #F8FAFC;
    --bg-surface: #FFFFFF;
    --bg-card: #FFFFFF;
    --bg-card-hover: #F1F5F9;
    --border: #E2E8F0;
    --border-subtle: rgba(0, 0, 0, 0.08);
    --border-hover: rgba(0, 0, 0, 0.15);

    --text-primary: #0F172A;
    --text-secondary: #64748B;
    --text-tertiary: #94A3B8;
    --text-muted: #CBD5E1;

    --primary: #2563EB;
    --primary-hover: #1D4ED8;
    --primary-soft: rgba(37, 99, 235, 0.10);
    --primary-soft-hover: rgba(37, 99, 235, 0.15);

    --secondary: #0891B2;
    --secondary-soft: rgba(8, 145, 178, 0.10);

    --success: #059669;
    --success-soft: rgba(5, 150, 105, 0.10);

    --warning: #D97706;
    --warning-soft: rgba(217, 119, 6, 0.10);

    --danger: #DC2626;
    --danger-soft: rgba(220, 38, 38, 0.10);

    --info: #4F46E5;
    --info-soft: rgba(79, 70, 229, 0.10);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.15);

    --glass-bg: rgba(255, 255, 255, 0.9);
    --glass-border: rgba(0, 0, 0, 0.08);
}

/* ================================
   Base Styles
   ================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* Background gradient */
.bg-gradient {
    background: linear-gradient(135deg, var(--bg-main) 0%, var(--bg-surface) 50%, var(--bg-main) 100%);
}

[data-theme="light"] .bg-gradient {
    background: linear-gradient(135deg, var(--bg-surface) 0%, var(--bg-main) 50%, var(--bg-surface) 100%);
}

/* ================================
   Theme Transition
   ================================ */
body, body * {
    transition:
        background-color var(--transition-normal),
        border-color var(--transition-normal),
        color var(--transition-fast),
        box-shadow var(--transition-normal);
}

/* Exclude animations from transition */
body,
.glass-card,
.glass-card:hover,
.animate-fade-in,
.kpi-card,
.status-badge,
.section-header {
    transition: none;
}

/* ================================
   Custom Scrollbar
   ================================ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-surface);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ================================
   Glass Card Component
   ================================ */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    transition: all var(--transition-slow);
}

.glass-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
    box-shadow: var(--shadow-xl);
}

[data-theme="light"] .glass-card {
    box-shadow: var(--shadow-sm);
    border-color: var(--border);
}

[data-theme="light"] .glass-card:hover {
    box-shadow: var(--shadow-lg);
    border-color: var(--border-hover);
}

/* ================================
   KPI Card Component
   ================================ */
.kpi-card {
    position: relative;
    padding: 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    cursor: pointer;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.kpi-card:hover::before {
    opacity: 1;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-soft);
}

.kpi-card .kpi-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition-fast);
}

.kpi-card:hover .kpi-icon {
    transform: scale(1.1);
}

.kpi-card .kpi-value {
    font-size: 1.875rem;
    font-weight: 700;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.kpi-card .kpi-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ================================
   Platform Cards
   ================================ */
.platform-card {
    padding: 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
}

.platform-card.annie {
    border-top: 3px solid var(--annie-primary);
}

.platform-card.ismart {
    border-top: 3px solid var(--ismart-primary);
}

.platform-card .platform-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.platform-card .platform-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.platform-card.annie .platform-icon {
    background: var(--annie-soft);
    color: var(--annie-primary);
}

.platform-card.ismart .platform-icon {
    background: var(--ismart-soft);
    color: var(--ismart-primary);
}

/* ================================
   Badge Styles
   ================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 600;
    gap: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.badge-success {
    background: var(--success-soft);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-soft);
    color: var(--warning);
}

.badge-danger {
    background: var(--danger-soft);
    color: var(--danger);
}

.badge-primary {
    background: var(--primary-soft);
    color: var(--primary);
}

.badge-secondary {
    background: var(--secondary-soft);
    color: var(--secondary);
}

.badge-annie {
    background: var(--annie-soft);
    color: var(--annie-primary);
}

.badge-ismart {
    background: var(--ismart-soft);
    color: var(--ismart-primary);
}

/* ================================
   Status Indicator
   ================================ */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.status-dot.online {
    background: var(--success);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

.status-dot.warning {
    background: var(--warning);
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
}

.status-dot.offline {
    background: var(--danger);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
}

.status-dot.loading {
    background: var(--primary);
    animation: pulse 1.5s ease-in-out infinite;
}

/* ================================
   Live Data Badge States
   ================================ */
.live-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.live-badge.live {
    background: var(--success-soft);
    color: var(--success);
}

.live-badge.partial {
    background: var(--warning-soft);
    color: var(--warning);
}

.live-badge.error {
    background: var(--danger-soft);
    color: var(--danger);
}

.live-badge.empty {
    background: var(--border-subtle);
    color: var(--text-secondary);
}

.live-badge.loading {
    background: var(--primary-soft);
    color: var(--primary);
}

/* ================================
   Animations
   ================================ */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes countUp {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

.animate-fade-in {
    animation: fadeIn 0.6s ease-out forwards;
}

.animate-slide-up {
    animation: slideUp 0.6s ease-out forwards;
}

.animate-pulse-slow {
    animation: pulse 3s ease-in-out infinite;
}

/* Staggered animation delays */
section:nth-child(1) { animation-delay: 0s; }
section:nth-child(2) { animation-delay: 0.05s; }
section:nth-child(3) { animation-delay: 0.1s; }
section:nth-child(4) { animation-delay: 0.15s; }
section:nth-child(5) { animation-delay: 0.2s; }
section:nth-child(6) { animation-delay: 0.25s; }
section:nth-child(7) { animation-delay: 0.3s; }
section:nth-child(8) { animation-delay: 0.35s; }
section:nth-child(9) { animation-delay: 0.4s; }

/* ================================
   Header Styles
   ================================ */
.header-command-center {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.header-command-center .logo {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-command-center .title {
    font-size: 1.125rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-command-center .subtitle {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

/* ================================
   Search Box
   ================================ */
.search-box {
    position: relative;
}

.search-box input {
    width: 100%;
    max-width: 320px;
    padding: 0.5rem 1rem 0.5rem 2.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: all var(--transition-fast);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.search-box .search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

/* ================================
   Filter Controls
   ================================ */
.filter-select {
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 1rem;
    transition: all var(--transition-fast);
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

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

/* ================================
   Theme Toggle
   ================================ */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
}

.theme-toggle button {
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.theme-toggle button:hover {
    color: var(--text-primary);
}

.theme-toggle button.active {
    background: var(--primary-soft);
    color: var(--primary);
}

/* ================================
   Section Header
   ================================ */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.section-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.section-header p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ================================
   Empty State
   ================================ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
}

.empty-state .empty-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--border-subtle);
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.empty-state h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.empty-state p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ================================
   Error State
   ================================ */
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
    background: var(--danger-soft);
    border-radius: 8px;
}

.error-state .error-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--danger);
    color: white;
    margin-bottom: 1rem;
}

/* ================================
   Health Score Gauge
   ================================ */
.health-gauge {
    position: relative;
    width: 160px;
    height: 160px;
}

.health-gauge svg {
    transform: rotate(-90deg);
}

.health-gauge .gauge-bg {
    fill: none;
    stroke: var(--border);
    stroke-width: 8;
}

.health-gauge .gauge-fill {
    fill: none;
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s ease-out;
}

.health-gauge .gauge-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.health-gauge .gauge-number {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
}

.health-gauge .gauge-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ================================
   Actions Card
   ================================ */
.action-card {
    padding: 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    transition: all var(--transition-fast);
}

.action-card:hover {
    border-color: var(--primary-soft);
    box-shadow: var(--shadow-md);
}

.action-card .priority-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-size: 0.625rem;
    font-weight: 700;
}

.action-card .priority-badge.p1 {
    background: var(--danger-soft);
    color: var(--danger);
}

.action-card .priority-badge.p2 {
    background: var(--warning-soft);
    color: var(--warning);
}

.action-card .priority-badge.p3 {
    background: var(--primary-soft);
    color: var(--primary);
}

/* ================================
   Escalation Table
   ================================ */
.escalation-table {
    width: 100%;
    border-collapse: collapse;
}

.escalation-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
}

.escalation-table td {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-subtle);
    transition: background var(--transition-fast);
}

.escalation-table tr:hover td {
    background: var(--primary-soft);
}

/* ================================
   ApexCharts Customization
   ================================ */
.apexcharts-tooltip {
    background: var(--bg-card) !important;
    border: 1px solid var(--border) !important;
    border-radius: 8px !important;
    box-shadow: var(--shadow-xl) !important;
}

.apexcharts-tooltip-title {
    background: var(--bg-surface) !important;
    border-bottom: 1px solid var(--border-subtle) !important;
    color: var(--text-primary) !important;
    padding: 0.5rem 0.75rem !important;
}

.apexcharts-tooltip-text {
    color: var(--text-primary) !important;
}

.apexcharts-xaxistooltip {
    background: var(--bg-card) !important;
    border: 1px solid var(--border) !important;
    border-radius: 6px !important;
    color: var(--text-primary) !important;
}

.apexcharts-menu {
    background: var(--bg-card) !important;
    border: 1px solid var(--border) !important;
    border-radius: 8px !important;
}

.apexcharts-menu-item:hover {
    background: var(--primary-soft) !important;
}

/* Light theme chart styling */
[data-theme="light"] .apexcharts-gridline {
    stroke: var(--border);
}

[data-theme="light"] .apexcharts-text {
    fill: var(--text-secondary);
}

/* ================================
   Skeleton Loading
   ================================ */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-card) 0%,
        var(--border-subtle) 50%,
        var(--bg-card) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 4px;
}

.skeleton-text {
    height: 0.875rem;
    margin-bottom: 0.5rem;
}

.skeleton-title {
    height: 1.5rem;
    width: 60%;
    margin-bottom: 0.5rem;
}

.skeleton-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
}

/* ================================
   Responsive Breakpoints
   ================================ */
@media (max-width: 1536px) {
    .header-command-center .search-box input {
        max-width: 280px;
    }
}

@media (max-width: 1280px) {
    .header-command-center .subtitle {
        display: none;
    }

    .header-command-center .search-box input {
        max-width: 200px;
    }
}

@media (max-width: 1024px) {
    .kpi-card {
        padding: 1rem;
    }

    .kpi-card .kpi-value {
        font-size: 1.5rem;
    }
}

@media (max-width: 768px) {
    .header-command-center {
        padding: 0.75rem 1rem;
    }

    .header-command-center .search-box {
        display: none;
    }

    .kpi-card {
        border-radius: 10px;
    }
}

@media (max-width: 640px) {
    .kpi-card {
        padding: 0.875rem;
    }

    .kpi-card .kpi-icon {
        width: 36px;
        height: 36px;
    }

    .kpi-card .kpi-value {
        font-size: 1.25rem;
    }
}

/* ================================
   Print Styles
   ================================ */
@media print {
    body {
        background: white !important;
        color: black !important;
    }

    .glass-card, .kpi-card, .platform-card {
        background: white !important;
        border: 1px solid #e5e7eb !important;
        box-shadow: none !important;
        break-inside: avoid;
    }

    .fixed {
        position: relative !important;
    }

    header, .header-command-center, footer {
        display: none !important;
    }
}
