/* ---=== Brand Variables ===--- */
:root {
    --font-heading: 'Poppins', sans-serif;
    --font-body: 'Inter', sans-serif;
    
    --color-primary: #3498db;
    --color-primary-dark: #2980b9;
    --color-bg: #f4f7f9;
    --color-bg-alt: #ffffff;
    --color-border: #e6e9ed;
    --color-text-primary: #2c3e50;
    --color-text-secondary: #7b8a9a;
    --color-sidebar-bg: #2c3e50;
    --color-sidebar-text: #bdc3c7;
    --color-sidebar-text-active: #ffffff;
    --color-sidebar-hover: #34495e;
}

[data-theme='dark'] {
    /* == Dark Theme == */
    --color-primary: #3498db; /* Blue can stay the same or be slightly lighter */
    --color-primary-dark: #2980b9;
    --color-bg: #1a1d21; /* Very dark grey */
    --color-bg-alt: #2c3138; /* Slightly lighter dark grey for cards */
    --color-border: #424953;
    --color-text-primary: #f0f2f5; /* Light text */
    --color-text-secondary: #a0a8b4;
    --color-sidebar-bg: #212529;
    --color-sidebar-text: #a0a8b4;
    --color-sidebar-text-active: #ffffff;
    --color-sidebar-hover: #343a40;
}

/* ---=== Base & Reset ===--- */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font-body);
    background-color: var(--color-bg);
    color: var(--color-text-primary);
    transition: background-color 0.2s ease, color 0.2s ease;
}

.app-container { display: flex; min-height: 100vh; }

/* ---=== Sidebar Navigation ===--- */
.sidebar {
    width: 260px;
    background-color: var(--color-sidebar-bg);
    color: var(--color-sidebar-text-active);
    display: flex;
    flex-direction: column;
    padding: 20px;
    border-right: 1px solid var(--color-border);
}

.sidebar-header {
    display: flex; align-items: center; gap: 15px; padding-bottom: 20px;
    border-bottom: 1px solid var(--color-border);
}

.logo { width: 40px; height: 40px; }
.sidebar-title { font-family: var(--font-heading); font-size: 1.2em; }
.sidebar-nav { margin-top: 30px; flex-grow: 1; }

.nav-link {
    display: flex; align-items: center; padding: 12px 15px;
    margin-bottom: 8px; border-radius: 6px; text-decoration: none;
    color: var(--color-sidebar-text);
    transition: background-color 0.3s, color 0.3s;
}

.nav-link:hover { background-color: var(--color-sidebar-hover); color: var(--color-sidebar-text-active); }
.nav-link.active { background-color: var(--color-primary); color: var(--color-sidebar-text-active); font-weight: 500; }
.sidebar-footer { font-size: 0.8em; color: var(--color-text-secondary); text-align: center; }


/* ---=== Main Content Area ===--- */
.main-content { flex-grow: 1; display: flex; flex-direction: column; }

.main-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 20px 30px; background-color: var(--color-bg-alt);
    border-bottom: 1px solid var(--color-border);
}

.header-controls { display: flex; align-items: center; gap: 20px; }
.main-header h2 { font-family: var(--font-heading); font-size: 1.8em; }
.user-profile { display: flex; align-items: center; gap: 15px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.content-area { padding: 30px; flex-grow: 1; overflow-y: auto; }

/* ---=== Components (Cards, Forms, Buttons) ===--- */
.card {
    background-color: var(--color-bg-alt);
    border-radius: 8px; padding: 25px; margin-bottom: 30px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    border: 1px solid var(--color-border);
}

h3, h4 {
    font-family: var(--font-heading); font-weight: 600;
    margin-bottom: 20px; color: var(--color-text-primary);
}
h3 { font-size: 1.4em; }
h4 { font-size: 1.1em; }


.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

label { font-weight: 500; margin-bottom: 8px; font-size: 0.9em; color: var(--color-text-secondary); }
input[type="text"], input[type="password"], input[type="number"] {
    padding: 12px; border: 1px solid var(--color-border);
    border-radius: 6px; font-size: 1em; font-family: var(--font-body);
    background-color: var(--color-bg); color: var(--color-text-primary);
    transition: border-color 0.3s, box-shadow 0.3s;
}

input:focus {
    outline: none; border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

button {
    background-color: var(--color-primary); color: white;
    padding: 12px 20px; border: none; border-radius: 6px;
    cursor: pointer; font-size: 1em; font-weight: 500;
    font-family: var(--font-body); transition: background-color 0.3s;
}

button:hover { background-color: var(--color-primary-dark); }
.theme-btn {
    padding: 8px 16px; font-size: 0.9em;
    background-color: var(--color-border);
    color: var(--color-text-secondary);
}
.theme-btn:hover { background-color: var(--color-primary); color: white; }

/* ---=== Tab and Result Styling ===--- */
.tab-nav { border-bottom: 2px solid var(--color-border); margin-bottom: 20px; }

.tab-link {
    background: none; border: none; padding: 10px 20px;
    margin-bottom: -2px; border-bottom: 2px solid transparent;
    font-size: 1em; color: var(--color-text-secondary);
}

.tab-link.active {
    border-bottom-color: var(--color-primary);
    color: var(--color-text-primary); font-weight: 500;
}

.tab-content { display: none; }
.tab-content p { color: var(--color-text-secondary); }

#results-log {
    background-color: var(--color-sidebar-bg);
    color: var(--color-sidebar-text);
    font-family: 'Courier New', Courier, monospace;
    padding: 15px; border-radius: 5px; min-height: 100px;
    max-height: 400px; overflow-y: auto; white-space: pre-wrap; font-size: 0.9em;
}

#results-log p { margin: 0 0 10px 0; color: inherit; }

/* ---=== New Spinner & Action Styles ===--- */
.form-action {
    display: flex;
    align-items: center;
    gap: 15px;
}

.spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border-left-color: var(--color-primary);
    animation: spin 1s ease infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}


