/**
 * Panel shell refresh — Linear / Vercel–inspired surfaces, mobile-first spacing.
 * Scoped to body.panel-shell-modern so legacy pages can opt out if needed.
 * Does not change HTML structure, IDs, or JS hooks (#sidebar, toggleSidebar, etc.).
 */

html[data-theme="light"] body.panel-shell-modern {
    --shell-bg: #eef1f8;
    --shell-bg-mid: #e8ecf6;
    --shell-card: #ffffff;
    --shell-card-hover: #fafbff;
    --shell-border: rgba(15, 23, 42, 0.08);
    --shell-border-strong: rgba(15, 23, 42, 0.12);
    --shell-text: #0f172a;
    --shell-muted: #64748b;
    --shell-accent: #6d5aed;
    --shell-accent-soft: rgba(109, 90, 237, 0.12);
    --shell-glow: rgba(109, 90, 237, 0.2);
    --header-blur-bg: rgba(248, 250, 252, 0.82);
}

html[data-theme="dark"] body.panel-shell-modern {
    --shell-bg: #0c0e14;
    --shell-bg-mid: #12151f;
    --shell-card: #161a24;
    --shell-card-hover: #1c2230;
    --shell-border: rgba(255, 255, 255, 0.06);
    --shell-border-strong: rgba(255, 255, 255, 0.1);
    --shell-text: #f1f5f9;
    --shell-muted: #94a3b8;
    --shell-accent: #8b7cf7;
    --shell-accent-soft: rgba(139, 124, 247, 0.14);
    --shell-glow: rgba(139, 124, 247, 0.25);
    --header-blur-bg: rgba(12, 14, 20, 0.78);
}

body.panel-shell-modern {
    font-family: "DM Sans", var(--font-family, "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
    background: var(--shell-bg) !important;
    color: var(--shell-text);
}

/* Map FinFlow tokens to shell (inherits to all components using var(--bg-color) etc.) */
html[data-theme="light"] body.panel-shell-modern {
    --bg-color: var(--shell-bg);
    --bg-secondary: #e2e8f0;
    --card-bg: var(--shell-card);
    --card-hover: var(--shell-card-hover);
    --border-color: var(--shell-border);
    --border-light: rgba(15, 23, 42, 0.04);
    --border-dark: rgba(15, 23, 42, 0.14);
    --text-primary: var(--shell-text);
    --text-secondary: #475569;
    --text-muted: var(--shell-muted);
    --primary-color: var(--shell-accent);
    --primary-dark: #5b4cdb;
    --primary-light: rgba(109, 90, 237, 0.14);
    --primary-gradient: linear-gradient(135deg, #6d5aed 0%, #9333ea 100%);
    --finflow-gray: var(--shell-bg);
    --finflow-gray-light: var(--shell-bg);
    --finflow-gray-medium: #e2e8f0;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow: 0 4px 16px rgba(15, 23, 42, 0.07);
    --shadow-md: 0 12px 32px rgba(15, 23, 42, 0.1);
}

html[data-theme="dark"] body.panel-shell-modern {
    --bg-color: var(--shell-bg);
    --bg-secondary: var(--shell-bg-mid);
    --card-bg: var(--shell-card);
    --card-hover: var(--shell-card-hover);
    --border-color: var(--shell-border);
    --border-light: rgba(255, 255, 255, 0.04);
    --border-dark: rgba(255, 255, 255, 0.12);
    --text-primary: var(--shell-text);
    --text-secondary: #cbd5e1;
    --text-muted: var(--shell-muted);
    --primary-color: var(--shell-accent);
    --primary-dark: #7c3aed;
    --primary-light: rgba(139, 124, 247, 0.15);
    --primary-gradient: linear-gradient(135deg, #8b7cf7 0%, #a78bfa 100%);
    --finflow-gray: var(--shell-bg);
    --finflow-gray-light: var(--shell-bg);
    --finflow-gray-medium: #1e293b;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    --shadow-md: 0 16px 48px rgba(0, 0, 0, 0.5);
}

/* Ambient background */
body.panel-shell-modern .app-container {
    position: relative;
    background: transparent;
}

body.panel-shell-modern .app-container::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse 70% 45% at 15% -5%, var(--shell-glow), transparent 55%),
        radial-gradient(ellipse 50% 35% at 100% 0%, rgba(45, 212, 191, 0.08), transparent 45%),
        var(--shell-bg);
}

body.panel-shell-modern .app-container > .main-content {
    position: relative;
    z-index: 1;
}

/* Sidebar */
body.panel-shell-modern .finflow-sidebar {
    background: var(--shell-card);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--shell-border-strong);
    box-shadow: 4px 0 40px rgba(0, 0, 0, 0.06);
    padding: 24px 0;
}

