/* --- Variable Definitions --- */
:root {
    --primary-gold: #FFD700;
    --background-dark: #1f1f1f;
    --background-medium: #2d2d2d;
    --background-light: #444;
    --accent-purple: #800080;
    --foreground-light: #f0f0f0;
    --foreground-medium: #a0a0a0;
    --font-body: 'PT Sans', sans-serif;
    --font-display: 'Playfair Display', serif;
    --success-green: #28a745;
    --error-red: #dc3545;
}

/* --- Base & Reset Styles --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    background-color: var(--background-dark);
    color: var(--foreground-light);
    line-height: 1.6;
}

h1, h2, h3, h4, h5 {
    font-family: var(--font-display);
    color: var(--primary-gold);
}

a {
    color: var(--primary-gold);
    text-decoration: none;
}

ul {
    list-style: none;
}

/* --- Layout --- */
#app-container {
    display: flex;
    height: 100vh;
}

#sidebar {
    width: 250px;
    background-color: var(--background-dark);
    border-right: 1px solid var(--background-light);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease-in-out;
    position: fixed; /* Changed for mobile overlay */
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    z-index: 50;
}

#sidebar.open {
    transform: translateX(0);
}


.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
    border-bottom: 1px solid var(--background-light);
}

.sidebar-header .logo-icon {
    width: 2rem;
    height: 2rem;
    margin-right: 0.5rem;
    color: var(--primary-gold);
}

.sidebar-header h1 {
    font-size: 1.25rem;
}

.nav-links {
    flex-grow: 1;
    padding: 1rem;
}

.nav-links li a {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--foreground-medium);
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

.nav-links li a:hover,
.nav-links li a.active {
    background-color: var(--background-medium);
    color: var(--foreground-light);
}

.main-content-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    width: 100%; /* Ensure it takes full width */
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem;
    height: 70px;
    border-bottom: 1px solid var(--background-light);
}

.time-display {
    text-align: right;
}

.time-display #current-time {
    font-weight: bold;
    color: var(--primary-gold);
}

.time-display #current-date {
    font-size: 0.75rem;
    color: var(--foreground-medium);
}

#main-content {
    flex: 1;
    padding: 1rem; /* Reduced padding for mobile */
    overflow-y: auto;
}

/* --- Dashboard Insights --- */
.dashboard-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background-color: var(--background-medium);
    border-radius: 8px;
    align-items: center;
}
.date-range-pickers {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.quick-filters {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
}
.btn-quick-filter {
    background-color: var(--background-light);
    color: var(--foreground-light);
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
}
.btn-quick-filter.active {
    background-color: var(--primary-gold);
    color: var(--background-dark);
}

.dashboard-insights-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 1.5rem;
}

.chart-container {
    background-color: var(--background-medium);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}
.chart-container h4, .chart-container h5 {
    margin-bottom: 1rem;
    text-align: center;
}

.full-width { grid-column: 1 / -1; }
.half-width { grid-column: span 6; }
.third-width { grid-column: span 4; }

.interactive-chart-section {
    grid-column: 1 / -1;
    background-color: var(--background-dark);
    padding: 1.5rem;
    border-radius: 8px;
    margin-top: 1rem;
}

.chart-filters {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.chart-filters label {
    font-weight: bold;
}
.chart-filters select, .dashboard-controls input {
    padding: 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--background-light);
    background-color: var(--background-medium);
    color: var(--foreground-light);
}

.number-analysis-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}


/* Forms */
.form-container, .info-container {
    max-width: 600px;
    margin: 0 auto;
    background-color: var(--background-medium);
    padding: 2rem;
    border-radius: 8px;
}
.info-box {
    background-color: var(--background-medium); 
    padding: 1.5rem; 
    border-radius: 8px;
    margin-bottom: 1rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--foreground-medium);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--background-light);
    background-color: var(--background-dark);
    color: var(--foreground-light);
    font-size: 1rem;
}

/* Import Page Styles */
.import-instructions {
    margin: 1rem 0;
    padding: 1rem;
    background-color: var(--background-dark);
    border-left: 3px solid var(--primary-gold);
    border-radius: 4px;
    font-size: 0.9rem;
}
.template-link {
    display: inline-block;
    margin-bottom: 1.5rem;
    text-decoration: underline;
}
.import-summary {
    margin-top: 1.5rem;
    padding: 1rem;
    border-radius: 4px;
    text-align: center;
}
.import-summary .success {
    color: var(--success-green);
    font-weight: bold;
}
.import-summary .error {
    color: var(--error-red);
    font-weight: bold;
}