/* ---=== New CSV Preview Table Styles ===--- */
.results-preview {
    margin-top: 20px;
    max-height: 300px;
    overflow: auto;
    border: 1px solid var(--color-border);
    border-radius: 6px;
}

.preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

.preview-table th, .preview-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

.preview-table th {
    background-color: var(--color-bg);
    font-family: var(--font-heading);
    font-weight: 600;
    position: sticky;
    top: 0;
}
/* ---=== New Authentication Page Styles ===--- */
.auth-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: var(--color-bg);
}

.auth-container {
    width: 100%;
    max-width: 400px;
    padding: 30px;
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-header .logo {
    width: 60px;
    height: 60px;
    margin-bottom: 15px;
}

.auth-header h2 {
    font-family: var(--font-heading);
    color: var(--color-text-primary);
}

.auth-header p {
    color: var(--color-text-secondary);
}

.auth-form {
    /* background-color: var(--color-bg-alt); */
    padding: 30px;
    border-radius: 8px;
    border: 1px solid var(--color-border);
}

.auth-log {
    margin-bottom: 15px;
    text-align: center;
    font-size: 0.9em;
}

.auth-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 0.9em;
}

.auth-footer a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
}
.auth-footer a:hover {
    text-decoration: underline;
}

/* --- Logout Link Style --- */
.logout-link {
    font-size: 0.8em;
    color: var(--color-text-secondary);
    text-decoration: none;
    margin-left: 10px;
    transition: color 0.3s;
}
.logout-link:hover {
    color: var(--color-primary);
}

/* ---=== New UX Enhancement Styles ===--- */
.disabled {
    opacity: 0.5;
    pointer-events: none;
    transition: opacity 0.3s ease-in-out;
}

.section-lock {
    font-size: 0.7em;
    font-weight: 500;
    color: var(--color-text-secondary);
}

.results-list {
    margin-top: 15px;
    padding-left: 20px;
    list-style-type: square;
}

/* ---=== NEW: Professional Two-Panel Auth Layout ===--- */

/* This will be the main container on the page */
.auth-wrapper {
    display: flex;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* The left panel for branding */
.auth-branding-panel {
    width: 45%;
    background: linear-gradient(45deg, #2c3e50, #34495e);
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 40px;
    text-align: center;
}

.auth-branding-panel .logo {
    width: 80px;
    height: 80px;
    margin-bottom: 20px;
}

.auth-branding-panel h1 {
    font-family: var(--font-heading);
    font-size: 2.5em;
    font-weight: 700;
    margin-bottom: 10px;
}

.auth-branding-panel p {
    font-size: 1.1em;
    max-width: 400px;
    color: var(--color-text-light);
}

/* The right panel for the form */
.auth-form-panel {
    width: 55%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
    background-color: var(--color-bg);
}

/* Override previous styles to fit the new layout */
body.auth-page {
    display: block; /* Remove flex properties */
    padding: 0; /* Remove old padding */
}

.auth-container {
    width: 100%;
    max-width: 420px;
    padding: 0; /* Remove old padding */
}

.auth-form {
    border: none; /* Remove border from form card */
    box-shadow: none; /* Remove shadow */
    padding: 0; /* Remove padding */
}

.auth-form .form-action button {
    width: 100%; /* Make button full-width */
}

.auth-links {
    display: flex;
    justify-content: space-between;
    font-size: 0.9em;
    margin-top: 20px;
    margin-bottom: 20px;
}

.auth-links a {
    text-decoration: none;
    color: var(--color-text-secondary);
}

.auth-links a:hover {
    color: var(--color-primary);
}

/* --- NEW Profile Settings Styles --- */
.profile-photo-section {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
}
#avatar-preview {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--color-border);
}
#profile_photo {
    display: none; /* Hide the default file input */
}
.file-upload-label {
    background-color: var(--color-border);
    color: var(--color-text-secondary);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.3s;
}
.file-upload-label:hover {
    background-color: var(--color-primary);
    color: white;
}
.readonly-input {
    background-color: var(--color-bg);
    cursor: not-allowed;
    opacity: 0.7;
}

