@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* Color Palette - Modern Dark Theme */
    --bg-dark: #0a0b10;
    --bg-card: #151726;
    --bg-input: #1e2133;
    --bg-sidebar: #0d0f1a;

    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;

    --accent-indigo: #6366f1;
    --accent-indigo-hover: #4f46e5;
    --accent-indigo-glow: rgba(99, 102, 241, 0.4);

    --accent-emerald: #10b981;
    --accent-emerald-glow: rgba(16, 185, 129, 0.2);
    --accent-rose: #f43f5e;
    --accent-rose-glow: rgba(244, 63, 94, 0.2);
    --accent-amber: #f59e0b;

    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-focus: #6366f1;

    --font-main: 'Inter', system-ui, -apple-system, sans-serif;
    --radius-lg: 12px;
    --radius-md: 8px;
    --radius-sm: 4px;

    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    height: 100%;
}

body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    background-color: var(--bg-dark);
    /* Assuming --bg-dark is the intended variable */
    color: var(--text-primary);
    /* Assuming --text-primary is the intended variable */
    height: 100vh;
    overflow: hidden;
    display: flex;
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

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

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

.app-container {
    display: grid;
    grid-template-columns: 320px 1fr;
    width: 100%;
    height: 100%;
    overflow: hidden;
    /* Constraint */
}

.hidden {
    display: none !important;
}

/* Sidebar */
.sidebar {
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-subtle);
    padding: 24px 0;
    /* Remove horizontal padding from container, keep vertical */
    display: flex;
    flex-direction: column;
    overflow-y: hidden;
    /* Disable global scroll */
    min-height: 0;
    /* Critical for grid item shrinkage */
    height: 100%;
}

.logo-section {
    margin-bottom: 40px;
    padding: 0 20px;
    /* Add horizontal padding here */
    flex-shrink: 0;
}

.logo-section h1 {
    font-size: 1.25rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-section h1::before {
    content: '';
    width: 12px;
    height: 12px;
    background: var(--accent-indigo);
    border-radius: 2px;
    box-shadow: 0 0 10px var(--accent-indigo-glow);
}

.tagline {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 500;
}

.input-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 32px;
    overflow-y: auto;
    /* Enable scroll here */
    padding: 0 20px;
    /* Add horizontal padding here */
    min-height: 0;
    /* Required for nested flex scroll */
}

.group-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 1.5px;
    margin-bottom: 0;
    /* Adjusted for flex container */
    font-weight: 700;
}

.title-with-info {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.info-icon-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.info-icon {
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    transition: var(--transition);
}

.info-icon-wrapper:hover .info-icon {
    color: var(--accent-indigo);
}

.tooltip {
    position: absolute;
    left: 50%;
    top: 24px;
    transform: translateX(-50%) translateY(0);
    /* Start at final Y but shifted for animation */
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    width: 260px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    text-transform: none;
    letter-spacing: normal;
}

.tooltip em {
    color: var(--accent-indigo);
    font-style: italic;
}

.info-icon-wrapper:hover .tooltip {
    opacity: 1;
    transform: translateX(-50%) translateY(4px);
}

/* Tooltip Arrow */
.tooltip::before {
    content: '';
    position: absolute;
    left: 50%;
    top: -6px;
    transform: translateX(-50%) rotate(45deg);
    width: 10px;
    height: 10px;
    background: var(--bg-card);
    border-left: 1px solid var(--border-subtle);
    border-top: 1px solid var(--border-subtle);
}

@media screen and (max-width: 1024px) {
    .tooltip {
        left: auto;
        right: 0;
        top: 24px;
        transform: translateX(0);
    }

    .tooltip::before {
        left: auto;
        right: 10px;
        top: -6px;
        transform: rotate(45deg);
    }

    .info-icon-wrapper:hover .tooltip {
        transform: translateY(4px) translateX(0);
    }
}

/* Time Header Labels */
.time-header {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-bottom: 6px;
}

.label-spacer {
    width: 20px;
}

.time-label {
    width: 48px;
    text-align: center;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}


/* Time Input Fields */
.cue-row {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-bottom: 8px;
}

.cue-row span.label {
    width: 20px;
    font-weight: 700;
    color: var(--accent-indigo);
    font-size: 0.9rem;
}

.time-box {
    width: 48px;
    height: 36px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: #fff;
    text-align: center;
    font-family: 'Inter', monospace;
    font-size: 0.9rem;
    transition: var(--transition);
}

.time-box:focus {
    border-color: var(--accent-indigo);
    outline: none;
    background: var(--bg-card);
}

.time-box.input-error {
    border-color: var(--accent-rose);
    box-shadow: 0 0 5px var(--accent-rose-glow);
    color: var(--accent-rose);
}

.clear-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px;
    line-height: 1;
    border-radius: 50%;
    transition: var(--transition);
}

