/* ==========================================================================
   Mortacc Premium Design System — SaaS-grade visual polish
   ========================================================================== */

/* ── Refined Typography Scale ─────────────────────────────────────────── */
:root {
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-display: 'DM Serif Display', Georgia, serif;
    --text-xs: 0.75rem;    /* 12px */
    --text-sm: 0.8125rem;  /* 13px */
    --text-base: 0.875rem; /* 14px */
    --text-lg: 1rem;       /* 16px */
    --text-xl: 1.125rem;   /* 18px */
    --text-2xl: 1.5rem;    /* 24px */
    --text-3xl: 1.875rem;  /* 30px */

    /* Elevated brand colors */
    --brand-100: #fdf2f4;
    --brand-200: #f5d5db;
    --brand-300: #e8b4be;
    --brand-400: #d48f9c;
    --brand-500: #b76e79;
    --brand-600: #a05864;
    --brand-700: #8b4a55;

    /* Refined neutrals */
    --gray-50:  #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    /* Elevation / shadows — deeper for premium feel */
    --elevation-1: 0 1px 2px rgba(15,23,42,.04);
    --elevation-2: 0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.03);
    --elevation-3: 0 4px 6px rgba(15,23,42,.05), 0 2px 4px rgba(15,23,42,.03);
    --elevation-4: 0 10px 15px rgba(15,23,42,.06), 0 4px 6px rgba(15,23,42,.03);
    --elevation-5: 0 20px 40px rgba(15,23,42,.08), 0 8px 12px rgba(15,23,42,.04);

    /* Animation */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
    --duration-fast: 120ms;
    --duration-normal: 200ms;
    --duration-slow: 350ms;
}

/* ── Smooth scrolling, better font rendering ─────────────────────────── */
html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* ── Animated entrance for page content ──────────────────────────────── */
@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.content > * {
    animation: fadeSlideIn var(--duration-slow) var(--ease-out) both;
}
.content > *:nth-child(1) { animation-delay: 0ms; }
.content > *:nth-child(2) { animation-delay: 40ms; }
.content > *:nth-child(3) { animation-delay: 80ms; }
.content > *:nth-child(4) { animation-delay: 120ms; }
.content > *:nth-child(5) { animation-delay: 160ms; }

/* ── Premium Cards ───────────────────────────────────────────────────── */
.premium-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--elevation-1);
    transition: all var(--duration-normal) var(--ease-out);
    overflow: hidden;
}
.premium-card:hover {
    box-shadow: var(--elevation-3);
    border-color: var(--gray-300);
}
.premium-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-soft);
    display: flex; align-items: center; justify-content: space-between;
}
.premium-card-title {
    font-size: var(--text-sm); font-weight: 600; color: var(--ink);
    letter-spacing: -.01em;
}
.premium-card-body { padding: 18px 20px; }

/* ── Premium Stat Cards ──────────────────────────────────────────────── */
.premium-stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px 22px;
    box-shadow: var(--elevation-1);
    transition: all var(--duration-normal) var(--ease-out);
    position: relative;
    overflow: hidden;
}
.premium-stat:hover {
    transform: translateY(-2px);
    box-shadow: var(--elevation-4);
    border-color: var(--gray-300);
}
.premium-stat .ps-icon {
    width: 40px; height: 40px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; margin-bottom: 12px;
}
.premium-stat .ps-value {
    font-size: 28px; font-weight: 700; color: var(--ink);
    letter-spacing: -.02em; line-height: 1.1;
}
.premium-stat .ps-label {
    font-size: 11px; font-weight: 500; color: var(--ink-3);
    text-transform: uppercase; letter-spacing: .5px; margin-top: 4px;
}
.premium-stat .ps-sub {
    font-size: 11px; color: var(--ink-4); margin-top: 2px;
}
.premium-stat::after {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
}
.premium-stat.accent-red::after    { background: var(--red); }
.premium-stat.accent-amber::after  { background: var(--amber); }
.premium-stat.accent-green::after  { background: var(--green); }
.premium-stat.accent-purple::after { background: var(--purple); }
.premium-stat.accent-brand::after  { background: var(--brand); }
.premium-stat.accent-teal::after   { background: var(--teal); }

/* ── Glass Header (for entity pages) ─────────────────────────────────── */
.glass-header {
    background: linear-gradient(135deg, var(--surface) 0%, var(--brand-100) 100%);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 22px 26px;
    display: flex; align-items: center; gap: 18px;
    margin-bottom: 20px;
    box-shadow: var(--elevation-2);
}
.glass-avatar {
    width: 52px; height: 52px; border-radius: 12px;
    background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: 22px; font-weight: 700; flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(183,110,121,.35);
}

