/* ============================================
   AIS Reconciler — Premium Dark Theme CSS
   ============================================ */

:root {
    /* fallback defaults (Light Theme) */
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.75);
    --bg-card-hover: rgba(255, 255, 255, 0.85);
    --bg-glass: rgba(0, 0, 0, 0.02);
    --border-subtle: rgba(79, 70, 229, 0.08);
    --border-glow: rgba(79, 70, 229, 0.3);

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;

    --accent-indigo: var(--primary, #4f46e5);
    --accent-purple: var(--accent, #c026d3);
    --accent-emerald: var(--success, #10b981);
    --accent-amber: var(--warning, #f59e0b);
    --accent-rose: #f43f5e;
    --accent-cyan: var(--secondary, #0891b2);
    --accent-blue: #3B82F6;

    --gradient-primary: linear-gradient(135deg, var(--primary, #4f46e5), var(--accent, #c026d3));
    --gradient-success: linear-gradient(135deg, var(--success, #10b981), var(--secondary, #0891b2));
    --gradient-warning: linear-gradient(135deg, var(--warning, #f59e0b), #ef4444);
    --gradient-danger: linear-gradient(135deg, #f43f5e, #dc2626);

    --radius-sm: var(--radius, 8px);
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: var(--radius-lg, 24px);

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-md: var(--shadow, 0 10px 30px rgba(0, 0, 0, 0.04));
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.08);
    --shadow-glow: 0 0 40px rgba(79, 70, 229, 0.15);

    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: var(--transition, 400ms cubic-bezier(0.16, 1, 0.3, 1));
}

/* Dark theme overrides matching dark-theme class of the main site */
.dark-theme {
    --bg-primary: #030712;
    --bg-secondary: #0b0f19;
    --bg-card: rgba(13, 17, 39, 0.45);
    --bg-card-hover: rgba(13, 17, 39, 0.6);
    --bg-glass: rgba(255, 255, 255, 0.03);
    --border-subtle: rgba(129, 140, 248, 0.15);
    --border-glow: rgba(129, 140, 248, 0.3);

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

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: var(--shadow);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 0 40px rgba(129, 140, 248, 0.15);
}

/* Reset & Base */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* Ambient Background */
.ambient-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.15;
    animation: float 20s ease-in-out infinite;
}

.orb-1 {
    width: 600px;
    height: 600px;
    background: var(--accent-indigo);
    top: -200px;
    right: -100px;
    animation-delay: 0s;
}

.orb-2 {
    width: 500px;
    height: 500px;
    background: var(--accent-purple);
    bottom: -150px;
    left: -100px;
    animation-delay: -7s;
}

.orb-3 {
    width: 400px;
    height: 400px;
    background: var(--accent-emerald);
    top: 50%;
    left: 50%;
    animation-delay: -14s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(40px, -30px) scale(1.05); }
    50% { transform: translate(-20px, 40px) scale(0.95); }
    75% { transform: translate(30px, 20px) scale(1.02); }
}

/* App Container */
.app-container {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 100px 24px 60px; /* Adjusted padding-top to offset the fixed website navbar */
}

/* Glass Card */
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--shadow-md);
    transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.glass-card:hover {
    border-color: var(--border-glow);
    box-shadow: var(--shadow-md), var(--shadow-glow);
}

/* Header */
.app-header {
    padding: 16px 0 24px;
}

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

.logo-section {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-icon {
    display: flex;
    filter: drop-shadow(0 0 12px rgba(99, 102, 241, 0.4));
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 400;
}

.fy-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(99, 102, 241, 0.12);
    color: var(--accent-indigo);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 100px;
    letter-spacing: 0.04em;
}

/* Upload Section */
.upload-section {
    margin-bottom: 32px;
}

.section-title {
    font-size: 1.15rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.title-icon {
    font-size: 1.2rem;
}

.section-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.upload-card {
    padding: 32px;
}

.upload-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.upload-zone {
    position: relative;
    border: 2px dashed var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 32px 24px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    background: var(--bg-glass);
}

.upload-zone:hover {
    border-color: var(--accent-indigo);
    background: rgba(99, 102, 241, 0.05);
}

.upload-zone.has-file {
    border-color: var(--accent-emerald);
    border-style: solid;
    background: rgba(16, 185, 129, 0.05);
}

.upload-zone-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.upload-icon {
    color: var(--accent-indigo);
    margin-bottom: 4px;
    transition: transform var(--transition-normal);
}

.upload-zone:hover .upload-icon {
    transform: scale(1.1);
}

.upload-label {
    font-weight: 600;
    font-size: 0.95rem;
}

.upload-sublabel {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.file-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.file-name {
    font-size: 0.78rem;
    color: var(--accent-emerald);
    font-weight: 500;
    margin-top: 4px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Password Field */
.password-row {
    margin-bottom: 24px;
}

.password-field {
    max-width: 480px;
}

.password-field label {
    display: block;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.input-wrapper {
    display: flex;
    position: relative;
}

.input-wrapper input {
    flex: 1;
    padding: 10px 44px 10px 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: 'Inter', monospace;
    font-size: 0.88rem;
    outline: none;
    transition: border-color var(--transition-fast);
}

.input-wrapper input:focus {
    border-color: var(--accent-indigo);
}

.toggle-pwd {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 4px;
    opacity: 0.5;
    transition: opacity var(--transition-fast);
}

.toggle-pwd:hover {
    opacity: 1;
}

.hint {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 5px;
}

/* Buttons */
.action-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.1), transparent);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.btn:hover::before {
    opacity: 1;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(99, 102, 241, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-color: var(--border-glow);
}

.btn:disabled {
    opacity: 0.5;
    pointer-events: none;
}

.btn-icon {
    font-size: 1rem;
}

/* Error Toast */
.error-toast {
    margin-top: 16px;
    padding: 12px 18px;
    background: rgba(244, 63, 94, 0.1);
    border: 1px solid rgba(244, 63, 94, 0.25);
    border-radius: var(--radius-sm);
    color: var(--accent-rose);
    font-size: 0.85rem;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Loading */
.loading-section {
    display: flex;
    justify-content: center;
    padding: 60px 0;
}

.loading-card {
    padding: 48px 64px;
    text-align: center;
}

.loader {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0;
    margin-bottom: 24px;
    height: 60px;
    position: relative;
}

.loader-ring {
    width: 48px;
    height: 48px;
    border: 3px solid transparent;
    border-radius: 50%;
    position: absolute;
    animation: spin 1.5s linear infinite;
}

.loader-ring:nth-child(1) {
    border-top-color: var(--accent-indigo);
    width: 48px;
    height: 48px;
}

.loader-ring:nth-child(2) {
    border-right-color: var(--accent-purple);
    width: 36px;
    height: 36px;
    animation-direction: reverse;
    animation-duration: 1.2s;
}

.loader-ring:nth-child(3) {
    border-bottom-color: var(--accent-emerald);
    width: 24px;
    height: 24px;
    animation-duration: 0.9s;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-card h3 {
    font-size: 1.1rem;
    margin-bottom: 6px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.loading-card p {
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* Meta Card */
.meta-card {
    padding: 20px 28px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.meta-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.meta-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

.meta-value {
    font-size: 0.9rem;
    font-weight: 500;
}

/* Health Banner */
.health-banner {
    padding: 16px 24px;
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
    animation: slideIn 0.4s ease;
}

.health-banner.clean {
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: var(--accent-emerald);
}

.health-banner.needs_attention {
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.2);
    color: var(--accent-amber);
}

.health-banner.critical {
    background: rgba(244, 63, 94, 0.08);
    border: 1px solid rgba(244, 63, 94, 0.2);
    color: var(--accent-rose);
}

.health-icon {
    font-size: 1.5rem;
}

.health-text h3 {
    font-size: 0.95rem;
}

.health-text p {
    font-size: 0.78rem;
    opacity: 0.8;
}

/* Summary Cards Grid */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.summary-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 20px 22px;
    position: relative;
    overflow: hidden;
    transition: all var(--transition-normal);
}

.summary-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-glow);
}

.summary-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.summary-card.card-indigo::before { background: var(--gradient-primary); }
.summary-card.card-emerald::before { background: var(--gradient-success); }
.summary-card.card-amber::before { background: linear-gradient(135deg, var(--accent-amber), #D97706); }
.summary-card.card-rose::before { background: var(--gradient-danger); }
.summary-card.card-cyan::before { background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue)); }

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.card-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.card-icon {
    font-size: 1.2rem;
}

.card-values {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.card-value-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-source {
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.card-amount {
    font-size: 0.95rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.card-diff {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.diff-label {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.diff-value {
    font-size: 0.85rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.diff-value.positive { color: var(--accent-emerald); }
.diff-value.negative { color: var(--accent-rose); }
.diff-value.zero { color: var(--text-muted); }

/* Tabs */
.tabs-container {
    padding: 0;
    overflow: hidden;
}

.tabs-nav {
    display: flex;
    border-bottom: 1px solid var(--border-subtle);
    overflow-x: auto;
    scrollbar-width: none;
}

.tabs-nav::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 14px 22px;
    font-family: 'Inter', sans-serif;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition-fast);
    position: relative;
    border-bottom: 2px solid transparent;
}

.tab-btn:hover {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.02);
}

.tab-btn.active {
    color: var(--accent-indigo);
    border-bottom-color: var(--accent-indigo);
}

.tab-icon {
    font-size: 1rem;
}

.tab-content {
    padding: 28px;
    min-height: 200px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Reconciliation Tables */
.recon-section {
    margin-bottom: 32px;
}

.recon-section:last-child {
    margin-bottom: 0;
}

.recon-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.recon-title {
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.recon-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 100px;
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-indigo);
}

.recon-count.success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-emerald);
}

.recon-count.warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-amber);
}

.recon-count.danger {
    background: rgba(244, 63, 94, 0.15);
    color: var(--accent-rose);
}

.recon-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.82rem;
}

.recon-table thead th {
    padding: 10px 14px;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}

.recon-table thead th:first-child {
    border-radius: var(--radius-sm) 0 0 0;
}

.recon-table thead th:last-child {
    border-radius: 0 var(--radius-sm) 0 0;
}

.recon-table tbody tr {
    transition: background var(--transition-fast);
}

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

.recon-table td {
    padding: 11px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    vertical-align: middle;
}

.recon-table td:last-child {
    text-align: right;
}

.recon-table .amount {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 100px;
    letter-spacing: 0.02em;
}

.status-badge.matched {
    background: rgba(16, 185, 129, 0.12);
    color: var(--accent-emerald);
}

.status-badge.mismatch,
.status-badge.amount_mismatch {
    background: rgba(245, 158, 11, 0.12);
    color: var(--accent-amber);
}

.status-badge.ais_only {
    background: rgba(244, 63, 94, 0.12);
    color: var(--accent-rose);
}

.status-badge.zerodha_only {
    background: rgba(59, 130, 246, 0.12);
    color: var(--accent-blue);
}

/* Row highlights */
.row-matched { border-left: 3px solid var(--accent-emerald); }
.row-mismatch { border-left: 3px solid var(--accent-amber); }
.row-missing { border-left: 3px solid var(--accent-rose); }
.row-extra { border-left: 3px solid var(--accent-blue); }

/* Aggregate Row */
.agg-row {
    background: rgba(99, 102, 241, 0.06);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border: 1px solid rgba(99, 102, 241, 0.12);
}

.agg-item {
    text-align: center;
}

.agg-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin-bottom: 4px;
}

.agg-value {
    font-size: 1.1rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.agg-value.ais-color { color: var(--accent-purple); }
.agg-value.zerodha-color { color: var(--accent-emerald); }
.agg-value.diff-color { color: var(--accent-amber); }

/* Info boxes */
.info-box {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.82rem;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.info-box.info {
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.15);
    color: var(--accent-blue);
}

.info-box.warning {
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.15);
    color: var(--accent-amber);
}

.info-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        padding: 12px 14px 40px;
    }

    .upload-grid {
        grid-template-columns: 1fr;
    }

    .upload-card {
        padding: 20px;
    }

    .summary-grid {
        grid-template-columns: 1fr 1fr;
    }

    .meta-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .tabs-nav {
        gap: 0;
    }

    .tab-btn {
        padding: 12px 14px;
        font-size: 0.78rem;
    }

    .tab-content {
        padding: 16px;
    }

    .agg-row {
        flex-wrap: wrap;
        gap: 12px;
    }

    .recon-table {
        display: block;
        overflow-x: auto;
    }
}

@media (max-width: 480px) {
    .summary-grid {
        grid-template-columns: 1fr;
    }

    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

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

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

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.empty-state p {
    font-size: 0.88rem;
}

/* Responsive table container */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
