/**
 * ATM Reconciliation System - Main Stylesheet
 * Theme: Sky Blue (#4A90E2) & Reddish Gold (#D4845C)
 * Supports automatic light/dark mode adaptation
 */

/* =================================================================
   CSS Custom Properties (Theme Variables)
   ================================================================= */

:root {
    /* Primary Theme Colors */
    --theme-primary: #4A90E2;           /* Sky Blue */
    --theme-secondary: #D4845C;         /* Reddish Gold */
    
    /* Background Colors - Light Mode */
    --bg-body: #ffffff;
    --bg-gradient-start: #4A90E2;
    --bg-gradient-end: #357ABD;
    --bg-card: #ffffff;
    --bg-section: #f8f9fa;
    --bg-input: #f9fafb;
    
    /* Text Colors - Auto Dark on Light */
    --text-primary: #1a1a1a;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --text-on-primary: #ffffff;
    --text-on-secondary: #ffffff;
    
    /* Border & Shadow Colors */
    --border-light: #e5e7eb;
    --border-medium: #d1d5db;
    --border-dark: #9ca3af;
    --shadow-sm: rgba(0, 0, 0, 0.05);
    --shadow-md: rgba(0, 0, 0, 0.1);
    --shadow-lg: rgba(0, 0, 0, 0.15);
    --shadow-hover: rgba(74, 144, 226, 0.3);
    
    /* Status Colors (Preserved for Clarity) */
    --status-success: #10b981;
    --status-error: #ef4444;
    --status-warning: #f59e0b;
    --status-info: #3b82f6;
    --status-balanced: #10b981;
    
    /* Status Background Colors */
    --bg-success: #d1fae5;
    --bg-error: #fee2e2;
    --bg-warning: #fef3c7;
    --bg-info: #dbeafe;
    
    /* Status Text Colors */
    --text-success: #065f46;
    --text-error: #991b1b;
    --text-warning: #92400e;
    --text-info: #1e40af;
    
    /* Interactive States */
    --hover-overlay: rgba(74, 144, 226, 0.08);
    --active-overlay: rgba(74, 144, 226, 0.15);
    
    /* Accent Colors (Theme-based) */
    --accent-primary-light: #7CB3E9;
    --accent-primary-dark: #2E6BA5;
    --accent-secondary-light: #E0A584;
    --accent-secondary-dark: #B8633D;
}

/* Dark Mode Adaptations */
@media (prefers-color-scheme: dark) {
    :root {
        /* Primary Theme Colors - Adjusted for Dark Mode */
        --theme-primary: #7CB3E9;       /* Lighter Sky Blue */
        --theme-secondary: #E0A584;     /* Lighter Reddish Gold */
        
        /* Background Colors - Dark Mode */
        --bg-body: #0f172a;
        --bg-gradient-start: #2E6BA5;
        --bg-gradient-end: #1e3a5f;
        --bg-card: #1e293b;
        --bg-section: #0f172a;
        --bg-input: #0f172a;
        
        /* Text Colors - Auto Light on Dark */
        --text-primary: #f1f5f9;
        --text-secondary: #cbd5e1;
        --text-muted: #94a3b8;
        --text-on-primary: #0f172a;
        --text-on-secondary: #0f172a;
        
        /* Border & Shadow Colors */
        --border-light: #334155;
        --border-medium: #475569;
        --border-dark: #64748b;
        --shadow-sm: rgba(0, 0, 0, 0.2);
        --shadow-md: rgba(0, 0, 0, 0.4);
        --shadow-lg: rgba(0, 0, 0, 0.6);
        --shadow-hover: rgba(124, 179, 233, 0.4);
        
        /* Status Colors - Adjusted for Dark Mode */
        --status-success: #34d399;
        --status-error: #f87171;
        --status-warning: #fbbf24;
        --status-info: #60a5fa;
        --status-balanced: #34d399;
        
        /* Status Background Colors */
        --bg-success: #14532d;
        --bg-error: #7f1d1d;
        --bg-warning: #78350f;
        --bg-info: #1e3a5f;
        
        /* Status Text Colors */
        --text-success: #86efac;
        --text-error: #fca5a5;
        --text-warning: #fde68a;
        --text-info: #93c5fd;
        
        /* Interactive States */
        --hover-overlay: rgba(124, 179, 233, 0.12);
        --active-overlay: rgba(124, 179, 233, 0.2);
    }
}