/* ── Status Pills (refined) ──────────────────────────────────────────── */
.status-pill {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px; border-radius: 999px;
    font-size: 11.5px; font-weight: 500; letter-spacing: .01em;
}
.status-pill::before {
    content: ''; width: 6px; height: 6px; border-radius: 50%;
    background: currentColor; flex-shrink: 0;
}
.status-pill.green  { background: #dcfce7; color: #15803d; }
.status-pill.amber  { background: #fef3c7; color: #92400e; }
.status-pill.red    { background: #fee2e2; color: #991b1b; }
.status-pill.purple { background: #ede9fe; color: #6d28d9; }
.status-pill.blue   { background: #dbeafe; color: #1d4ed8; }
.status-pill.gray   { background: var(--surface-2); color: var(--ink-3); }

/* ── Premium Table ───────────────────────────────────────────────────── */
.premium-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.premium-table thead th {
    text-align: left; font-size: 10.5px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .7px;
    color: var(--ink-3); padding: 12px 14px;
    border-bottom: 2px solid var(--border);
    background: var(--surface-2);
}
.premium-table tbody td {
    padding: 13px 14px; border-bottom: 1px solid var(--border-soft);
    color: var(--ink-2); vertical-align: middle;
}
.premium-table tbody tr { transition: background var(--duration-fast); }
.premium-table tbody tr:hover { background: var(--brand-100); }

/* ── Empty States (beautiful illustrations) ──────────────────────────── */
.empty-state-premium {
    text-align: center; padding: 64px 24px;
}
.empty-state-premium .esp-illustration {
    width: 120px; height: 120px; margin: 0 auto 20px;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 48px;
    background: linear-gradient(135deg, var(--brand-100), var(--brand-200));
}
.empty-state-premium h3 {
    font-size: var(--text-lg); font-weight: 600; color: var(--ink);
    margin-bottom: 6px;
}
.empty-state-premium p {
    font-size: var(--text-sm); color: var(--ink-3);
    max-width: 360px; margin: 0 auto 16px; line-height: 1.6;
}

/* ── Skeleton Loaders ────────────────────────────────────────────────── */
@keyframes shimmer {
    0%   { background-position: -200px 0; }
    100% { background-position: calc(200px + 100%) 0; }
}
.skeleton {
    background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%);
    background-size: 200px 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius);
}
.skeleton-text  { height: 14px; width: 100%; margin-bottom: 8px; }
.skeleton-title { height: 20px; width: 60%; margin-bottom: 12px; }
.skeleton-card  { height: 120px; width: 100%; margin-bottom: 16px; border-radius: 14px; }
.skeleton-stat  { height: 90px; width: 100%; margin-bottom: 14px; border-radius: 14px; }
.skeleton-avatar { width: 40px; height: 40px; border-radius: 50%; }
.skeleton-row {
    display: flex; align-items: center; gap: 12px; padding: 12px 0;
    border-bottom: 1px solid var(--border-soft);
}
.skeleton-row .skeleton-text { flex: 1; margin-bottom: 0; }

/* ── Loading Spinner ─────────────────────────────────────────────────── */
@keyframes spin {
    to { transform: rotate(360deg); }
}
.spinner {
    width: 24px; height: 24px; border: 2.5px solid var(--border);
    border-top-color: var(--brand); border-radius: 50%;
    animation: spin .6s linear infinite;
}
.spinner-lg { width: 40px; height: 40px; border-width: 3px; }
.loading-overlay {
    display: flex; align-items: center; justify-content: center;
    padding: 48px; gap: 12px; color: var(--ink-3); font-size: var(--text-sm);
}

/* ── Tooltips ────────────────────────────────────────────────────────── */
[data-tooltip] {
    position: relative;
    cursor: help;
}
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute; bottom: calc(100% + 8px); left: 50%;
    transform: translateX(-50%);
    background: var(--gray-900); color: #fff;
    padding: 5px 10px; border-radius: 6px;
    font-size: 11px; font-weight: 500; white-space: nowrap;
    pointer-events: none; opacity: 0;
    transition: opacity var(--duration-fast) var(--ease-out);
    z-index: 500;
}
[data-tooltip]:hover::after {
    opacity: 1;
}

/* ── Onboarding Walkthrough / Tour ───────────────────────────────────── */
.tour-highlight {
    position: relative;
    z-index: 501;
    box-shadow: 0 0 0 4px rgba(183,110,121,.35), 0 0 0 9999px rgba(15,23,42,.5);
    border-radius: 8px;
}
.tour-tooltip {
    position: fixed; z-index: 502;
    background: var(--surface); border-radius: 12px;
    padding: 20px 22px; max-width: 340px;
    box-shadow: var(--elevation-5); border: 1px solid var(--border);
    font-size: var(--text-sm); line-height: 1.6;
}
.tour-tooltip h4 { font-size: var(--text-base); font-weight: 600; margin-bottom: 6px; }
.tour-tooltip p  { color: var(--ink-2); margin-bottom: 14px; }
.tour-tooltip .tour-actions { display: flex; gap: 8px; justify-content: flex-end; }
.tour-dots { display: flex; gap: 6px; justify-content: center; margin-top: 10px; }
.tour-dot {
    width: 8px; height: 8px; border-radius: 50%; background: var(--border);
    transition: all var(--duration-fast);
}
.tour-dot.active { background: var(--brand); width: 24px; border-radius: 4px; }
.tour-tooltip .tour-close {
    position: absolute; top: 8px; right: 10px;
    background: none; border: none; color: var(--ink-3); font-size: 20px;
    line-height: 1; cursor: pointer; padding: 0 4px; border-radius: 4px;
    transition: color var(--duration-fast);
}
.tour-tooltip .tour-close:hover { color: var(--ink); }

/* ── Hover Cards (lift effect) ───────────────────────────────────────── */
.hover-lift {
    transition: all var(--duration-normal) var(--ease-out);
}
.hover-lift:hover {
    transform: translateY(-2px);
    box-shadow: var(--elevation-4);
}

/* ── Gradient Page Headers ───────────────────────────────────────────── */
.page-hero {
    background: linear-gradient(135deg, var(--gray-900), var(--gray-800));
    border-radius: 16px; padding: 28px 32px; margin-bottom: 24px;
    color: #fff;
}
.page-hero h1 { font-size: var(--text-2xl); font-weight: 700; margin: 0; }
.page-hero p  { font-size: var(--text-sm); opacity: .8; margin-top: 4px; }
.page-hero .hero-actions { display: flex; gap: 8px; margin-top: 14px; }

/* ── Metric Row ──────────────────────────────────────────────────────── */
.metric-row {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 0; border-bottom: 1px solid var(--border-soft);
    font-size: var(--text-sm);
}
.metric-row:last-child { border-bottom: none; }
.metric-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.metric-label { flex: 1; color: var(--ink); }
.metric-value { font-weight: 600; color: var(--ink); }

/* ── Interactive stat card ───────────────────────────────────────────── */
.stat-link {
    text-decoration: none; color: inherit; display: block;
    transition: all var(--duration-normal) var(--ease-out);
    border-radius: 14px; border: 1px solid var(--border);
    background: var(--surface); padding: 20px 22px;
}
.stat-link:hover {
    border-color: var(--brand-400);
    box-shadow: var(--elevation-3);
    transform: translateY(-1px);
}
.stat-link .stat-link-arrow {
    position: absolute; top: 14px; right: 16px;
    font-size: 14px; color: var(--ink-4); opacity: 0;
    transition: all var(--duration-fast);
}
.stat-link:hover .stat-link-arrow { opacity: 1; }

/* ── Progress bar (refined) ──────────────────────────────────────────── */
.progress-bar {
    height: 6px; border-radius: 999px; background: var(--surface-2);
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%; border-radius: 999px;
    transition: width var(--duration-slow) var(--ease-out);
}

/* ── Keyboard shortcut badge ─────────────────────────────────────────── */
.kbd {
    display: inline-block; padding: 2px 6px;
    border-radius: 4px; border: 1px solid var(--border);
    background: var(--surface-2); font-size: 11px;
    font-family: monospace; color: var(--ink-3);
}

/* ── Notification dot ────────────────────────────────────────────────── */
.notif-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--red); display: inline-block;
    animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50%      { opacity: .5; }
}

