/* ============================================
   Rich Future - Stylesheet
   ============================================ */

:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: #1a2235;
    --bg-input: #0f1626;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-glow: rgba(59, 130, 246, 0.3);
    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.1);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --border: #1e293b;
    --border-light: #334155;
    --sidebar-width: 260px;
    --transition: 0.2s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

.app-container {
    display: flex;
    min-height: 100vh;
}

/* ============================================
   Sidebar
   ============================================ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    padding: 20px 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
    transition: transform var(--transition);
}

.sidebar-header {
    padding: 0 20px 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-header h1 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
}

.sidebar-header h1 span {
    color: var(--accent);
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    display: none;
}

.sidebar-toggle:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.nav-section {
    padding: 0 10px;
}

.nav-label {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    padding: 0 10px 10px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 8px;
    text-align: left;
    transition: all var(--transition);
}

.nav-item:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent);
}

.nav-item svg {
    flex-shrink: 0;
}

/* ============================================
   Main Content
   ============================================ */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 30px 40px;
    max-width: 1200px;
}

.tool-panel {
    display: none;
}

.tool-panel.active {
    display: block;
}

.tool-panel h2 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}

/* ============================================
   Featured Compound Tool
   ============================================ */
.featured-header {
    margin-bottom: 25px;
}

.featured-header p.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 20px;
}

.featured-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 30px;
}

.summary-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
}

.summary-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.summary-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--success);
}

.summary-card:nth-child(2) .summary-value {
    color: var(--accent);
}

.summary-card:nth-child(3) .summary-value {
    color: var(--success);
}

.summary-card:nth-child(4) .summary-value {
    color: var(--warning);
}

/* ============================================
   Tool Layout
   ============================================ */
.tool-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 30px;
    align-items: start;
}

.tool-inputs {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 25px;
}

.input-group {
    margin-bottom: 15px;
}

.input-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.input-group input,
.input-group select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: border-color var(--transition);
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ============================================
   Buttons
   ============================================ */
.btn-primary,
.btn-secondary {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    width: 100%;
    margin-bottom: 10px;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

/* ============================================
   Results
   ============================================ */
.tool-results {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 25px;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.result-item {
    text-align: center;
    padding: 15px;
    background: var(--bg-input);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.result-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}

.result-value {
    display: block;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* ============================================
   Charts
   ============================================ */
.chart-container {
    margin-top: 25px;
    padding: 20px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.chart-container h3 {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 15px;
}

canvas {
    width: 100% !important;
    height: 250px !important;
}

/* ============================================
   Table
   ============================================ */
.table-container {
    margin-top: 25px;
    padding: 20px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.table-container h3 {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 15px;
}

.table-scroll {
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

th {
    background: var(--bg-card);
    color: var(--text-secondary);
    padding: 10px 12px;
    text-align: right;
    font-weight: 600;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

th:first-child {
    text-align: left;
}

td {
    padding: 8px 12px;
    text-align: right;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

td:first-child {
    text-align: left;
    font-weight: 600;
}

tr:hover td {
    background: rgba(59, 130, 246, 0.05);
}

/* ============================================
   Budget Categories
   ============================================ */
.budget-categories {
    margin-top: 15px;
}

.budget-category {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 8px;
}

.budget-cat-name {
    font-weight: 600;
    color: var(--text-primary);
}

.budget-cat-amount {
    color: var(--text-secondary);
}

.budget-cat-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
}

.budget-cat-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.budget-cat-delete {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    padding: 5px;
    margin-left: 10px;
    font-size: 1.1rem;
    opacity: 0.6;
    transition: opacity var(--transition);
}

.budget-cat-delete:hover {
    opacity: 1;
}

/* ============================================
   Ad Slots (Google AdSense Integration)
   ============================================ */

/* Ad Label (visible when placeholder is shown) */
.ad-label {
    display: none;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    padding: 0 4px;
    margin-bottom: 6px;
}

/* Ad Placeholder (shown when ads are disabled/not loaded) */
.ad-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px;
    background: var(--bg-input);
    border: 1px dashed var(--border-light);
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 0.8rem;
    min-height: 80px;
    transition: all var(--transition);
}

.ad-placeholder svg {
    opacity: 0.4;
}

/* When ads are enabled, hide placeholders */
body.ads-enabled .ad-placeholder {
    display: none !important;
}

body.ads-enabled .ad-label {
    display: none !important;
}

/* Sidebar Ad Slot (160x600) */
.sidebar-ad {
    padding: 15px 10px 20px;
    border-top: 1px solid var(--border);
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.sidebar-placeholder {
    width: 160px;
    height: 600px;
    min-height: 600px;
}

/* Top Banner Ad (728x90) */
.ad-banner {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0 0 20px 0;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.banner-placeholder {
    width: 728px;
    height: 90px;
    max-width: 100%;
}

/* In-Content Banner Ad (468x60) */
.ad-incontent {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 15px 0;
    padding: 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.incontent-placeholder {
    width: 468px;
    height: 60px;
    max-width: 100%;
}

/* Responsive Ad (auto-sizes) */
.ad-responsive {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 15px 0 0 0;
    padding: 10px;
}

.responsive-placeholder {
    min-height: 50px;
    width: 100%;
}

/* Responsive adjustments for ads */
@media (max-width: 768px) {
    .sidebar-ad {
        display: none;
    }

    .banner-placeholder {
        width: 320px;
        height: 50px;
    }

    .incontent-placeholder {
        width: 300px;
        height: 250px;
    }

    .responsive-placeholder {
        width: 320px;
        min-height: 50px;
    }
}

@media (max-width: 480px) {
    .banner-placeholder {
        width: 320px;
        height: 50px;
    }

    .incontent-placeholder {
        width: 300px;
        height: 250px;
    }
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 900px) {
    .tool-layout {
        grid-template-columns: 1fr;
    }
    .featured-summary {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: block;
    }

    .main-content {
        margin-left: 0;
        padding: 20px;
    }

    .featured-summary {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 480px) {
    .featured-summary {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   Scrollbar
   ============================================ */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

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

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