/* CSS Variables */
:root {
    --color-primary: #1976d2;
    --color-primary-dark: #1565c0;
    --color-primary-light: rgba(25, 118, 210, 0.04);
    --color-primary-lighter: rgba(25, 118, 210, 0.1);
    --color-heading: #1a365d;
    --color-accent: #42a5f5;
    --color-success: #2e7d32;
    --color-success-dark: #1b5e20;
    --color-text: rgba(0, 0, 0, 0.87);
    --color-text-secondary: rgba(0, 0, 0, 0.6);
    --color-border: rgba(0, 0, 0, 0.23);
    --color-border-light: rgba(0, 0, 0, 0.12);
    --color-disabled-text: rgba(0, 0, 0, 0.26);
    --color-divider: rgba(224, 224, 224, 1);
    --color-stripe: rgba(0, 0, 0, 0.02);
    --color-bg-start: #f6f9fc;
    --color-bg-end: #ecf3f9;
    --color-error-bg: #fdeded;
    --color-error-text: #5f2120;
    --color-error-border: #f5c6cb;
    --color-success-bg: #d4edda;
    --color-success-text: #155724;
    --color-success-border: #c3e6cb;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.1);
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Container */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Common page layout */
.page-content,
.main-content {
    min-height: 100vh;
    background: linear-gradient(120deg, var(--color-bg-start) 0%, var(--color-bg-end) 100%);
}

.page-content {
    padding: 64px 0;
}

.page-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-heading);
    margin-bottom: 32px;
}

/* Navigation */
.app-nav {
    position: static;
    background-color: white;
    box-shadow: var(--shadow-sm);
}

.nav-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 64px;
    padding: 0;
}

.logo-section {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: inherit;
}

.logo-section img {
    width: 32px;
    height: 32px;
    margin-right: 16px;
}

.logo-section h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-heading);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}

.nav-links {
    display: flex;
    gap: 24px;
}

.nav-links a {
    color: var(--color-text);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--color-primary);
}

.nav-links a.active {
    border-bottom: 2px solid var(--color-primary);
    padding-bottom: 2px;
}