/* --- NEW: Two-Column Grid for Profile Settings --- */

.profile-grid-container {
    display: grid;
    /* Create two columns: The first is 2x the size of the second */
    grid-template-columns: 2fr 1fr; 
    gap: 40px; /* The space between the two columns */
    align-items: start; /* Align items to the top of their grid area */
}

.profile-details-column {
    display: flex;
    flex-direction: column;
    gap: 20px; /* Space between the username and password forms */
}

.profile-photo-column {
    display: flex;
    flex-direction: column;
    align-items: center; /* Center the profile photo content */
    text-align: center;
    background-color: var(--color-bg); /* A slightly different background */
    padding: 20px;
    border-radius: 8px;
    border: 1px dashed var(--color-border);
}

/* On smaller screens, the grid will stack into a single column */
@media (max-width: 992px) {
    .profile-grid-container {
        grid-template-columns: 1fr;
    }
}

/* --- New Result Warning Style --- */
.results-warning {
    padding: 10px;
    background-color: var(--color-warning-bg, #fffbe6); /* A light yellow background */
    border: 1px solid var(--color-warning-border, #ffe58f);
    border-radius: 6px;
    font-size: 0.9em;
    color: var(--color-warning-text, #d46b08);
    margin-bottom: 15px;
}

/* Add variables for theming to :root and [data-theme='dark'] */
:root {
    /* ... your existing variables ... */
    --color-warning-bg: #fffbe6;
    --color-warning-border: #ffe58f;
    --color-warning-text: #d46b08;
}
[data-theme='dark'] {
    /* ... your existing variables ... */
    --color-warning-bg: #4d3400;
    --color-warning-border: #875800;
    --color-warning-text: #ffd666;
}

/* ---=== NEW: Landing Page Styles ===--- */
.landing-body {
    background-color: var(--color-bg-white);
    font-family: var(--font-body);
}

.landing-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 50px;
    border-bottom: 1px solid var(--color-border);
}

.landing-header .logo-container {
    display: flex;
    align-items: center;
    gap: 15px;
    text-decoration: none;
    color: var(--color-text-primary);
}

.landing-header .logo {
    width: 40px;
    height: 40px;
}

.landing-header .app-name {
    font-family: var(--font-heading);
    font-size: 1.5em;
    font-weight: 600;
}

.landing-header .nav-buttons .btn {
    text-decoration: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.landing-header .nav-buttons .btn-secondary {
    margin-right: 10px;
    color: var(--color-text-primary);
}
.landing-header .nav-buttons .btn-secondary:hover {
    background-color: var(--color-bg-light);
}

.landing-header .nav-buttons .btn-primary {
    background-color: var(--color-primary);
    color: white;
}
.landing-header .nav-buttons .btn-primary:hover {
    background-color: var(--color-primary-dark);
}

.landing-hero {
    text-align: center;
    padding: 100px 20px;
    background-color: var(--color-bg-light);
}

.landing-hero h1 {
    font-family: var(--font-heading);
    font-size: 3.5em;
    font-weight: 700;
    color: var(--color-text-dark);
    margin-bottom: 20px;
}

.landing-hero p {
    font-size: 1.2em;
    color: var(--color-text-secondary);
    max-width: 600px;
    margin: 0 auto 30px auto;
}

.features-section {
    padding: 80px 50px;
    text-align: center;
}

.features-section h2 {
    font-family: var(--font-heading);
    font-size: 2.5em;
    margin-bottom: 50px;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 40px;
    max-width: 1200px;
    margin: 0 auto;
}

.feature-card {
    text-align: left;
    padding: 30px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background-color: var(--color-bg-white);
}

.feature-card .icon {
    font-size: 2.5em;
    color: var(--color-primary);
    margin-bottom: 15px;
}

.feature-card h3 {
    font-family: var(--font-heading);
    margin-bottom: 10px;
}

.feature-card p {
    color: var(--color-text-secondary);
    font-size: 0.9em;
    line-height: 1.6;
}