/* Manage Page Styles */
.manage-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background-color: var(--background-medium);
    border-radius: 8px;
}
.manage-controls .filter-group {
    display: flex;
    flex-direction: column;
}
.manage-controls label {
    font-size: 0.8rem;
    color: var(--foreground-medium);
    margin-bottom: 0.25rem;
}
.manage-actions {
    margin-left: auto;
    display: flex;
    gap: 1rem;
    align-self: flex-end;
}
.table-container {
    overflow-x: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
}
th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--background-light);
}
th {
    color: var(--primary-gold);
}
th.sortable-header {
    cursor: pointer;
}
th.sortable-header:hover {
    color: var(--foreground-light);
}
.sort-arrow {
    margin-left: 0.5rem;
    font-size: 0.8em;
    opacity: 0.7;
}
td.actions {
    display: flex;
    gap: 0.5rem;
}
.btn-edit, .btn-delete, .btn-bulk-delete {
    background: none;
    border: 1px solid var(--foreground-medium);
    color: var(--foreground-medium);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}
.btn-edit:hover {
    background-color: var(--primary-gold);
    color: var(--background-dark);
    border-color: var(--primary-gold);
}
.btn-delete:hover, .btn-bulk-delete:hover {
    background-color: var(--error-red);
    color: var(--foreground-light);
    border-color: var(--error-red);
}


/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-primary {
    background-color: var(--primary-gold);
    color: var(--background-dark);
}

.btn-primary:hover {
    opacity: 0.8;
}
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Modal and Spinner */
.modal-hidden {
    display: none;
}

#modal-overlay.modal-hidden,
#loading-spinner.modal-hidden {
    display: none;
}

#modal-overlay, #loading-spinner {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

#modal-box {
    background-color: var(--background-medium);
    padding: 2rem;
    border-radius: 8px;
    text-align: center;
    max-width: 400px;
    width: 90%;
}
.modal-form .form-group {
    text-align: left;
}

#modal-content {
    margin-bottom: 1rem;
}

#modal-actions {
    margin-top: 1.5rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
}

#modal-cancel-button {
    background-color: var(--background-light);
    color: var(--foreground-light);
}

#modal-confirm-button {
    background-color: var(--success-green);
    color: white;
}
#modal-confirm-button.delete {
    background-color: var(--error-red);
}


.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid var(--background-light);
    border-top-color: var(--primary-gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Weekly Comparison Table */
.weekly-comparison-table {
    margin-top: 1rem;
    text-align: center;
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}
.weekly-comparison-table th {
    background-color: var(--background-light);
    font-size: 0.7rem;
    padding: 0.4rem 0.1rem;
    white-space: normal;
}
.weekly-comparison-table td, .weekly-comparison-table th {
    border: 1px solid var(--background-light);
    padding: 0.25rem;
    font-size: 0.8rem;
    min-width: 35px;
}
.weekly-comparison-table .week-label {
    font-weight: bold;
    color: var(--primary-gold);
    white-space: nowrap;
    font-size: 0.75rem;
    cursor: help;
    position: relative;
    border-left: 2px solid var(--primary-gold);
}
.weekly-comparison-table .week-label .full-date {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--background-dark);
    padding: 0.5rem;
    border-radius: 6px;
    z-index: 10;
    white-space: nowrap;
    border: 1px solid var(--background-light);
}
.weekly-comparison-table .week-label:hover .full-date {
    display: block;
}
.weekly-comparison-table .highlight-match {
    background-color: #3a3a2a;
    font-weight: bold;
    color: var(--primary-gold);
    border: 1px solid var(--primary-gold);
}
.weekly-comparison-table th.day-divider,
.weekly-comparison-table td.day-divider {
    border-left: 2px solid var(--primary-gold);
}
.weekly-comparison-table th:last-child,
.weekly-comparison-table td:last-child {
    border-right: 2px solid var(--primary-gold);
}

/* Responsive Styles */
.md-hidden {
    display: none;
}
@media (max-width: 768px) {
    #sidebar {
        position: fixed;
    }
    .main-content-wrapper {
        margin-left: 0;
    }
    .md-hidden {
        display: block;
    }
    header #page-title {
        font-size: 1.25rem;
    }
    .manage-controls, .dashboard-controls {
        flex-direction: column;
        align-items: stretch;
    }
    .quick-filters {
        margin-left: 0;
        justify-content: center;
    }
    .number-analysis-grid {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 769px) {
    #sidebar {
        position: relative;
        transform: translateX(0);
    }
}