/* Buttons */
.btn {
    padding: 10px 36px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    text-transform: none;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

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

.btn-primary:hover {
    background-color: var(--color-primary-dark);
}

.btn-success {
    background-color: var(--color-success);
    color: white;
    padding: 12px 32px;
    font-size: 1.1rem;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(46, 125, 50, 0.2);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-success:hover {
    background-color: var(--color-success-dark);
    box-shadow: 0 6px 16px rgba(46, 125, 50, 0.3);
}

.btn-success:disabled {
    background-color: var(--color-border-light);
    color: var(--color-disabled-text);
    cursor: not-allowed;
    box-shadow: none;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* HTMX Loading Indicator */
.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: block;
}

/* Cards */
.card {
    background-color: white;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    margin-bottom: 32px;
}

.card-content {
    padding: 24px;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-heading);
    margin-bottom: 16px;
}

.card-content p {
    color: var(--color-text);
    line-height: 1.6;
    margin-bottom: 16px;
}

.card-content p:last-child {
    margin-bottom: 0;
}

/* Paper component */
.paper {
    background-color: white;
    border-radius: 16px;
    box-shadow: var(--shadow-md);
}

/* Tables */
.table-container {
    border-radius: 8px;
    overflow: hidden;
    overflow-x: auto;
    box-shadow: var(--shadow-md);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background-color: var(--color-primary);
}

.data-table thead th {
    color: white;
    font-weight: 600;
    padding: 16px;
    text-align: left;
}

.data-table tbody tr {
    border-bottom: 1px solid var(--color-divider);
}

.data-table tbody tr:nth-of-type(odd) {
    background-color: var(--color-stripe);
}

.data-table tbody td {
    padding: 16px;
}

.data-table tbody tr.total-row {
    background-color: var(--color-accent);
}

.data-table tbody tr.total-row td {
    font-weight: bold;
    color: white;
    font-size: 1.1rem;
}

/* Alerts */
.alert {
    margin-top: 32px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
    max-width: 600px;
    padding: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
}

.alert-error {
    background-color: var(--color-error-bg);
    color: var(--color-error-text);
    border: 1px solid var(--color-error-border);
}

/* Progress bars */
.progress-bar {
    height: 8px;
    border-radius: 4px;
    background-color: var(--color-primary-lighter);
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background-color: var(--color-primary);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-bar-indeterminate {
    animation: indeterminate 1.5s linear infinite;
}

@keyframes indeterminate {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

.progress-text {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    text-align: center;
    margin-top: 8px;
}

/* Empty states */
.empty-state {
    padding: 32px;
    text-align: center;
}

.empty-state h3 {
    font-size: 1.25rem;
    color: var(--color-text-secondary);
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--color-text-secondary);
}

/* Index page styles */
.main-content {
    padding-top: 32px;
    padding-bottom: 64px;
}

.hero-section {
    text-align: center;
    margin-bottom: 8px;
    animation: fadeIn 0.5s ease-in;
}

.hero-section h2 {
    font-size: 3rem;
    font-weight: 700;
    color: var(--color-heading);
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 32px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.3;
}

.hero-section .subtitle {
    font-size: 1.25rem;
    color: var(--color-text-secondary);
    max-width: 600px;
    margin: 32px auto 0;
    position: relative;
    top: -10px;
}

.upload-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
}

.upload-section form {
    width: 100%;
    display: flex;
    justify-content: center;
}

.upload-box {
    padding: 48px;
    width: 100%;
    max-width: 600px;
    text-align: center;
    cursor: pointer;
    background-color: white;
    border: 3px dashed var(--color-border-light);
    border-radius: 16px;
    transition: all 0.3s ease;
}

.upload-box:hover {
    background-color: var(--color-primary-light);
    border-color: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.upload-box.drag-active {
    background-color: var(--color-primary-light);
    border-color: var(--color-primary);
}

.upload-box img {
    margin-bottom: 20px;
}

.upload-box h3 {
    font-size: 1.4rem;
    font-weight: 400;
    color: var(--color-text);
    margin-bottom: 12px;
}

.upload-box .or-text {
    font-size: 1rem;
    color: var(--color-text-secondary);
    margin: 16px 0;
}

.upload-box .file-hint {
    font-size: 1rem;
    color: var(--color-text-secondary);
    margin-top: 24px;
}

.progress-section {
    margin-top: 32px;
    width: 100%;
    max-width: 600px;
    display: none;
}

.progress-section.htmx-request {
    display: block;
}

/* Disable upload box while processing */
.upload-section:has(.htmx-request) .upload-box {
    pointer-events: none;
    opacity: 0.5;
}

.results-section {
    margin-top: 48px;
    animation: slideUp 0.5s ease-out;
}

.download-button-container {
    margin-bottom: 24px;
    display: flex;
    justify-content: center;
}

input[type="file"] {
    display: none;
}

/* Password prompt */
.password-section {
    margin-top: 32px;
    width: 100%;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.password-prompt {
    font-size: 1rem;
    color: var(--color-text);
    margin-bottom: 16px;
    text-align: center;
}

.password-input-group {
    display: flex;
    gap: 12px;
    align-items: center;
}

.password-input-group .form-input {
    flex: 1;
}

/* Honeypot (anti-spam) */
.honeypot-field {
    position: absolute;
    left: -9999px;
    height: 0;
    overflow: hidden;
}

/* Contact page styles */
.form-group {
    margin-bottom: 24px;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: 8px;
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 16px;
    font-size: 1rem;
    font-family: inherit;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    transition: border-color 0.2s, box-shadow 0.2s;
    background-color: white;
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 1px var(--color-primary);
}

.form-textarea {
    resize: vertical;
    min-height: 120px;
}

.btn-submit {
    width: 100%;
    padding: 12px 32px;
    font-size: 1rem;
    font-weight: 600;
    background-color: var(--color-primary);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
    font-family: inherit;
    text-transform: none;
}

.btn-submit:hover {
    background-color: var(--color-primary-dark);
}

.alert-success {
    background-color: var(--color-success-bg);
    color: var(--color-success-text);
    border: 1px solid var(--color-success-border);
    padding: 16px;
    border-radius: 4px;
    margin-top: 24px;
}

/* Responsive */
@media (max-width: 768px) {
    .hero-section h2 {
        font-size: 2rem;
    }

    .hero-section .subtitle {
        font-size: 1rem;
    }

    .upload-box {
        padding: 32px 24px;
    }

    .nav-toolbar {
        flex-direction: column;
        gap: 8px;
        padding: 12px 0;
    }

    .container {
        padding: 0 16px;
    }
}