.clear-btn:hover {
    color: var(--accent-rose);
    background: rgba(244, 63, 94, 0.1);
}

/* Error message for cue points */
.error-message {
    color: var(--accent-rose);
    font-size: 0.75rem;
    font-style: italic;
    margin-top: 8px;
    margin-left: 26px;
    line-height: 1.4;
}


.sidebar-footer {
    margin-top: 24px;
    padding: 24px 20px 0 20px;
    /* Add horizontal padding here */
    border-top: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.help-btn {
    width: 100%;
    padding: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
}

.help-btn:hover {
    background: var(--accent-indigo-glow);
    color: #fff;
    border-color: var(--accent-indigo);
}

/* Main Content */
.dashboard-main {
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.header-left h2 {
    font-size: 1.4rem;
    font-weight: 700;
    transition: var(--transition);
}

.header-left p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 4px;
}

/* Pills & Inputs Styles */
.pill {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    padding: 8px 16px;
    border-radius: 100px;
    border: 1px solid var(--border-subtle);
}

.pill label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
}

.pill-select {
    background: transparent;
    border: none;
    color: var(--accent-indigo);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    outline: none;
}

/* Common Card Style */
.dashboard-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-vibrant);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.card-header h3 {
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
}

/* Suggestions Bar (BPM Tabs) */
.suggestions-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.tempo-tab {
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    text-align: center;
}

.tempo-tab .bpm-val {
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
}

.tempo-tab .error-val {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.tempo-tab:hover {
    border-color: var(--accent-indigo);
    transform: translateY(-2px);
}

.tempo-tab.active {
    background: var(--accent-indigo);
    border-color: transparent;
    box-shadow: 0 10px 20px var(--accent-indigo-glow);
}

.tempo-tab.active * {
    color: #fff !important;
}

/* Custom BPM Stepper */
.custom-tempo-bar {
    display: flex;
    justify-content: center;
    background: var(--bg-card);
    padding: 16px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
}

.bpm-stepper {
    display: flex;
    align-items: center;
    gap: 16px;
}

.bpm-display {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--accent-indigo);
    min-width: 180px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.step-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid var(--border-subtle);
    background: var(--bg-input);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

.step-btn.secondary {
    width: 40px;
    height: 40px;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.step-btn:hover {
    background: var(--accent-indigo);
    border-color: var(--accent-indigo);
    transform: scale(1.1);
}

/* Results Content Layout */
.results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto 1fr;
    gap: 16px;
    align-items: stretch;
}

.suggestions-bar,
.custom-tempo-bar {
    grid-column: 1;
    grid-row: 1;
}

.data-card {
    grid-column: 1;
    grid-row: 2;
}

.chart-card {
    grid-column: 2;
    grid-row: 2;
}

.data-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 450px;
}


/* Modern Table */
.data-table-container {
    padding: 0;
}

.modern-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.modern-table th {
    padding: 16px 20px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-subtle);
}

.modern-table td {
    padding: 16px 20px;
    font-size: 0.95rem;
    border-bottom: 1px solid var(--border-subtle);
}

.modern-table tr:last-child td {
    border-bottom: none;
}

.modern-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* Cue column styling */
.modern-table th:first-child,
.modern-table td:first-child {
    width: 60px;
    text-align: center;
    padding: 16px 12px;
}


/* Color grading for offset td */
.offset-good {
    color: var(--accent-emerald);
    font-weight: 600;
}

.offset-ok {
    color: var(--accent-amber);
    font-weight: 500;
}

.offset-bad {
    color: var(--accent-rose);
    font-weight: 500;
}

.cell-faded {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-left: 8px;
}

/* Beat Map (Circular Chart) */
.chart-card {
    display: flex;
    flex-direction: column;
    min-height: 450px;
}

.chart-wrapper {
    flex: 1;
    padding: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 350px;
}

.chart-container {
    width: min(100%, 320px);
    aspect-ratio: 1 / 1;
    border: 2px solid var(--border-subtle);
    border-radius: 50%;
    position: relative;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.05) 0%, transparent 70%);
    flex-shrink: 0;
}

.chart-center-dot {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 8px;
    background: var(--accent-indigo);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 15px var(--accent-indigo-glow);
}

.chart-point-label {
    position: absolute;
    color: #fff;
    background: #000;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.8rem;
    font-weight: 700;
    transform: translate(-50%, -50%);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 10;
    border: 1px solid var(--border-subtle);
}

.chart-beat-line {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2px;
    height: 50%;
    background: var(--text-muted);
    transform-origin: top center;
    opacity: 0.3;
}

