/* PDF to Excel - Styles */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; min-height: 100vh; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f5f7fa; min-height: 100vh; display: flex; flex-direction: column; align-items: center; }

header { width: 100%; background: linear-gradient(135deg, #7c3aed 0%, #5b21b6 100%); padding: 1rem 2rem; display: flex; justify-content: center; box-shadow: 0 4px 20px rgba(124, 58, 237, 0.3); }
.header-content { max-width: 1400px; width: 100%; display: flex; justify-content: space-between; align-items: center; }
.logo { display: flex; align-items: center; gap: 0.75rem; }
.logo img { height: 45px; filter: brightness(0) invert(1); }
.logo-text { font-size: 1.5rem; font-weight: 700; color: white; text-shadow: 0 2px 4px rgba(0,0,0,0.1); }

.header-right { display: flex; align-items: center; gap: 1rem; }

/* Usage info card (below upload section) */
.usage-info-card { 
    margin-top: 1rem; 
    padding: 0.75rem 1rem; 
    background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%); 
    border-radius: 8px; 
    text-align: center;
    border: 1px solid #c4b5fd;
}
.usage-info-card span { 
    font-size: 0.85rem; 
    color: #6d28d9; 
    font-weight: 500; 
}
.usage-info-card.logged-in { 
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%); 
    border-color: #6ee7b7;
}
.usage-info-card.logged-in span { 
    color: #047857; 
}