@supports (background: color-mix(in srgb, white 50%, black)) {
    body.panel-shell-modern .finflow-sidebar {
        background: color-mix(in srgb, var(--shell-card) 92%, transparent);
    }
}

html[data-theme="dark"] body.panel-shell-modern .finflow-sidebar {
    box-shadow: 4px 0 48px rgba(0, 0, 0, 0.35);
}

body.panel-shell-modern .sidebar-nav-item {
    border-radius: 10px;
    border-left: none;
    margin: 0 4px;
    transition: background 0.2s cubic-bezier(0.22, 1, 0.36, 1), color 0.2s, transform 0.15s;
}

body.panel-shell-modern .sidebar-nav-item:hover {
    transform: translateX(4px);
}

body.panel-shell-modern .sidebar-nav-item.active {
    background: var(--shell-accent-soft);
    color: var(--primary-color);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary-color) 28%, transparent);
}

body.panel-shell-modern .sidebar-dropdown-item {
    border-radius: 8px;
    transition: background 0.15s ease;
}

body.panel-shell-modern .sidebar-dropdown-item.active {
    background: var(--shell-accent-soft);
    color: var(--primary-color);
}

body.panel-shell-modern .sidebar-premium {
    background: transparent;
    box-shadow: none;
    border: none;
}

body.panel-shell-modern .sidebar-premium-btn {
    box-shadow: 0 4px 16px var(--shell-glow);
}

body.panel-shell-modern .sidebar-premium-btn:hover {
    box-shadow: 0 8px 24px var(--shell-glow);
}

/* Main column */
body.panel-shell-modern .main-content {
    padding: clamp(20px, 3vw, 36px);
    animation: shellFadeIn 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes shellFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Sticky top header bar */
body.panel-shell-modern .finflow-header {
    position: sticky;
    top: 0;
    z-index: 40;
    margin-bottom: clamp(20px, 3vw, 28px);
    padding: 12px 0 16px;
    margin-top: -4px;
    background: var(--header-blur-bg);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--shell-border);
    border-radius: 0 0 16px 16px;
    flex-wrap: wrap;
    gap: clamp(12px, 2vw, 20px);
}

body.panel-shell-modern .finflow-greeting {
    font-size: 14px;
    color: var(--text-muted);
}

