/*
 * SienaCore Business Plan System - Design System v1.2 (Modern Theme)
 * Scoped strictly to body.theme-modern
 *
 * Strategy:
 * - Default: Benign / Transparent
 * - Theme-modern: Glass, Sticky Columns, Deep Slate Background
 */

/* =========================================
   Base Variables (Scoped)
   ========================================= */
body.theme-modern {
    --bg-app: #0f172a;
    /* Deep Slate */
    --bg-panel: #1e293b;
    /* Sidebar */
    --bg-card: #1e293b;
    --bg-card-glass: rgba(30, 41, 59, 0.7);
    --bg-input: rgba(0, 0, 0, 0.2);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-subtle: rgba(255, 255, 255, 0.1);
    --accent-primary: #3b82f6;

    --font-family: 'Inter', system-ui, sans-serif;
    --radius-lg: 12px;
}

/* =========================================
   Global Overrides for Theme Modern
   ========================================= */
body.theme-modern {
    background-color: var(--bg-app);
    color: var(--text-primary);
    font-family: var(--font-family);
}

/* Sidebar & Layout Overrides */
body.theme-modern .sidebar {
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border-subtle);
    color: var(--text-secondary);
}

body.theme-modern .sidebar-menu a {
    color: var(--text-secondary);
}

body.theme-modern .sidebar-menu a.active {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-primary);
    border-left-color: var(--accent-primary);
}

body.theme-modern .sidebar-menu a:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Main Content Area */
body.theme-modern .main-wrapper {
    background: transparent;
}

/* =========================================
   New Component Classes (Benign in Default)
   ========================================= */

/* .modern-card: Transparent by default, Glass in Modern */
.modern-card {
    background: transparent;
    padding: 0;
    margin-bottom: 20px;
}

body.theme-modern .modern-card {
    background: var(--bg-card-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    padding: 20px;
    /* Internal padding */
}

/* Typography inside card */
body.theme-modern .page-title {
    color: var(--text-primary);
    font-weight: 700;
}

body.theme-modern .page-description {
    color: var(--text-secondary);
}

/* =========================================
   The Table (High Density + Sticky)
   ========================================= */

/* Wrapper for scrolling */
.modern-table-container {
    width: 100%;
    overflow-x: auto;
    /* Enable scroll */
    position: relative;
    padding-bottom: 10px;
    /* Space for scrollbar */
}

/* Table Style Overrides */
body.theme-modern table {
    width: 100%;
    border-collapse: separate;
    /* Required for sticky */
    border-spacing: 0;
    font-size: 13px;
    /* Compact font */
}

/* Header Cells */
body.theme-modern th {
    background: var(--bg-panel);
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-subtle);
    border-right: 1px solid var(--border-subtle);
    padding: 6px 8px;
    /* Compact padding */
    height: 32px;
    white-space: nowrap;
    font-weight: 600;
    position: sticky;
    top: 0;
    /* Sticky Header */
    z-index: 10;
}

/* Body Cells */
body.theme-modern td {
    background: transparent;
    border-bottom: 1px solid var(--border-subtle);
    border-right: 1px solid var(--border-subtle);
    /* Grid lines */
    padding: 0;
    /* Zero padding for inputs */
    height: 30px;
    /* Fixed compact height */
    vertical-align: middle;
}

/* STICKY LEFT COLUMN (The "Pin") */
body.theme-modern th:first-child,
body.theme-modern td:first-child {
    position: sticky;
    left: 0;
    background: var(--bg-panel);
    /* Must be opaque to hide scrolling content */
    z-index: 11;
    /* Higher than normal cells */
    border-right: 2px solid var(--border-subtle);
    /* Distinct divider */
    width: 250px;
    /* Min width */
    min-width: 250px;
    max-width: 250px;
}

body.theme-modern th:first-child {
    z-index: 20;
    /* Corner piece - highest */
}

/* Inputs (Transparent & Compact) */
body.theme-modern input[type="text"],
body.theme-modern input[type="number"] {
    background: transparent;
    border: none;
    color: var(--text-primary);
    width: 100%;
    height: 100%;
    /* Fill cell */
    padding: 0 4px;
    font-size: 13px;
    font-family: monospace;
    /* Alignment */
    text-align: right;
}

body.theme-modern input:focus {
    background: rgba(59, 130, 246, 0.15);
    outline: none;
    box-shadow: inset 0 -2px 0 var(--accent-primary);
    /* Underline focus */
}

/* Hover row effect */
body.theme-modern tr:hover td {
    background-color: rgba(255, 255, 255, 0.03);
}

/* Ensure sticky column keeps its background on hover */
body.theme-modern tr:hover td:first-child {
    background-color: var(--bg-panel);
}

/* =========================================
   Inputs / Forms (Settings pages)
   ========================================= */
body.theme-modern .form-group input,
body.theme-modern .form-group select,
body.theme-modern .form-group textarea {
    background: var(--bg-input);
    border: none;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    border-radius: 4px 4px 0 0;
}

body.theme-modern .form-group input:focus {
    border-bottom-color: var(--accent-primary);
    background: rgba(59, 130, 246, 0.1);
}

/* Scrollbars */
body.theme-modern ::-webkit-scrollbar {
    height: 10px;
    width: 10px;
}

body.theme-modern ::-webkit-scrollbar-track {
    background: var(--bg-app);
}

body.theme-modern ::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 5px;
    border: 2px solid var(--bg-app);
}

body.theme-modern ::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}