/* ── Section separator ───────────────────────────────────────────────── */
.section-divider {
    display: flex; align-items: center; gap: 10px;
    margin: 28px 0 16px;
}
.section-divider::before,
.section-divider::after {
    content: ''; flex: 1; height: 1px; background: var(--border);
}
.section-divider span {
    font-size: 10.5px; font-weight: 600; color: var(--ink-3);
    text-transform: uppercase; letter-spacing: .8px;
}

/* ── Inline code / token display ─────────────────────────────────────── */
.token {
    display: inline-block; padding: 2px 8px;
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 4px; font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 11px; color: var(--ink-2);
}

/* ── Enhanced topbar ─────────────────────────────────────────────────── */
.topbar {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    background: rgba(255,255,255,.85);
}
[data-theme=dark] .topbar {
    background: rgba(30,41,59,.92);
}

/* ── Enhanced sidebar ────────────────────────────────────────────────── */
.sidebar {
    background: linear-gradient(180deg, #0f172a 0%, #1a2744 100%);
}

/* ── Command Center: premium stat grid ────────────────────────────────── */
.cc-premium-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px;
}
@media (max-width: 1200px) { .cc-premium-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px)  { .cc-premium-grid { grid-template-columns: 1fr; } }

.cc-premium-stat {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 14px; padding: 20px 22px;
    box-shadow: var(--elevation-1);
    transition: all var(--duration-normal) var(--ease-out);
    text-decoration: none; color: inherit; display: block;
    position: relative; overflow: hidden;
}
.cc-premium-stat:hover {
    transform: translateY(-2px);
    box-shadow: var(--elevation-4);
    border-color: var(--gray-300);
}
.cc-premium-stat::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
}
.cc-premium-stat.danger::before  { background: var(--red); }
.cc-premium-stat.warning::before { background: var(--amber); }
.cc-premium-stat.success::before { background: var(--green); }
.cc-premium-stat.info::before    { background: var(--purple); }
.cc-premium-stat .cc-ps-icon  { font-size: 22px; margin-bottom: 8px; }
.cc-premium-stat .cc-ps-value { font-size: 28px; font-weight: 700; color: var(--ink); letter-spacing: -.02em; }
.cc-premium-stat .cc-ps-label { font-size: 11px; font-weight: 500; color: var(--ink-3); text-transform: uppercase; letter-spacing: .4px; }
.cc-premium-stat .cc-ps-sub   { font-size: 11px; color: var(--ink-4); margin-top: 2px; }