/* Offline Indicator */
.offline-indicator { position: fixed; bottom: 1rem; left: 1rem; padding: 0.75rem 1rem; border-radius: 8px; font-size: 0.8rem; font-weight: 500; z-index: 1000; display: none; }
.offline-indicator.offline { background: #ef4444; color: white; display: flex; align-items: center; gap: 0.5rem; }
.offline-indicator.ready { background: #10b981; color: white; display: flex; align-items: center; gap: 0.5rem; }

.container { max-width: 1400px; margin: 0 auto; padding: 2rem; }

.card { background: white; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); padding: 1.5rem; margin-bottom: 1.5rem; }
.card-title { font-size: 1rem; font-weight: 600; color: #374151; margin-bottom: 1rem; }

/* Main Layout - 3 columns */
.main-layout { display: grid; grid-template-columns: 280px 1fr 280px; gap: 1.5rem; }

/* Upload */
.upload-area { border: 2px dashed #7c3aed; border-radius: 12px; padding: 1.5rem 1rem; text-align: center; cursor: pointer; transition: all 0.2s; }
.upload-area:hover { background: #f5f3ff; }
.upload-area.disabled { opacity: 0.5; cursor: not-allowed; }
.upload-area.dragover { background: #f5f3ff; border-color: #7c3aed; }
.upload-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.file-input { display: none; }

/* PDF List */
.pdf-list { max-height: 200px; overflow-y: auto; margin-top: 1rem; }
.pdf-item { display: flex; align-items: center; justify-content: space-between; padding: 0.5rem 0.75rem; background: #f9fafb; border-radius: 6px; margin-bottom: 0.5rem; cursor: pointer; border: 2px solid transparent; }
.pdf-item:hover { background: #f5f3ff; }
.pdf-item.active { border-color: #7c3aed; background: #f5f3ff; }
.pdf-item-name { font-size: 0.8rem; color: #374151; font-weight: 500; }
.pdf-item-date { font-size: 0.7rem; color: #9ca3af; }
.pdf-item-delete { background: none; border: none; color: #ef4444; cursor: pointer; font-size: 0.8rem; padding: 0.25rem; }

/* Fields */
.field-list { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 1rem; }
.field-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.75rem; background: #f9fafb; border-radius: 6px; border: 2px solid transparent; }
.field-item.selected { border-color: #7c3aed; background: #f5f3ff; }
.field-item input[type="radio"] { accent-color: #7c3aed; }
.field-item label { flex: 1; font-size: 0.875rem; cursor: pointer; }
.delete-btn { background: none; border: none; color: #9ca3af; cursor: pointer; font-size: 0.8rem; }
.delete-btn:hover { color: #ef4444; }

.add-field { display: flex; gap: 0.5rem; margin-top: 1rem; }
.add-field input { flex: 1; padding: 0.5rem 0.75rem; border: 1px solid #d1d5db; border-radius: 6px; font-size: 0.875rem; }
.add-field input:focus { outline: none; border-color: #7c3aed; }

/* Extracted List */
.extracted-list { margin-top: 1rem; max-height: 150px; overflow-y: auto; }
.extracted-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem; background: #f5f3ff; border-radius: 6px; margin-bottom: 0.5rem; font-size: 0.75rem; }
.field-name { font-weight: 600; color: #7c3aed; }
.field-value { flex: 1; color: #374151; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Preview */
.pdf-preview { min-height: 500px; max-height: 600px; overflow-y: auto; background: #e5e7eb; border-radius: 8px; position: relative; padding: 1rem; }
.pdf-placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 450px; color: #9ca3af; }
.pdf-page-container { position: relative; margin: 0 auto 1rem; display: inline-block; }
.pdf-page-container canvas { display: block; box-shadow: 0 2px 10px rgba(0,0,0,0.2); }
.highlight-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; cursor: crosshair; }
.highlight-box { position: absolute; border-radius: 3px; cursor: pointer; transition: opacity 0.2s; }
.highlight-box.processing { border-style: dashed; animation: pulse 1s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Info Banner */
.info-banner { background: #f5f3ff; border: 1px solid #c4b5fd; border-radius: 6px; padding: 0.5rem 1rem; margin-bottom: 1rem; font-size: 0.8rem; color: #6d28d9; display: none; }
.info-banner.active { display: flex; align-items: center; gap: 0.5rem; }

/* Section separator */
.template-section { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid #e5e7eb; }

/* Intro Section */
.intro-section { background: white; border-radius: 16px; padding: 2rem; margin-bottom: 1.5rem; color: #374151; border: 1px solid #e5e7eb; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.intro-header { display: flex; justify-content: center; align-items: center; cursor: pointer; user-select: none; position: relative; }
.intro-header:hover .intro-title { color: #6d28d9; }
.intro-toggle-icon { position: absolute; right: 0; font-size: 1.25rem; color: #7c3aed; transition: transform 0.3s ease; }
.intro-section.collapsed .intro-toggle-icon { transform: rotate(-90deg); }
.intro-content { overflow: hidden; transition: max-height 0.3s ease, opacity 0.3s ease; }
.intro-section.collapsed .intro-content { max-height: 0; opacity: 0; margin-top: 0; }
.intro-section:not(.collapsed) .intro-content { max-height: 1000px; opacity: 1; margin-top: 1rem; }
.intro-title { font-size: 1.75rem; font-weight: 700; margin-bottom: 0.25rem; text-align: center; color: #7c3aed; transition: color 0.2s; }
.intro-subtitle { font-size: 1.1rem; color: #6b7280; text-align: center; margin-bottom: 0; }
.steps-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-top: 1rem; }
.step-card { background: #f9fafb; border-radius: 12px; padding: 1.5rem 1rem 1.25rem; text-align: center; position: relative; border: 1px solid #e5e7eb; }
.step-number { position: absolute; top: -13px; left: 50%; transform: translateX(-50%); background: #7c3aed; color: white; width: 26px; height: 26px; border-radius: 50%; font-size: 0.85rem; font-weight: 700; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 4px rgba(124, 58, 237, 0.3); }
.step-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.step-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.35rem; color: #374151; }
.step-desc { font-size: 0.9rem; color: #4b5563; line-height: 1.4; }
.step-detail { margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid #e5e7eb; text-align: left; }
.step-detail-item { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; margin-bottom: 0.5rem; color: #374151; }
.step-detail-icon { width: 22px; height: 22px; background: #f5f3ff; border-radius: 4px; display: flex; align-items: center; justify-content: center; font-size: 0.75rem; }
.highlight-demo { display: flex; align-items: center; gap: 0.25rem; margin-top: 0.5rem; }
.highlight-box-demo { flex: 1; height: 14px; background: #f3f4f6; border-radius: 2px; border: 1px dashed #d1d5db; }
.highlight-box-demo.filled { background: rgba(124, 58, 237, 0.3); border-style: solid; border-color: #7c3aed; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 0.75rem 1.5rem; border-radius: 8px; font-weight: 500; font-size: 0.875rem; cursor: pointer; border: none; transition: all 0.2s; }
.btn-primary { background: #7c3aed; color: white; }
.btn-primary:hover { background: #6d28d9; }
.btn-success { background: #10b981; color: white; }
.btn-success:hover { background: #059669; transform: translateY(-2px); }
.btn-success:enabled { animation: glow 2s infinite; }
.btn-outline { background: white; border: 1px solid #d1d5db; color: #374151; }
.btn-outline:hover { background: #f9fafb; }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.75rem; }
.btn-lg { padding: 1rem 2rem; font-size: 1rem; }

@keyframes glow { 
    0%, 100% { box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4); } 
    50% { box-shadow: 0 6px 20px rgba(16, 185, 129, 0.6); } 
}

/* Status */
.status { display: none; padding: 1rem; border-radius: 8px; font-size: 0.875rem; margin-top: 0.75rem; }
.status.success { display: block; background: #d1fae5; color: #065f46; }
.status.error { display: block; background: #fee2e2; color: #991b1b; }

/* OCR Status */
.ocr-status { background: #fef3c7; border: 1px solid #fcd34d; border-radius: 6px; padding: 0.75rem; margin-bottom: 1rem; font-size: 0.875rem; color: #92400e; display: none; }
.ocr-status.active { display: block; }

/* Modal */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); display: none; justify-content: center; align-items: center; z-index: 1000; }
.modal-overlay.active { display: flex; }
.modal { background: white; border-radius: 16px; padding: 2rem; max-width: 500px; width: 90%; }
.modal h2 { margin-bottom: 1.5rem; text-align: center; }

/* Social Buttons */
.social-btn { width: 100%; padding: 0.75rem; border-radius: 8px; font-weight: 500; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 0.5rem; margin-bottom: 0.75rem; transition: all 0.2s; }
.social-btn.google { background: white; border: 1px solid #d1d5db; color: #374151; }
.social-btn.google:hover { background: #f9fafb; }
.social-btn.apple { background: #000; border: none; color: white; }
.social-btn.apple:hover { background: #333; }
.divider { display: flex; align-items: center; margin: 1rem 0; }
.divider::before, .divider::after { content: ''; flex: 1; border-bottom: 1px solid #e5e7eb; }
.divider span { padding: 0 1rem; color: #9ca3af; font-size: 0.875rem; }

/* Password field */
.password-field { position: relative; }
.password-toggle { position: absolute; right: 0.75rem; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; color: #9ca3af; padding: 0.25rem; }
.password-toggle:hover { color: #6b7280; }

/* ============================================
   AUTH MODAL - Premium Design
   ============================================ */

.auth-modal-container {
    display: flex;
    background: white;
    border-radius: 24px;
    overflow: hidden;
    max-width: 900px;
    width: 95%;
    max-height: 90vh;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: authModalSlideIn 0.3s ease-out;
}

@keyframes authModalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Left Side - Branding */
.auth-modal-branding {
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: linear-gradient(135deg, #7c3aed 0%, #5b21b6 50%, #4c1d95 100%);
    padding: 2.5rem;
    width: 380px;
    position: relative;
    overflow: hidden;
}

.auth-branding-content {
    position: relative;
    z-index: 2;
}

.auth-branding-logo {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.auth-branding-title {
    color: white;
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.auth-branding-subtitle {
    color: rgba(255,255,255,0.85);
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 2rem;
}

.auth-features {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-feature-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    background: rgba(255,255,255,0.1);
    padding: 0.875rem 1rem;
    border-radius: 12px;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255,255,255,0.15);
    transition: all 0.2s;
}

.auth-feature-item:hover {
    background: rgba(255,255,255,0.15);
    transform: translateX(5px);
}

.auth-feature-icon {
    font-size: 1.5rem;
    line-height: 1;
}

.auth-feature-title {
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
}

.auth-feature-desc {
    color: rgba(255,255,255,0.7);
    font-size: 0.8rem;
    margin-top: 0.15rem;
}

.auth-branding-decoration {
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    pointer-events: none;
}

/* Right Side - Form */
.auth-modal-form-side {
    flex: 1;
    padding: 2rem 2.5rem;
    overflow-y: auto;
    position: relative;
}

.auth-close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: #f3f4f6;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    font-size: 1rem;
    transition: all 0.2s;
}

.auth-close-btn:hover {
    background: #e5e7eb;
    color: #374151;
}

.auth-form-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.auth-form-header h2 {
    font-size: 1.5rem;
    color: #1f2937;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.auth-form-header p {
    color: #6b7280;
    font-size: 0.9rem;
}

.auth-error-message {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 0.875rem 1rem;
    border-radius: 12px;
    margin-bottom: 1.25rem;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.auth-error-message::before {
    content: "⚠️";
}

/* Input Groups */
.auth-input-group {
    margin-bottom: 1.25rem;
}

.auth-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
}

.auth-label-icon {
    font-size: 1rem;
}

.auth-input-wrapper {
    position: relative;
}

.auth-input {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 0.95rem;
    transition: all 0.2s;
    background: #fafafa;
}

.auth-input:focus {
    outline: none;
    border-color: #7c3aed;
    background: white;
    box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.1);
}

.auth-input::placeholder {
    color: #9ca3af;
}

.auth-input-with-toggle {
    padding-right: 3rem;
}

.auth-password-toggle {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: #9ca3af;
    padding: 0.25rem;
    transition: color 0.2s;
}

.auth-password-toggle:hover {
    color: #7c3aed;
}

.auth-password-hint {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: #9ca3af;
}

.auth-password-hint span {
    background: #f3f4f6;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

/* Remember Me Checkbox */
.auth-remember-me {
    margin-bottom: 1.25rem;
}

.auth-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: #374151;
}

.auth-checkbox {
    display: none;
}

.auth-checkbox-custom {
    width: 20px;
    height: 20px;
    border: 2px solid #d1d5db;
    border-radius: 6px;
    position: relative;
    transition: all 0.2s;
}

.auth-checkbox:checked + .auth-checkbox-custom {
    background: #7c3aed;
    border-color: #7c3aed;
}

.auth-checkbox:checked + .auth-checkbox-custom::after {
    content: "✓";
    color: white;
    font-size: 0.75rem;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Forgot Link */
.auth-forgot-link {
    text-align: right;
    margin-bottom: 1rem;
}

.auth-forgot-link button {
    background: none;
    border: none;
    color: #7c3aed;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: color 0.2s;
}

.auth-forgot-link button:hover {
    color: #5b21b6;
    text-decoration: underline;
}

/* Submit Button */
.auth-submit-btn {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
    box-shadow: 0 4px 14px rgba(124, 58, 237, 0.4);
}

.auth-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.5);
}

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

.auth-submit-icon {
    font-size: 1.1rem;
}

/* Divider */
.auth-divider {
    display: flex;
    align-items: center;
    margin: 1.5rem 0;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid #e5e7eb;
}

.auth-divider span {
    padding: 0 1rem;
    color: #9ca3af;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Social Buttons */
.auth-social-buttons {
    display: flex;
    gap: 0.75rem;
}

.auth-social-btn {
    flex: 1;
    padding: 0.875rem 1rem;
    border-radius: 12px;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.auth-google-btn {
    background: white;
    border: 2px solid #e5e7eb;
    color: #374151;
}

.auth-google-btn:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

.auth-apple-btn {
    background: #000;
    border: 2px solid #000;
    color: white;
}

.auth-apple-btn:hover {
    background: #333;
    border-color: #333;
}

/* Switch Text */
.auth-switch-text {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.9rem;
    color: #6b7280;
}

.auth-switch-text button {
    background: none;
    border: none;
    color: #7c3aed;
    cursor: pointer;
    font-weight: 600;
    margin-left: 0.25rem;
    transition: color 0.2s;
}

.auth-switch-text button:hover {
    color: #5b21b6;
    text-decoration: underline;
}

/* Auth Modal Responsive */
@media (max-width: 768px) {
    .auth-modal-container {
        flex-direction: column;
        max-width: 450px;
    }
    
    .auth-modal-branding {
        display: none;
    }
    
    .auth-modal-form-side {
        padding: 1.5rem;
    }
    
    .auth-form-header h2 {
        font-size: 1.25rem;
    }
    
    .auth-social-buttons {
        flex-direction: column;
    }
}

/* Responsive */
@media (max-width: 1100px) {
    .main-layout { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
    .main-layout { grid-template-columns: 1fr; }
    .container { padding: 1rem; }
    header { padding: 1rem; }
    .header-content { flex-direction: column; gap: 1rem; text-align: center; }
    .header-right { flex-wrap: wrap; justify-content: center; }
    .steps-grid { grid-template-columns: repeat(2, 1fr); }
    .intro-section { padding: 1.5rem 1rem; }
}

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

/* Dashboard Styles */
.dashboard { background: white; border-radius: 16px; padding: 1.5rem; margin-bottom: 1.5rem; border: 1px solid #e5e7eb; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.dashboard-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 2rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.dashboard-welcome h2 { font-size: 1.5rem; color: #374151; margin-bottom: 0.25rem; }
.dashboard-welcome p { color: #6b7280; font-size: 0.9rem; }
.dashboard-stats { display: flex; gap: 1rem; flex-wrap: wrap; }
.stat-card { display: flex; align-items: center; gap: 0.75rem; background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%); padding: 1rem 1.25rem; border-radius: 12px; border: 1px solid #c4b5fd; min-width: 140px; }
.stat-icon { font-size: 2rem; }
.stat-value { font-size: 1.5rem; font-weight: 700; color: #7c3aed; }
.stat-label { font-size: 0.75rem; color: #6d28d9; }
.dashboard-content { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.dashboard-card { background: #f9fafb; border-radius: 12px; padding: 1.25rem; border: 1px solid #e5e7eb; }
.dashboard-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.dashboard-card-header h3 { font-size: 1rem; color: #374151; }

.templates-grid { display: flex; flex-direction: column; gap: 0.75rem; max-height: 300px; overflow-y: auto; }
.template-item { display: flex; justify-content: space-between; align-items: center; background: white; padding: 0.75rem 1rem; border-radius: 8px; border: 1px solid #e5e7eb; }
.template-info { flex: 1; }
.template-name { font-weight: 600; color: #374151; font-size: 0.9rem; }
.template-fields { font-size: 0.75rem; color: #6b7280; margin-top: 0.25rem; }
.template-actions { display: flex; gap: 0.5rem; }
.template-actions button { padding: 0.35rem 0.75rem; font-size: 0.75rem; border-radius: 6px; cursor: pointer; }

.history-list { display: flex; flex-direction: column; gap: 0.75rem; max-height: 300px; overflow-y: auto; }
.history-item { background: white; padding: 0.75rem 1rem; border-radius: 8px; border: 1px solid #e5e7eb; }
.history-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.history-date { font-size: 0.75rem; color: #9ca3af; }
.history-pdfs { font-size: 0.8rem; color: #374151; }
.history-fields { font-size: 0.75rem; color: #6b7280; margin-top: 0.25rem; }
.history-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; }

.empty-state { text-align: center; color: #9ca3af; font-size: 0.85rem; padding: 1.5rem; background: white; border-radius: 8px; border: 1px dashed #d1d5db; }

/* Dashboard Tabs */
.dashboard-tabs { display: flex; gap: 0.5rem; margin-bottom: 1rem; border-bottom: 2px solid #e5e7eb; padding-bottom: 0.5rem; }
.tab-btn { padding: 0.5rem 1rem; background: none; border: none; cursor: pointer; font-size: 0.875rem; color: #6b7280; border-radius: 6px; transition: all 0.2s; }
.tab-btn:hover { background: #f5f3ff; color: #7c3aed; }
.tab-btn.active { background: #7c3aed; color: white; }

@media (max-width: 900px) {
    .dashboard-content { grid-template-columns: 1fr; }
    .dashboard-header { flex-direction: column; gap: 1rem; }
    .dashboard-stats { width: 100%; justify-content: space-between; }
    .stat-card { flex: 1; min-width: auto; }
}

@media (max-width: 600px) {
    .stat-card { flex-direction: column; text-align: center; gap: 0.5rem; padding: 0.75rem; }
    .dashboard-stats { flex-wrap: wrap; }
}

/* Account Settings Styles */
.account-settings { display: flex; flex-direction: column; gap: 1.5rem; }
.settings-section { background: white; padding: 1.25rem; border-radius: 8px; border: 1px solid #e5e7eb; }
.settings-section h4 { font-size: 0.95rem; color: #374151; margin-bottom: 1rem; font-weight: 600; }
.settings-section p { font-size: 0.85rem; color: #6b7280; margin-bottom: 1rem; line-height: 1.5; }

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 500; color: #374151; margin-bottom: 0.35rem; }
.form-group input { width: 100%; padding: 0.6rem 0.85rem; border: 1px solid #d1d5db; border-radius: 6px; font-size: 0.875rem; transition: border-color 0.2s; }
.form-group input:focus { outline: none; border-color: #7c3aed; }
.form-group small { display: block; margin-top: 0.25rem; font-size: 0.75rem; color: #9ca3af; }

.settings-message { margin-top: 1rem; padding: 0.75rem; border-radius: 6px; font-size: 0.85rem; display: none; }
.settings-message.success { display: block; background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.settings-message.error { display: block; background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

.danger-zone { border-color: #fca5a5; background: #fef2f2; }
.danger-zone h4 { color: #dc2626; }

.btn-danger { background: #ef4444; color: white; border: none; padding: 0.6rem 1rem; border-radius: 6px; font-size: 0.875rem; font-weight: 500; cursor: pointer; transition: background 0.2s; }
.btn-danger:hover { background: #dc2626; }

.dashboard-content { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1.5rem; }

@media (max-width: 1100px) {
    .dashboard-content { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
    .dashboard-content { grid-template-columns: 1fr; }
}

/* Delete Account Modal */
.delete-modal { background: white; border-radius: 16px; overflow: hidden; }
.delete-modal-header { text-align: center; padding: 1.5rem 1rem; background: #f3e8ff; }
.delete-modal-icon { font-size: 3rem; margin-bottom: 0.5rem; }
.delete-modal-header h2 { color: #7c3aed; font-size: 1.25rem; margin: 0; }
.delete-modal-body { padding: 1.5rem; text-align: center; }
.delete-modal-footer { display: flex; gap: 0.75rem; padding: 1rem 1.5rem; background: #f9fafb; border-top: 1px solid #e5e7eb; }
.delete-modal-footer .btn { flex: 1; padding: 0.6rem 1rem; border-radius: 8px; font-weight: 500; cursor: pointer; }
.btn-outline { background: white; border: 1px solid #d1d5db; color: #374151; }
.btn-outline:hover { background: #f3f4f6; }
.btn-danger { background: #ef4444; color: white; border: none; }
.btn-danger:hover { background: #dc2626; }

/* Admin Panel Styles */
.admin-messages-list { max-height: 500px; overflow-y: auto; display: flex; flex-direction: column; gap: 1rem; }
.admin-message-item { background: white; border-radius: 8px; padding: 1rem; border: 1px solid #e5e7eb; border-left: 4px solid #9ca3af; }
.admin-message-item.new { border-left-color: #7c3aed; background: #f5f3ff; }
.admin-message-item.read { border-left-color: #3b82f6; }
.admin-message-item.responded { border-left-color: #10b981; }
.admin-message-item.closed { border-left-color: #6b7280; opacity: 0.7; }
.admin-message-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.admin-message-from { font-weight: 600; color: #374151; font-size: 0.9rem; }
.admin-message-date { font-size: 0.75rem; color: #9ca3af; }
.admin-message-subject { font-size: 0.85rem; color: #6b7280; margin-bottom: 0.5rem; }
.admin-message-body { font-size: 0.85rem; color: #374151; padding: 0.75rem; background: #f9fafb; border-radius: 6px; margin-bottom: 0.75rem; }
.admin-message-status { margin-bottom: 0.5rem; }
.admin-message-actions { display: flex; gap: 0.5rem; align-items: center; }
.admin-message-actions select { padding: 0.4rem 0.75rem; border: 1px solid #d1d5db; border-radius: 6px; font-size: 0.8rem; }
.status-badge { display: inline-block; padding: 0.2rem 0.6rem; border-radius: 12px; font-size: 0.7rem; font-weight: 500; text-transform: uppercase; }
.status-badge.new { background: #ede9fe; color: #5b21b6; }
.status-badge.read { background: #dbeafe; color: #1e40af; }
.status-badge.responded { background: #d1fae5; color: #065f46; }
.status-badge.closed { background: #e5e7eb; color: #374151; }
.btn-danger:hover { background: #dc2626; }

/* Admin Dashboard Styles */
.admin-stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.admin-stat-card { background: white; border-radius: 12px; padding: 1.5rem; text-align: center; border: 1px solid #e5e7eb; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
.admin-stat-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.admin-stat-value { font-size: 2rem; font-weight: 700; color: #7c3aed; }
.admin-stat-label { font-size: 0.9rem; color: #6b7280; margin-top: 0.25rem; }
.admin-stat-sub { font-size: 0.75rem; color: #10b981; margin-top: 0.25rem; }

.admin-users-list { display: flex; flex-direction: column; gap: 0.75rem; max-height: 500px; overflow-y: auto; }
.admin-user-item { display: flex; justify-content: space-between; align-items: center; background: white; padding: 1rem; border-radius: 8px; border: 1px solid #e5e7eb; }
.admin-user-info { display: flex; flex-direction: column; gap: 0.25rem; }
.admin-user-email { font-weight: 600; color: #374151; }
.admin-user-name { font-size: 0.85rem; color: #6b7280; }
.admin-user-date { font-size: 0.75rem; color: #9ca3af; }
.admin-user-actions { display: flex; gap: 0.5rem; align-items: center; }
.admin-badge { display: inline-block; padding: 0.2rem 0.5rem; border-radius: 4px; font-size: 0.7rem; font-weight: 600; }
.admin-badge.admin { background: #7c3aed; color: white; }
.admin-badge.user { background: #e5e7eb; color: #6b7280; }
.admin-tab-content { min-height: 200px; }

/* Collapsible Settings Sections */
.settings-section.collapsible { overflow: hidden; }
.collapsible-header { display: flex; justify-content: space-between; align-items: center; cursor: pointer; padding: 0.75rem 1rem; background: white; border-radius: 8px; transition: background 0.2s; user-select: none; }
.collapsible-header:hover { background: #f9fafb; }
.collapsible-header h4 { margin: 0; font-size: 0.95rem; color: #374151; display: flex; align-items: center; gap: 0.5rem; }
.collapse-icon { color: #9ca3af; font-size: 0.75rem; transition: transform 0.3s; }
.collapsible-header.active .collapse-icon { transform: rotate(180deg); }
.collapsible-content { max-height: 0; overflow: hidden; transition: max-height 0.3s ease-out; padding: 0 1rem; }
.collapsible-content.open { max-height: 500px; padding: 1rem; }

/* Danger zone for collapsible */
.settings-section.collapsible.danger-zone .collapsible-header { background: #fef2f2; }
.settings-section.collapsible.danger-zone .collapsible-header h4 { color: #dc2626; }

/* Analytics Dashboard Styles */
.admin-analytics-content { padding: 0.5rem; }
.analytics-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.analytics-stat-card { background: white; border-radius: 10px; padding: 1rem; text-align: center; border: 1px solid #e5e7eb; box-shadow: 0 2px 6px rgba(0,0,0,0.04); }
.analytics-stat-icon { font-size: 1.75rem; margin-bottom: 0.25rem; }
.analytics-stat-value { font-size: 1.5rem; font-weight: 700; color: #6d28d9; }
.analytics-stat-label { font-size: 0.8rem; color: #6b7280; margin-top: 0.1rem; }
.analytics-stat-sub { font-size: 0.7rem; color: #10b981; margin-top: 0.15rem; }

.analytics-chart { display: flex; align-items: flex-end; gap: 4px; height: 150px; background: white; border-radius: 10px; padding: 1rem; border: 1px solid #e5e7eb; margin-top: 0.5rem; }
.chart-bar { flex: 1; background: linear-gradient(to top, #7c3aed, #a78bfa); border-radius: 4px 4px 0 0; min-height: 8px; position: relative; transition: height 0.3s; cursor: pointer; }
.chart-bar:hover { background: linear-gradient(to top, #6d28d9, #7c3aed); }
.chart-label { position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%); font-size: 0.6rem; color: #9ca3af; white-space: nowrap; }

.analytics-events-list { display: flex; flex-direction: column; gap: 0.5rem; max-height: 300px; overflow-y: auto; background: white; border-radius: 10px; padding: 1rem; border: 1px solid #e5e7eb; margin-top: 0.5rem; }
.analytics-event-item { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 0.75rem; background: #f9fafb; border-radius: 6px; }
.event-type-badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 12px; font-size: 0.7rem; font-weight: 500; text-transform: uppercase; }
.event-type-badge.page_view { background: #e0e7ff; color: #3730a3; }
.event-type-badge.signup { background: #d1fae5; color: #065f46; }
.event-type-badge.login { background: #dbeafe; color: #1e40af; }
.event-type-badge.pdf_upload { background: #fef3c7; color: #92400e; }
.event-type-badge.extraction { background: #fce7f3; color: #9d174d; }
.event-type-badge.download { background: #cffafe; color: #0e7490; }
.event-type-badge.contact { background: #ede9fe; color: #5b21b6; }
.event-date { font-size: 0.75rem; color: #9ca3af; }

/* User-deleted message styling for admin view */
.admin-message-item.user-deleted {
    opacity: 0.8;
    border-left: 4px solid #f97316 !important;
    background: #fffbeb;
}
.admin-message-item.user-deleted .admin-message-body {
    background: #fef3c7;
}
.admin-deleted-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    background: #fed7aa;
    color: #c2410c;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-left: 0.5rem;
}

/* Notification badge for tabs */
.notification-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ef4444;
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.4);
    animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* User notification badge in header */
.user-notification-badge {
    color: #fbbf24;
    font-size: 0.65rem;
    animation: glow-pulse 1.5s ease-in-out infinite;
    text-shadow: 0 0 8px rgba(251, 191, 36, 0.8);
}

@keyframes glow-pulse {
    0%, 100% { opacity: 1; text-shadow: 0 0 8px rgba(251, 191, 36, 0.8); }
    50% { opacity: 0.7; text-shadow: 0 0 12px rgba(251, 191, 36, 1); }
}

/* ============================================
   DARK MODE STYLES
   ============================================ */

/* Dark mode color scheme */
:root {
    --bg-primary: #f5f7fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f9fafb;
    --text-primary: #374151;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border-color: #e5e7eb;
    --border-light: #d1d5db;
    --accent-light: #f5f3ff;
    --accent-border: #c4b5fd;
    --shadow-color: rgba(0,0,0,0.1);
}

.dark-mode {
    --bg-primary: #111827;
    --bg-secondary: #1f2937;
    --bg-tertiary: #374151;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;
    --border-color: #374151;
    --border-light: #4b5563;
    --accent-light: #2d2640;
    --accent-border: #5b21b6;
    --shadow-color: rgba(0,0,0,0.3);
}

/* Dark mode body */
.dark-mode body {
    background: var(--bg-primary);
}

/* Dark mode cards */
.dark-mode .card,
.dark-mode .dashboard,
.dark-mode .intro-section,
.dark-mode .modal,
.dark-mode .dashboard-card,
.dark-mode .template-item,
.dark-mode .history-item,
.dark-mode .settings-section,
.dark-mode .admin-message-item,
.dark-mode .admin-user-item,
.dark-mode .analytics-stat-card,
.dark-mode .admin-stat-card {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

/* Dark mode text */
.dark-mode .card-title,
.dark-mode .dashboard-welcome h2,
.dark-mode .dashboard-card-header h3,
.dark-mode .settings-section h4,
.dark-mode .admin-message-from,
.dark-mode .admin-user-email,
.dark-mode .template-name,
.dark-mode .history-pdfs,
.dark-mode .step-title,
.dark-mode .step-desc,
.dark-mode .intro-title {
    color: var(--text-primary);
}

/* Dark mode secondary text */
.dark-mode .dashboard-welcome p,
.dark-mode .template-fields,
.dark-mode .history-fields,
.dark-mode .history-date,
.dark-mode .admin-message-date,
.dark-mode .admin-user-name,
.dark-mode .step-detail-item {
    color: var(--text-secondary);
}

/* Dark mode inputs */
.dark-mode input,
.dark-mode select,
.dark-mode textarea {
    background: var(--bg-tertiary);
    border-color: var(--border-light);
    color: var(--text-primary);
}

.dark-mode input::placeholder,
.dark-mode textarea::placeholder {
    color: var(--text-muted);
}

.dark-mode input:focus,
.dark-mode select:focus,
.dark-mode textarea:focus {
    border-color: #7c3aed;
}

/* Dark mode buttons */
.dark-mode .btn-outline {
    background: var(--bg-tertiary);
    border-color: var(--border-light);
    color: var(--text-primary);
}

.dark-mode .btn-outline:hover {
    background: var(--bg-secondary);
}

/* Dark mode PDF list */
.dark-mode .pdf-item {
    background: var(--bg-tertiary);
}

.dark-mode .pdf-item:hover,
.dark-mode .pdf-item.active {
    background: var(--accent-light);
}

.dark-mode .pdf-item-name {
    color: var(--text-primary);
}

/* Dark mode fields */
.dark-mode .field-item {
    background: var(--bg-tertiary);
}

.dark-mode .field-item.selected {
    background: var(--accent-light);
    border-color: #7c3aed;
}

/* Dark mode extracted items */
.dark-mode .extracted-item {
    background: var(--accent-light);
}

.dark-mode .field-name {
    color: #a78bfa;
}

/* Dark mode upload area */
.dark-mode .upload-area:hover {
    background: var(--accent-light);
}

/* Dark mode usage card */
.dark-mode .usage-info-card {
    background: var(--accent-light);
    border-color: var(--accent-border);
}

.dark-mode .usage-info-card span {
    color: #a78bfa;
}

/* Dark mode stat cards */
.dark-mode .stat-card {
    background: var(--accent-light);
    border-color: var(--accent-border);
}

.dark-mode .stat-value {
    color: #a78bfa;
}

.dark-mode .stat-label {
    color: #c4b5fd;
}

/* Dark mode admin stats */
.dark-mode .admin-stat-value,
.dark-mode .analytics-stat-value {
    color: #a78bfa;
}

/* Dark mode tables/lists */
.dark-mode .templates-grid,
.dark-mode .history-list,
.dark-mode .admin-users-list,
.dark-mode .admin-messages-list {
    background: transparent;
}

/* Dark mode empty states */
.dark-mode .empty-state {
    background: var(--bg-tertiary);
    border-color: var(--border-light);
    color: var(--text-muted);
}

/* Dark mode tabs */
.dark-mode .tab-btn {
    color: var(--text-secondary);
}

.dark-mode .tab-btn:hover {
    background: var(--accent-light);
    color: #a78bfa;
}

/* Dark mode collapsible */
.dark-mode .collapsible-header {
    background: var(--bg-secondary);
}

.dark-mode .collapsible-header:hover {
    background: var(--bg-tertiary);
}

/* Dark mode analytics chart */
.dark-mode .analytics-chart,
.dark-mode .analytics-events-list {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

.dark-mode .analytics-event-item {
    background: var(--bg-tertiary);
}

/* Dark mode modal overlay */
.dark-mode .modal-overlay {
    background: rgba(0, 0, 0, 0.7);
}

/* Dark mode delete modal header */
.dark-mode .delete-modal-header {
    background: var(--accent-light);
}

/* Dark mode password toggle */
.dark-mode .password-toggle {
    color: var(--text-muted);
}

.dark-mode .password-toggle:hover {
    color: var(--text-secondary);
}

/* Dark mode OCR status */
.dark-mode .ocr-status {
    background: #422006;
    border-color: #b45309;
    color: #fcd34d;
}

/* Dark mode info banner */
.dark-mode .info-banner {
    background: var(--accent-light);
    border-color: var(--accent-border);
    color: #c4b5fd;
}

/* Dark mode step cards */
.dark-mode .step-card {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
}

/* Dark mode status messages */
.dark-mode .status.success {
    background: #064e3b;
    color: #6ee7b7;
}

.dark-mode .status.error {
    background: #7f1d1d;
    color: #fca5a5;
}

.dark-mode .settings-message.success {
    background: #064e3b;
    color: #6ee7b7;
    border-color: #047857;
}

.dark-mode .settings-message.error {
    background: #7f1d1d;
    color: #fca5a5;
    border-color: #dc2626;
}

/* Dark mode danger zone */
.dark-mode .danger-zone {
    background: #450a0a;
    border-color: #7f1d1d;
}

.dark-mode .danger-zone h4 {
    color: #f87171;
}

/* Dark mode admin badge */
.dark-mode .admin-badge.user {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

/* Dark mode PDF preview */
.dark-mode .pdf-preview {
    background: var(--bg-tertiary);
}

.dark-mode .pdf-placeholder {
    color: var(--text-muted);
}

/* Dark mode dropdown menus */
.dark-mode #userMenu {
    background: var(--bg-secondary);
    box-shadow: 0 4px 12px var(--shadow-color);
}

/* Dark mode select dropdown options */
.dark-mode select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Transition for smooth mode switching */
body, .card, .dashboard, .intro-section, .modal, input, select, textarea,
.btn, .pdf-item, .field-item, .stat-card, .step-card, .template-item,
.history-item, .admin-message-item, .admin-user-item {
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}