/* =================================================================
   Base Styles
   ================================================================= */

* {
    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-body);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Centered layout for upload pages */
body.centered-layout {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* =================================================================
   Layout Components
   ================================================================= */

.container {
    max-width: 600px;
    width: 100%;
    background: var(--bg-card);
    border-radius: 20px;
    box-shadow: 0 20px 60px var(--shadow-lg);
    padding: 40px;
    transition: all 0.3s ease;
}

.container-wide {
    max-width: 1200px;
}

.container-full {
    max-width: 1400px;
}

/* =================================================================
   Typography
   ================================================================= */

h1 {
    color: var(--text-primary);
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 10px;
}

h2 {
    color: var(--text-primary);
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 15px;
}

h3 {
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 10px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 30px;
}

p {
    color: var(--text-secondary);
    margin-bottom: 10px;
}

/* =================================================================
   Buttons
   ================================================================= */

.btn {
    display: inline-block;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, 
                var(--theme-primary) 0%, 
                var(--accent-primary-dark) 100%);
    color: var(--text-on-primary);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px var(--shadow-hover);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: linear-gradient(135deg, 
                var(--theme-secondary) 0%, 
                var(--accent-secondary-dark) 100%);
    color: var(--text-on-secondary);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(212, 132, 92, 0.3);
}

.btn-block {
    width: 100%;
    padding: 15px;
}

.btn:disabled {
    background: var(--border-medium);
    cursor: not-allowed;
    transform: none;
    opacity: 0.6;
}

.btn-back {
    background: var(--border-medium);
    color: var(--text-primary);
}

.btn-back:hover {
    background: var(--border-dark);
    transform: translateY(-2px);
}

/* =================================================================
   Form Elements
   ================================================================= */

.form-group {
    margin-bottom: 25px;
}

label {
    display: block;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 14px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 2px solid var(--border-medium);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.3s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--theme-primary);
    box-shadow: 0 0 0 3px var(--hover-overlay);
}

/* File Input Styling */
.file-input-wrapper {
    position: relative;
    overflow: hidden;
    display: inline-block;
    width: 100%;
}

.file-input-wrapper input[type="file"] {
    position: absolute;
    left: -9999px;
}

.file-input-label {
    display: block;
    width: 100%;
    padding: 12px 20px;
    background: var(--bg-input);
    border: 2px dashed var(--border-medium);
    border-radius: 10px;
    cursor: pointer;
    text-align: center;
    transition: all 0.3s ease;
    color: var(--text-secondary);
}

.file-input-label:hover {
    border-color: var(--theme-primary);
    background: var(--hover-overlay);
}

.file-name {
    margin-top: 8px;
    font-size: 12px;
    color: var(--status-success);
    font-weight: 500;
}

/* =================================================================
   Alert Boxes
   ================================================================= */

.alert {
    padding: 15px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    border-left: 4px solid;
    font-size: 14px;
}

.alert h3 {
    font-size: 16px;
    margin-bottom: 8px;
}

.alert ul {
    margin-left: 20px;
    line-height: 1.8;
}

/* Success Alert */
.alert-success {
    background: var(--bg-success);
    border-color: var(--status-success);
    color: var(--text-success);
}

/* Error Alert */
.alert-error {
    background: var(--bg-error);
    border-color: var(--status-error);
    color: var(--text-error);
}

/* Warning Alert */
.alert-warning {
    background: var(--bg-warning);
    border-color: var(--status-warning);
    color: var(--text-warning);
}

/* Info Alert */
.alert-info {
    background: var(--bg-info);
    border-color: var(--status-info);
    color: var(--text-info);
}