.chart-beat-number {
    position: absolute;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 700;
    transform: translate(-50%, -50%);
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
}

.chart-line {
    /* Current tempo line */
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2px;
    height: 50%;
    background: var(--accent-rose);
    transform-origin: top center;
    box-shadow: 0 0 10px var(--accent-rose-glow);
}

/* Global Settings Bar (Footer) */
.settings-bar {
    display: flex;
    gap: 32px;
    padding: 12px 24px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-subtle);
    flex-wrap: wrap;
    z-index: 10;
    flex-wrap: wrap;
    z-index: 10;
    align-items: flex-start;
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.setting-item label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
}

.setting-item select,
.setting-item input {
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: #fff;
    padding: 8px 12px;
    font-family: var(--font-main);
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition);
}

.setting-item select:focus,
.setting-item input:focus {
    border-color: var(--accent-indigo);
}

.dual-input {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
}

.dual-input input {
    width: 70px;
    text-align: center;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-input);
    transition: .4s;
    border-radius: 24px;
    border: 1px solid var(--border-subtle);
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-muted);
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--accent-indigo);
    border-color: var(--accent-indigo);
}

input:checked+.slider:before {
    transform: translateX(20px);
    background-color: #fff;
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 40px;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    position: relative;
}

.modal-card.large {
    max-width: 800px;
}

.close-modal {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 2rem;
    cursor: pointer;
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--accent-indigo);
    border: none;
    border-radius: var(--radius-md);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    margin-top: 24px;
    transition: var(--transition);
}

.btn-primary:hover {
    background: var(--accent-indigo-hover);
}

/* Empty State */
.empty-state-message {
    padding: 80px 40px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.empty-icon {
    font-size: 3rem;
    opacity: 0.5;
}

.empty-state-message p {
    color: var(--text-secondary);
    max-width: 300px;
}

/* Help Content */
.help-content {
    color: var(--text-main);
    line-height: 1.6;
}

.help-scroll {
    max-height: 70vh;
    overflow-y: auto;
    padding-right: 12px;
}

.help-scroll h2 {
    font-size: 1.5rem;
    margin-bottom: 24px;
    color: #fff;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 16px;
}

.help-scroll section {
    margin-bottom: 40px;
}

.help-scroll h3 {
    font-size: 0.85rem;
    color: var(--accent-indigo);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 24px;
    margin-bottom: 12px;
}

.help-scroll section:first-of-type h3:first-of-type {
    margin-top: 0;
}

.help-scroll h4 {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-main);
    margin-top: 20px;
    margin-bottom: 8px;
}

.help-scroll p {
    margin-bottom: 16px;
    color: var(--text-muted);
}

.help-scroll ul {
    list-style: none;
    padding: 0;
    margin-bottom: 16px;
}

.help-scroll li {
    margin-bottom: 12px;
    padding-left: 0;
    color: var(--text-muted);
}

.help-scroll li strong {
    color: #fff;
}

.help-warning {
    color: var(--accent-rose) !important;
}

/* Color guide specific override if needed, or keep generic */
.color-guide {
    list-style: none;
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.color-guide li {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 0;
    /* Remove inherited margin to tighten spacing */
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.dot.green {
    background: var(--accent-emerald);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
}

.dot.yellow {
    background: var(--accent-amber);
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.4);
}

.dot.red {
    background: var(--accent-rose);
    box-shadow: 0 0 8px rgba(244, 63, 94, 0.4);
}

/* Responsive adjustments */
@media screen and (max-width: 1024px) {
    .app-container {
        grid-template-columns: 280px 1fr;
    }

    .results-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }

    .suggestions-bar,
    .custom-tempo-bar,
    .data-card,
    .chart-card {
        grid-column: auto;
        grid-row: auto;
    }
}

@media screen and (max-width: 768px) {
    .app-container {
        display: block;
        overflow-y: auto;
    }

    .sidebar {
        border-right: none;
        border-bottom: 1px solid var(--border-subtle);
    }

    .dashboard-main {
        padding: 20px;
    }

    .settings-bar {
        gap: 16px;
    }
}

.main-footer {
    margin-top: auto;
    padding: 20px 0;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-subtle);
    width: 100%;
}

.main-footer a {
    color: var(--accent-indigo);
    text-decoration: underline;
    transition: color 0.2s;
}

.main-footer a:hover {
    color: var(--accent-indigo-hover);
}

@media screen and (min-width: 2500px) {
    body {
        zoom: 1.5;
        width: 66.66vw;
        height: 66.66vh;
    }

    .modal-card.large {
        max-width: 600px;
    }

    .help-scroll {
        max-height: 500px;
    }
}