body.panel-shell-modern .finflow-title {
    font-size: clamp(1.35rem, 4vw, 1.85rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    background: none;
    -webkit-text-fill-color: unset;
    color: var(--text-primary);
}

body.panel-shell-modern .dashboard-page .finflow-title {
    animation: none;
}

body.panel-shell-modern .finflow-mobile-toggle {
    border-radius: 12px;
    background: var(--primary-gradient);
    box-shadow: 0 4px 20px var(--shell-glow);
    transition: transform 0.15s cubic-bezier(0.22, 1, 0.36, 1), filter 0.2s;
}

body.panel-shell-modern .finflow-mobile-toggle:active {
    transform: scale(0.96);
}

/* Header controls */
body.panel-shell-modern .finflow-lang-wrap,
body.panel-shell-modern .finflow-icon-btn,
body.panel-shell-modern .finflow-notification-bell,
body.panel-shell-modern .finflow-profile {
    border-radius: 12px;
    border-color: var(--shell-border-strong);
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}

body.panel-shell-modern .finflow-lang-wrap:hover,
body.panel-shell-modern .finflow-icon-btn:hover,
body.panel-shell-modern .finflow-notification-bell:hover {
    box-shadow: 0 6px 20px var(--shell-glow);
}

body.panel-shell-modern .finflow-search {
    border-radius: 999px;
    border: 1px solid var(--shell-border-strong);
    background: var(--card-bg);
    transition: border-color 0.2s, box-shadow 0.2s;
}

body.panel-shell-modern .finflow-search:focus-within {
    border-color: color-mix(in srgb, var(--primary-color) 45%, var(--shell-border));
    box-shadow: 0 0 0 3px var(--shell-accent-soft);
}

/* Cards (global) */
body.panel-shell-modern .card {
    border-radius: 16px;
    border: 1px solid var(--shell-border);
    box-shadow: var(--shadow-sm);
    transition: border-color 0.2s, box-shadow 0.25s cubic-bezier(0.22, 1, 0.36, 1), transform 0.2s;
}

body.panel-shell-modern .card:hover {
    border-color: var(--shell-border-strong);
    box-shadow: var(--shadow-md);
}

body.panel-shell-modern .card-header {
    border-bottom-color: var(--shell-border);
}

/* Dashboard FinFlow stat cards */
body.panel-shell-modern .finflow-transfer-card {
    border-radius: 16px !important;
    border: 1px solid var(--shell-border) !important;
    transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.25s, border-color 0.2s !important;
}

body.panel-shell-modern .finflow-transfer-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md) !important;
    border-color: var(--shell-border-strong) !important;
}

/* Widget grid */
body.panel-shell-modern .dashboard-widgets-grid {
    gap: clamp(14px, 2vw, 20px);
}

body.panel-shell-modern .dashboard-widgets-grid > .card {
    transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.2s;
}

body.panel-shell-modern .dashboard-widgets-grid > .card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Buttons */
body.panel-shell-modern .btn {
    border-radius: 10px;
    transition: transform 0.15s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.2s, filter 0.2s;
}

body.panel-shell-modern .btn:active {
    transform: scale(0.98);
}

body.panel-shell-modern .btn-primary {
    box-shadow: 0 4px 16px var(--shell-glow);
}

/* Messages strip (dashboard) */
body.panel-shell-modern .finflow-dashboard-messages-link {
    border-radius: 16px;
    border: 1px solid var(--shell-border);
    transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
}

body.panel-shell-modern .finflow-dashboard-messages-link:hover {
    border-color: color-mix(in srgb, var(--primary-color) 35%, transparent);
    box-shadow: var(--shadow);
}

/* Movie slider */
body.panel-shell-modern .movie-card-inner {
    border-radius: 16px;
    border: 1px solid var(--shell-border);
}

/* Profile dropdown */
body.panel-shell-modern .finflow-profile-dropdown {
    border-radius: 14px;
    border: 1px solid var(--shell-border-strong);
    box-shadow: var(--shadow-md);
}

/* Mobile / coarse pointer: extra breathing room */
@media (max-width: 768px), (pointer: coarse) and (max-width: 1024px) {
    body.panel-shell-modern .main-content {
        padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px));
    }

    body.panel-shell-modern .finflow-header {
        border-radius: 0 0 12px 12px;
        padding-top: 8px;
    }

    body.panel-shell-modern .finflow-title {
        font-size: 1.25rem;
    }

    body.panel-shell-modern .finflow-sidebar.open {
        box-shadow: 8px 0 40px rgba(0, 0, 0, 0.25);
    }
}

@media (prefers-reduced-motion: reduce) {
    body.panel-shell-modern .main-content,
    body.panel-shell-modern .finflow-transfer-card,
    body.panel-shell-modern .card,
    body.panel-shell-modern .dashboard-widgets-grid > .card {
        animation: none !important;
        transition-duration: 0.01ms !important;
    }
}