/* =================================================================
   Cards & Sections
   ================================================================= */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: 0 4px 12px var(--shadow-md);
}

.card-header {
    border-bottom: 2px solid var(--border-light);
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.section {
    margin-bottom: 30px;
    padding: 20px;
    background: var(--bg-section);
    border-radius: 12px;
    border: 1px solid var(--border-light);
}

/* =================================================================
   Tables
   ================================================================= */

.table-wrapper {
    overflow-x: auto;
    margin: 20px 0;
    border-radius: 12px;
    border: 1px solid var(--border-light);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
}

thead {
    background: linear-gradient(135deg, 
                var(--theme-primary) 0%, 
                var(--accent-primary-dark) 100%);
    color: var(--text-on-primary);
}

th {
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-secondary);
    font-size: 14px;
}

tbody tr {
    transition: background-color 0.2s ease;
}

tbody tr:hover {
    background: var(--hover-overlay);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* Table Status Rows */
tr.excluded {
    background: var(--bg-error);
    color: var(--text-error);
}

tr.included {
    background: var(--bg-success);
    color: var(--text-success);
}

/* =================================================================
   Status Badges
   ================================================================= */

.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success {
    background: var(--status-success);
    color: white;
}

.badge-error {
    background: var(--status-error);
    color: white;
}

.badge-warning {
    background: var(--status-warning);
    color: white;
}

.badge-info {
    background: var(--status-info);
    color: white;
}

/* =================================================================
   Stats/Metrics Cards
   ================================================================= */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin: 30px 0;
}

.stat-card {
    background: var(--bg-card);
    border: 2px solid var(--border-light);
    border-radius: 15px;
    padding: 25px;
    text-align: center;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px var(--shadow-md);
    border-color: var(--theme-primary);
}

.stat-value {
    font-size: 36px;
    font-weight: 700;
    color: var(--theme-primary);
    margin-bottom: 8px;
}

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Balanced Status */
.stat-card.balanced {
    border-color: var(--status-success);
}

.stat-card.balanced .stat-value {
    color: var(--status-success);
}

/* Unbalanced Status */
.stat-card.unbalanced {
    border-color: var(--status-error);
}

.stat-card.unbalanced .stat-value {
    color: var(--status-error);
}

/* =================================================================
   Download Links
   ================================================================= */

.download-section {
    margin: 30px 0;
}

.download-links {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.download-link {
    flex: 1;
    min-width: 200px;
    padding: 15px 20px;
    background: var(--bg-section);
    border: 2px solid var(--border-light);
    border-radius: 12px;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 600;
    text-align: center;
    transition: all 0.3s ease;
}

.download-link:hover {
    background: var(--theme-primary);
    color: var(--text-on-primary);
    border-color: var(--theme-primary);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px var(--shadow-hover);
}

/* =================================================================
   Utility Classes
   ================================================================= */

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mt-10 { margin-top: 10px; }
.mt-20 { margin-top: 20px; }
.mt-30 { margin-top: 30px; }

.mb-10 { margin-bottom: 10px; }
.mb-20 { margin-bottom: 20px; }
.mb-30 { margin-bottom: 30px; }

.p-10 { padding: 10px; }
.p-20 { padding: 20px; }
.p-30 { padding: 30px; }

.hidden {
    display: none;
}

/* =================================================================
   Responsive Design
   ================================================================= */

@media (max-width: 768px) {
    .container {
        padding: 20px;
        border-radius: 15px;
    }
    
    h1 {
        font-size: 24px;
    }
    
    h2 {
        font-size: 20px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .download-links {
        flex-direction: column;
    }
    
    table {
        font-size: 12px;
    }
    
    th, td {
        padding: 8px;
    }
}

/* =================================================================
   Loading States
   ================================================================= */

.loading {
    opacity: 0.6;
    pointer-events: none;
}

.spinner {
    border: 3px solid var(--border-light);
    border-top-color: var(--theme-primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