/* ── Command Center: section cards ───────────────────────────────────── */
.cc-section-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 14px; overflow: hidden;
    box-shadow: var(--elevation-1); margin-bottom: 16px;
}
.cc-section-card .cc-sc-header {
    padding: 14px 18px; border-bottom: 1px solid var(--border-soft);
    display: flex; align-items: center; justify-content: space-between;
    font-size: var(--text-sm); font-weight: 600; color: var(--ink);
}
.cc-section-card .cc-sc-body { padding: 10px 0; }
.cc-section-card .cc-sc-footer {
    padding: 10px 18px; border-top: 1px solid var(--border-soft);
}

/* ── Responsive refinements ──────────────────────────────────────────── */
@media (max-width: 768px) {
    .premium-stat, .cc-premium-stat { padding: 16px; }
    .premium-stat .ps-value, .cc-premium-stat .cc-ps-value { font-size: 22px; }
    .glass-header { flex-direction: column; text-align: center; }
    .page-hero { padding: 20px 24px; }
    .page-hero h1 { font-size: var(--text-xl); }
}

/* ── Print styles ────────────────────────────────────────────────────── */
@media print {
    .sidebar, .topbar, .btn, .quick-actions, .cc-section-card .cc-sc-footer {
        display: none !important;
    }
    .main-area { margin-left: 0 !important; }
    .content { padding: 0 !important; }
    body { background: #fff; font-size: 11pt; }
    .premium-card, .cc-section-card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
}

/* ── Dark mode enhancements ──────────────────────────────────────────── */
[data-theme=dark] .premium-stat,
[data-theme=dark] .cc-premium-stat,
[data-theme=dark] .stat-link {
    background: var(--surface); border-color: var(--border);
}
[data-theme=dark] .glass-header {
    background: linear-gradient(135deg, var(--surface) 0%, rgba(183,110,121,.08) 100%);
}
[data-theme=dark] .page-hero {
    background: linear-gradient(135deg, #0f172a, #1e293b);
}
[data-theme=dark] .empty-state-premium .esp-illustration {
    background: linear-gradient(135deg, rgba(183,110,121,.12), rgba(183,110,121,.06));
}
[data-theme=dark] .premium-table tbody tr:hover { background: rgba(255,255,255,.03); }
[data-theme=dark] .topbar { background: rgba(15,23,42,.9); }
