/* ============================================================================
   CSS CUSTOM PROPERTIES (VARIABLES)
   ============================================================================ */
:root {
    /* Modern Color Palette */
    --primary-color: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #6366f1;
    --secondary-color: #0ea5e9;
    --secondary-dark: #0284c7;
    --secondary-light: #38bdf8;
    --success-color: #10b981;
    --success-dark: #059669;
    --error-color: #ef4444;
    --error-dark: #dc2626;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
    
    /* Accessible Colors (WCAG AA Compliant) */
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    --text-light: #d1d5db;
    --text-white: #ffffff;
    --header-blue: #1e40af;
    
    /* Background Colors */
    --bg-light: #f9fafb;
    --bg-white: #ffffff;
    --bg-gray: #f3f4f6;
    --bg-dark: #1f2937;
    --bg-darker: #111827;
    --surface: #ffffff;
    --surface-hover: #f8fafc;
    
    /* Border Colors */
    --border-light: #e5e7eb;
    --border-medium: #d1d5db;
    --border-dark: #374151;
    --border-focus: #4f46e5;
    
    /* Spacing Scale (rem-based) */
    --spacing-xs: 0.25rem;  /* 4px */
    --spacing-sm: 0.5rem;   /* 8px */
    --spacing-md: 1rem;     /* 16px */
    --spacing-lg: 1.5rem;   /* 24px */
    --spacing-xl: 2rem;     /* 32px */
    --spacing-2xl: 2.5rem;  /* 40px */
    --spacing-3xl: 3rem;    /* 48px */
    
    /* Z-Index Scale */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 9999;
    --z-modal: 10000;
    --z-toast: 10001;
    
    /* Shadows - Enhanced */
    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --shadow-inner: inset 0 2px 4px 0 rgba(0, 0, 0, 0.05);
    
    /* Transitions */
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-full: 9999px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: var(--spacing-lg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-2xl);
    width: 100%;
    max-width: 750px;
    padding: var(--spacing-3xl);
    animation: slideIn 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform, opacity;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

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

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

.container.loaded {
    will-change: auto;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: var(--spacing-3xl);
    padding-bottom: var(--spacing-lg);
    border-bottom: 2px solid var(--border-light);
}

.header h1 {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: var(--spacing-sm);
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.header .subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    letter-spacing: 0.01em;
}

/* Form Sections */
.form-section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    margin-bottom: var(--spacing-xl);
    border: 1px solid var(--border-light);
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-sm);
}

.form-section:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border-medium);
}

.section-header {
    color: var(--primary-color);
    font-weight: 700;
    margin-bottom: var(--spacing-lg);
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    letter-spacing: -0.01em;
}

.section-header i {
    font-size: 1.25rem;
}

/* File Upload */
.file-upload-wrapper {
    position: relative;
}

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

.file-upload-label {
    display: block;
    padding: var(--spacing-3xl);
    border: 2px dashed var(--border-medium);
    border-radius: var(--radius-lg);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    background: var(--bg-light);
    position: relative;
    overflow: hidden;
}

.file-upload-label::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(79, 70, 229, 0.1), transparent);
    transition: left 0.5s;
}

.file-upload-label:hover::before {
    left: 100%;
}

.file-upload-label:hover {
    background: rgba(79, 70, 229, 0.02);
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.file-upload-label:focus-within {
    outline: 3px solid rgba(79, 70, 229, 0.3);
    outline-offset: 2px;
}

.file-upload-label.has-file {
    border-style: solid;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.05) 0%, rgba(67, 56, 202, 0.05) 100%);
    border-color: var(--primary-color);
}

.file-upload-label i {
    font-size: 3.5rem;
    color: var(--primary-light);
    display: block;
    margin-bottom: var(--spacing-md);
    transition: transform var(--transition-normal);
}

.file-upload-label:hover i {
    transform: scale(1.1);
}

.file-upload-label span {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
}

.file-info {
    margin-top: var(--spacing-md);
    font-size: 0.875rem;
    color: var(--text-tertiary);
    font-weight: 500;
}

/* Option Grid */
.option-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
}

.option-group {
    display: flex;
    flex-direction: column;
}

.option-group label {
    font-size: 0.875rem;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
    font-weight: 600;
    letter-spacing: 0.01em;
}

.option-group input,
.option-group select {
    padding: 0.625rem 0.875rem;
    border: 1.5px solid var(--border-light);
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    transition: all var(--transition-fast);
    background: var(--bg-white);
    font-weight: 500;
}

.option-group input:focus,
.option-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
    background: var(--surface);
}

.help-text {
    font-size: 0.8125rem;
    color: var(--text-tertiary);
    margin-top: var(--spacing-xs);
    font-weight: 500;
}

/* Checkboxes */
.checkbox-group {
    display: flex;
    gap: var(--spacing-lg);
    flex-wrap: wrap;
}

.checkbox {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-left: 32px;
}

.checkbox input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.checkmark {
    position: absolute;
    left: 0;
    height: 22px;
    width: 22px;
    background-color: var(--bg-white);
    border: 2px solid var(--border-medium);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.checkbox:hover .checkmark {
    border-color: var(--primary-color);
    background-color: rgba(79, 70, 229, 0.05);
}

.checkbox input:focus ~ .checkmark {
    outline: 3px solid rgba(79, 70, 229, 0.3);
    outline-offset: 2px;
}

.checkbox input:checked ~ .checkmark {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.checkbox input:checked ~ .checkmark:after {
    content: "";
    position: absolute;
    display: block;
    left: 6px;
    top: 2px;
    width: 6px;
    height: 11px;
    border: solid white;
    border-width: 0 2.5px 2.5px 0;
    transform: rotate(45deg);
}

.checkbox span:not(.checkmark) {
    font-size: 0.9375rem;
    color: var(--text-primary);
    font-weight: 500;
}

/* Buttons */
.button-wrapper {
    text-align: center;
    margin-top: var(--spacing-2xl);
}

.convert-button {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--text-white);
    border: none;
    padding: 1rem 2.5rem;
    font-size: 1.0625rem;
    font-weight: 700;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: 0 4px 14px 0 rgba(79, 70, 229, 0.39);
    letter-spacing: 0.01em;
    position: relative;
    overflow: hidden;
}

.convert-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.convert-button:hover::before {
    left: 100%;
}

.convert-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px 0 rgba(79, 70, 229, 0.5);
}

.convert-button:focus,
.convert-button:focus-visible {
    outline: 3px solid rgba(79, 70, 229, 0.5);
    outline-offset: 3px;
}

.convert-button:active {
    transform: translateY(-1px);
}

.convert-button:disabled {
    background: var(--border-medium);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.6;
}

.download-button {
    background: var(--success-color);
    color: var(--text-white);
    border: none;
    padding: 0.875rem 2rem;
    font-size: 0.9375rem;
    font-weight: 700;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-inline-end: var(--spacing-sm);
    box-shadow: 0 4px 14px 0 rgba(16, 185, 129, 0.39);
}

.download-button:hover {
    background: var(--success-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px 0 rgba(16, 185, 129, 0.5);
}

.download-button:focus,
.download-button:focus-visible {
    outline: 3px solid rgba(16, 185, 129, 0.5);
    outline-offset: 2px;
}

.secondary-button {
    background: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    padding: 0.75rem 1.75rem;
    font-size: 0.9375rem;
    font-weight: 700;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.secondary-button:hover {
    background: var(--primary-color);
    color: var(--text-white);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px 0 rgba(79, 70, 229, 0.3);
}

.secondary-button:focus,
.secondary-button:focus-visible {
    outline: 3px solid rgba(79, 70, 229, 0.5);
    outline-offset: 2px;
}

/* Progress Section */
.progress-section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--spacing-2xl);
    margin-top: var(--spacing-xl);
    text-align: center;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
}

.progress-bar-container {
    background: var(--bg-light);
    border-radius: var(--radius-full);
    height: 12px;
    overflow: hidden;
    margin-bottom: var(--spacing-lg);
    box-shadow: var(--shadow-inner);
}

.progress-bar {
    background: linear-gradient(90deg, var(--primary-color), var(--primary-light));
    height: 100%;
    width: 0%;
    border-radius: var(--radius-full);
    transition: width var(--transition-normal);
    animation: pulse 2s ease-in-out infinite, shimmer 2s linear infinite;
    will-change: width, opacity;
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s linear infinite;
}

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

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.85;
    }
}

.status-message {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

/* Result Section */
.result-section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--spacing-2xl);
    margin-top: var(--spacing-xl);
    text-align: center;
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-md);
}

.result-success i {
    font-size: 4rem;
    color: var(--success-color);
    margin-bottom: var(--spacing-lg);
    animation: scaleIn 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    filter: drop-shadow(0 4px 12px rgba(16, 185, 129, 0.3));
}

@keyframes scaleIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.result-success h3 {
    color: var(--text-primary);
    margin-bottom: var(--spacing-lg);
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

#resultDetails {
    background: var(--bg-light);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    margin: var(--spacing-xl) 0;
    text-align: start;
    font-size: 0.9375rem;
    color: var(--text-secondary);
    border: 1px solid var(--border-light);
    font-weight: 600;
}

#resultDetails p {
    margin-bottom: var(--spacing-sm);
}

#resultDetails p:last-child {
    margin-bottom: 0;
}

#resultDetails strong {
    color: var(--text-primary);
    font-weight: 700;
}

/* Error Section */
.error-section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--spacing-2xl);
    margin-top: var(--spacing-xl);
    text-align: center;
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-md);
}

.error-message i {
    font-size: 4rem;
    color: var(--error-color);
    margin-bottom: var(--spacing-lg);
    animation: shake 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    filter: drop-shadow(0 4px 12px rgba(239, 68, 68, 0.3));
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-10px); }
    20%, 40%, 60%, 80% { transform: translateX(10px); }
}

.error-message h3 {
    color: var(--text-primary);
    margin-bottom: var(--spacing-lg);
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.error-message p {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xl);
    font-size: 0.9375rem;
    line-height: 1.6;
    font-weight: 500;
}

.error-main-message {
    font-size: 1.125rem;
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: var(--spacing-lg);
    padding: var(--spacing-md);
    background: rgba(239, 68, 68, 0.05);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--error-color);
}

.error-suggestion {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.1) 0%, rgba(245, 158, 11, 0.1) 100%);
    border: 1.5px solid rgba(251, 191, 36, 0.3);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    margin: var(--spacing-lg) 0;
    text-align: left;
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-md);
}

.error-suggestion i {
    color: #f59e0b;
    font-size: 1.5rem;
    margin: 0;
    flex-shrink: 0;
    animation: none;
    filter: none;
}

.error-suggestion strong {
    color: #d97706;
    display: block;
    margin-bottom: var(--spacing-xs);
    font-weight: 700;
}

.error-suggestion {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    line-height: 1.6;
}

.error-type-badge {
    display: inline-block;
    background: var(--error-color);
    color: var(--text-white);
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: var(--radius-full);
    font-size: 0.8125rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: var(--spacing-md);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.error-technical-details {
    margin-top: var(--spacing-xl);
    padding: var(--spacing-md);
    background: var(--bg-light);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    text-align: left;
}

.error-technical-details summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.875rem;
    padding: var(--spacing-sm);
    user-select: none;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.error-technical-details summary:hover {
    color: var(--text-primary);
}

.error-technical-details summary::marker {
    color: var(--primary-color);
}

.error-technical-details pre {
    margin-top: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    color: var(--text-primary);
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    line-height: 1.5;
}

/* Drag & Drop Overlay */
.drop-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(173, 216, 230, 0.95);
    z-index: var(--z-modal-backdrop);
    display: flex;
    justify-content: center;
    align-items: center;
}

.drop-message {
    text-align: center;
    color: var(--text-white);
}

.drop-message i {
    font-size: 72px;
    margin-bottom: var(--spacing-lg);
}

.drop-message p {
    font-size: 24px;
    font-weight: bold;
}

/* Footer */
.footer {
    text-align: center;
    margin-top: var(--spacing-2xl);
    padding-top: var(--spacing-xl);
    border-top: 2px solid var(--border-light);
}

.footer p {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 20px;
    }
    
    .header h1 {
        font-size: 24px;
    }
    
    .option-grid {
        grid-template-columns: 1fr;
    }
    
    .checkbox-group {
        flex-direction: column;
        gap: 10px;
    }
    
    .convert-button {
        width: 100%;
    }
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--secondary-color);
    border-radius: 50%;
    -webkit-animation: spin 1s linear infinite;
    animation: spin 1s linear infinite;
    vertical-align: middle;
    margin-inline-start: var(--spacing-sm);
}

@-webkit-keyframes spin {
    0% { -webkit-transform: rotate(0deg); transform: rotate(0deg); }
    100% { -webkit-transform: rotate(360deg); transform: rotate(360deg); }
}

@keyframes spin {
    0% { -webkit-transform: rotate(0deg); transform: rotate(0deg); }
    100% { -webkit-transform: rotate(360deg); transform: rotate(360deg); }
}

/* ============================================================================
   NEW FEATURES STYLES
   ============================================================================ */

/* Header Controls */
.header-controls {
    display: flex;
    gap: var(--spacing-sm);
    justify-content: center;
    margin-top: var(--spacing-lg);
    flex-wrap: wrap;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.95);
    border: 1.5px solid rgba(79, 70, 229, 0.2);
    color: var(--primary-color);
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    box-shadow: var(--shadow-sm);
}

.icon-btn:hover {
    background: var(--primary-color);
    color: var(--text-white);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.icon-btn:focus,
.icon-btn:focus-visible {
    outline: 3px solid rgba(79, 70, 229, 0.4);
    outline-offset: 2px;
}

/* Template Controls */
.template-controls {
    display: flex;
    gap: var(--spacing-md);
    margin: var(--spacing-lg) 0;
    align-items: center;
}

.template-select {
    flex: 1;
    padding: 0.625rem 0.875rem;
    border: 1.5px solid var(--border-light);
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    background: var(--bg-white);
    font-weight: 500;
    transition: all var(--transition-fast);
    cursor: pointer;
}

.template-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.template-btn {
    background: var(--primary-color);
    color: var(--text-white);
    border: none;
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.875rem;
    white-space: nowrap;
    transition: all var(--transition-fast);
    font-weight: 600;
    box-shadow: 0 2px 8px 0 rgba(79, 70, 229, 0.2);
}

.template-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px 0 rgba(79, 70, 229, 0.3);
}

.template-btn:focus,
.template-btn:focus-visible {
    outline: 3px solid rgba(79, 70, 229, 0.4);
    outline-offset: 2px;
}

/* Result Actions */
.result-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 20px 0;
}

.preview-button {
    background: var(--error-color);
    color: var(--text-white);
    border: none;
    padding: 12px 30px;
    font-size: 14px;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    transition: all var(--transition-normal);
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.preview-button:hover {
    background: var(--error-dark);
    -webkit-transform: translateY(-2px);
    transform: translateY(-2px);
}

.preview-button:focus,
.preview-button:focus-visible {
    outline: 3px solid var(--border-focus);
    outline-offset: 2px;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: var(--z-modal);
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.7);
    -webkit-animation: fadeIn 0.3s ease;
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex !important;
    justify-content: center;
    align-items: center;
}

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

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

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 900px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-2xl);
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform, opacity;
    border: 1px solid var(--border-light);
}

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

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

.modal-small {
    max-width: 450px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-xl) var(--spacing-2xl);
    border-bottom: 2px solid var(--border-light);
    background: linear-gradient(to bottom, var(--surface), var(--bg-light));
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.modal-header h2 {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 1.375rem;
    margin: 0;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.modal-close {
    background: var(--bg-light);
    border: 1.5px solid var(--border-light);
    font-size: 1.375rem;
    color: var(--text-tertiary);
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--error-color);
    color: var(--text-white);
    border-color: var(--error-color);
    transform: rotate(90deg);
}

.modal-close:focus,
.modal-close:focus-visible {
    outline: 3px solid rgba(239, 68, 68, 0.4);
    outline-offset: 2px;
}

.modal-body {
    padding: var(--spacing-2xl);
    overflow-y: auto;
    flex: 1;
}

/* Preview Table */
.preview-info {
    margin-bottom: 15px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 5px;
    font-size: 14px;
    color: #666;
}

.preview-table-wrapper {
    overflow-x: auto;
    max-height: 500px;
    overflow-y: auto;
}

.preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.preview-table th {
    background: var(--secondary-color);
    color: var(--text-white);
    padding: var(--spacing-sm);
    text-align: start;
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
}

.preview-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #eee;
}

.preview-table tr:hover {
    background: #f8f9fa;
}

.text-preview {
    font-size: 13px;
}

.text-page {
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 5px;
}

.text-page pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    margin-top: 10px;
    color: #666;
}

/* History Styles */
.empty-message {
    text-align: center;
    color: #999;
    padding: 40px;
    font-style: italic;
}

.history-items {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.history-item {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    border-left: 4px solid #ddd;
    transition: all 0.3s ease;
}

.history-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.history-item.success {
    border-left-color: var(--success-color);
}

.history-item.error {
    border-left-color: var(--error-color);
}

.history-item.pending {
    border-left-color: var(--warning-color);
}

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

.history-filename {
    font-weight: bold;
    color: #333;
    font-size: 14px;
}

.history-status {
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 12px;
    background: white;
    color: #666;
}

.history-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #999;
}

.history-download-btn {
    background: var(--secondary-color);
    color: var(--text-white);
    border: none;
    padding: 5px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    transition: all var(--transition-normal);
}

.history-download-btn:hover {
    background: var(--secondary-dark);
}

.history-download-btn:focus,
.history-download-btn:focus-visible {
    outline: 3px solid var(--border-focus);
    outline-offset: 2px;
}

/* Template Modal */
.template-input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-light);
    border-radius: 5px;
    font-size: 14px;
    margin-top: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
}

.template-input:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(173, 216, 230, 0.1);
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal-btn {
    padding: var(--spacing-sm) 24px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all var(--transition-normal);
}

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

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

.modal-btn.primary:focus,
.modal-btn.primary:focus-visible {
    outline: 3px solid var(--border-focus);
    outline-offset: 2px;
}

.modal-btn.secondary {
    background: var(--bg-gray);
    color: var(--text-secondary);
}

.modal-btn.secondary:hover {
    background: #e0e0e0;
}

.modal-btn.secondary:focus,
.modal-btn.secondary:focus-visible {
    outline: 3px solid var(--border-focus);
    outline-offset: 2px;
}

/* Copy button focus states */
.share-btn:focus,
.share-btn:focus-visible {
    outline: 3px solid var(--border-focus);
    outline-offset: 2px;
}

/* Toast Message */
.toast-message {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--success-color);
    color: var(--text-white);
    padding: var(--spacing-md) var(--spacing-xl);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-xl);
    z-index: var(--z-toast);
    animation: slideInRight 0.3s cubic-bezier(0.4, 0, 0.2, 1), slideOutRight 0.3s cubic-bezier(0.4, 0, 0.2, 1) 2.7s;
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    font-weight: 700;
    font-size: 0.9375rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.toast-message.toast-error {
    background: var(--error-color);
}

.toast-message.toast-info {
    background: var(--info-color);
}

.toast-message i {
    font-size: 1.25rem;
}

@-webkit-keyframes slideInRight {
    from {
        -webkit-transform: translateX(100%);
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        -webkit-transform: translateX(0);
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideInRight {
    from {
        -webkit-transform: translateX(100%);
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        -webkit-transform: translateX(0);
        transform: translateX(0);
        opacity: 1;
    }
}

@-webkit-keyframes slideOutRight {
    from {
        -webkit-transform: translateX(0);
        transform: translateX(0);
        opacity: 1;
    }
    to {
        -webkit-transform: translateX(100%);
        transform: translateX(100%);
        opacity: 0;
    }
}

@keyframes slideOutRight {
    from {
        -webkit-transform: translateX(0);
        transform: translateX(0);
        opacity: 1;
    }
    to {
        -webkit-transform: translateX(100%);
        transform: translateX(100%);
        opacity: 0;
    }
}

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

body.dark-mode {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

body.dark-mode .container {
    background: var(--bg-dark);
    border-color: var(--border-dark);
}

body.dark-mode .header h1 {
    background: linear-gradient(135deg, #818cf8 0%, #c084fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

body.dark-mode .header .subtitle {
    color: #94a3b8;
}

body.dark-mode .header {
    border-bottom-color: var(--border-dark);
}

body.dark-mode .form-section {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

body.dark-mode .section-header {
    color: #818cf8;
}

body.dark-mode .file-upload-label {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}

body.dark-mode .file-upload-label:hover {
    background: #1e293b;
    border-color: #6366f1;
}

body.dark-mode .file-upload-label.has-file {
    background: linear-gradient(135deg, rgba(129, 140, 248, 0.1) 0%, rgba(192, 132, 252, 0.1) 100%);
    border-color: #818cf8;
}

body.dark-mode .file-upload-label span {
    color: #94a3b8;
}

body.dark-mode .file-upload-label i {
    color: #818cf8;
}

body.dark-mode .option-group label,
body.dark-mode .checkbox span:not(.checkmark) {
    color: #e2e8f0;
}

body.dark-mode .option-group input,
body.dark-mode .option-group select,
body.dark-mode .template-select {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}

body.dark-mode .option-group input:focus,
body.dark-mode .option-group select:focus,
body.dark-mode .template-select:focus {
    border-color: #818cf8;
    background: #1e293b;
}

body.dark-mode .checkmark {
    background-color: #0f172a;
    border-color: #334155;
}

body.dark-mode .checkbox:hover .checkmark {
    background-color: rgba(129, 140, 248, 0.1);
}

body.dark-mode .progress-section,
body.dark-mode .result-section,
body.dark-mode .error-section {
    background: #1e293b;
    border-color: #334155;
}

body.dark-mode .status-message,
body.dark-mode #resultDetails,
body.dark-mode .error-message p {
    color: #94a3b8;
}

body.dark-mode .modal-content {
    background: #1e293b;
    border-color: #334155;
}

body.dark-mode .modal-header {
    border-bottom-color: #334155;
    background: linear-gradient(to bottom, #1e293b, #0f172a);
}

body.dark-mode .modal-header h2 {
    background: linear-gradient(135deg, #818cf8 0%, #c084fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

body.dark-mode .modal-close {
    background: #0f172a;
    border-color: #334155;
}

body.dark-mode .preview-info,
body.dark-mode .text-page,
body.dark-mode .history-item {
    background: #0f172a;
    color: #e2e8f0;
}

body.dark-mode .preview-table th {
    background: #4f46e5;
}

body.dark-mode .preview-table td {
    border-bottom-color: #334155;
    color: #e2e8f0;
}

body.dark-mode .preview-table tr:hover {
    background: #0f172a;
}

body.dark-mode .template-input {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}

body.dark-mode .history-filename {
    color: #e2e8f0;
}

body.dark-mode .history-status {
    background: #0f172a;
    color: #94a3b8;
}

body.dark-mode .footer {
    border-top-color: #334155;
}

body.dark-mode .footer p {
    background: linear-gradient(135deg, #818cf8 0%, #c084fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

body.dark-mode .icon-btn {
    background: #1e293b;
    border-color: #334155;
    color: #818cf8;
}

body.dark-mode .icon-btn:hover {
    background: #4f46e5;
    border-color: #4f46e5;
    color: var(--text-white);
}

body.dark-mode .error-main-message {
    background: rgba(239, 68, 68, 0.15);
    border-left-color: #ef4444;
    color: #fca5a5;
}

body.dark-mode .error-suggestion {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.15) 0%, rgba(245, 158, 11, 0.15) 100%);
    border-color: rgba(251, 191, 36, 0.4);
}

body.dark-mode .error-suggestion i {
    color: #fbbf24;
}

body.dark-mode .error-suggestion strong {
    color: #fbbf24;
}

body.dark-mode .error-technical-details {
    background: #0f172a;
    border-color: #334155;
}

body.dark-mode .error-technical-details summary {
    color: #94a3b8;
}

body.dark-mode .error-technical-details summary:hover {
    color: #e2e8f0;
}

body.dark-mode .error-technical-details pre {
    background: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}

/* Responsive Updates */
@media (max-width: 768px) {
    .header-controls {
        flex-wrap: wrap;
    }
    
    .template-controls {
        flex-direction: column;
    }
    
    .result-actions {
        flex-direction: column;
    }
    
    .modal-content {
        width: 95%;
        max-height: 90vh;
    }
    
    .modal-header,
    .modal-body {
        padding: 15px;
    }
}

/* ============================================================================
   AUTHENTICATION & CREDITS STYLES
   ============================================================================ */

/* Credits Badge */
.credits-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--text-white);
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--radius-full);
    font-size: 0.9375rem;
    font-weight: 700;
    box-shadow: 0 4px 14px 0 rgba(79, 70, 229, 0.39);
    transition: transform var(--transition-fast);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.credits-badge:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px 0 rgba(79, 70, 229, 0.5);
}

.credits-badge i {
    font-size: 1.125rem;
    color: #fbbf24;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.credits-text {
    font-size: 0.8125rem;
    opacity: 0.95;
    font-weight: 600;
}

/* User Menu */
.user-menu {
    position: relative;
}

.user-dropdown {
    display: none;
    position: absolute;
    top: 110%;
    right: 0;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    min-width: 240px;
    z-index: var(--z-dropdown);
    overflow: hidden;
    border: 1px solid var(--border-light);
}

.user-dropdown.show {
    display: block;
    animation: fadeIn 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.user-email {
    padding: var(--spacing-md) var(--spacing-lg);
    background: linear-gradient(to bottom, var(--surface), var(--bg-light));
    font-size: 0.875rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-light);
    word-break: break-all;
    font-weight: 600;
}

.dropdown-item {
    width: 100%;
    padding: var(--spacing-md) var(--spacing-lg);
    border: none;
    background: var(--surface);
    text-align: start;
    cursor: pointer;
    font-size: 0.9375rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    transition: all var(--transition-fast);
    font-weight: 600;
}

.dropdown-item:hover {
    background: var(--bg-light);
    padding-left: calc(var(--spacing-lg) + 4px);
}

.dropdown-item:focus,
.dropdown-item:focus-visible {
    outline: 2px solid rgba(79, 70, 229, 0.4);
    outline-offset: -2px;
}

.dropdown-item i {
    width: 20px;
    color: var(--primary-color);
    font-size: 1.125rem;
}

/* Login Modal Styles */
.login-message {
    padding: 12px;
    border-radius: 8px;
    margin: 15px 0;
    font-size: 14px;
    line-height: 1.5;
}

.login-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.login-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.login-message i {
    margin-right: 8px;
}

.modal-description {
    color: #666;
    font-size: 14px;
    margin-bottom: 20px;
    line-height: 1.5;
}

/* Login Form Styles */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #333;
    font-size: 14px;
}

.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="text"] {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.error-message {
    padding: 10px;
    background: #fee;
    border: 1px solid #fcc;
    border-radius: 6px;
    font-size: 14px;
    text-align: center;
}

.btn-primary {
    background: -webkit-linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--text-white);
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-primary:hover {
    -webkit-transform: translateY(-2px);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-primary:focus,
.btn-primary:focus-visible {
    outline: 3px solid var(--border-focus);
    outline-offset: 2px;
}

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

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    -webkit-transform: none;
    transform: none;
}

/* Google Sign In Button */
.google-btn {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background: white;
    color: #3c4043;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.2s ease;
    cursor: pointer;
    border: 1px solid #dadce0;
}

.google-btn:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    background: #f8f9fa;
}

.google-btn:focus,
.google-btn:focus-visible {
    outline: 3px solid var(--border-focus);
    outline-offset: 2px;
}

.google-btn:active {
    -webkit-transform: scale(0.98);
    transform: scale(0.98);
}

.google-icon {
    flex-shrink: 0;
}


.modal-note {
    margin-top: 15px;
    padding: 10px;
    background: #e8f4fd;
    border-radius: 6px;
    font-size: 13px;
    color: #0066cc;
    text-align: center;
}

.modal-note i {
    margin-right: 5px;
}

/* Referral Box Styles */
.referral-box {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 10px;
    margin: 20px 0;
}

.referral-box h3 {
    font-size: 16px;
    color: #333;
    margin-bottom: 10px;
}

.referral-box p {
    color: #666;
    font-size: 14px;
    margin-bottom: 15px;
}

.referral-box label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #555;
    margin-bottom: 8px;
}

.referral-link-container {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.referral-link-input {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 13px;
    font-family: monospace;
    background: white;
}

/* Credits Info */
.credits-info {
    margin: 20px 0;
}

.credit-offer {
    background: -webkit-linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--text-white);
    padding: var(--spacing-lg);
    border-radius: 10px;
    text-align: center;
}

.credit-offer i {
    font-size: 32px;
    margin-bottom: 10px;
    display: block;
}

.credit-offer strong {
    display: block;
    font-size: 20px;
    margin-bottom: 8px;
}

.credit-offer p {
    font-size: 14px;
    opacity: 0.95;
}

/* Share Buttons */
.share-buttons {
    display: flex;
    gap: 10px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.share-btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.2s, box-shadow 0.2s;
    min-width: 140px;
}

.share-btn:hover {
    -webkit-transform: translateY(-2px);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.share-btn:focus,
.share-btn:focus-visible {
    outline: 3px solid var(--border-focus);
    outline-offset: 2px;
}

.share-btn.twitter {
    background: #1DA1F2;
    color: white;
}

.share-btn.whatsapp {
    background: #25D366;
    color: white;
}

.share-btn.linkedin {
    background: #0077B5;
    color: white;
}

/* Referral Stats */
.referral-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.stat-card {
    background: -webkit-linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--text-white);
    padding: var(--spacing-lg);
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.2);
}

.stat-card i {
    font-size: 28px;
    margin-bottom: 10px;
    display: block;
    opacity: 0.9;
}

.stat-value {
    font-size: 32px;
    font-weight: bold;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 12px;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Referral List */
.referral-list {
    margin-top: 30px;
}

.referral-list h3 {
    font-size: 16px;
    color: #333;
    margin-bottom: 15px;
}

.referral-items {
    max-height: 300px;
    overflow-y: auto;
}

.referral-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #f9f9f9;
    border-radius: 8px;
    margin-bottom: 10px;
}

.referral-item i {
    color: #667eea;
    font-size: 18px;
}

.referral-item span {
    flex: 1;
    font-size: 14px;
    color: #333;
}

.referral-date {
    font-size: 12px;
    color: #999;
}

.credit-badge {
    background: #4CAF50;
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.no-referrals {
    text-align: center;
    color: #999;
    padding: 30px;
    font-size: 14px;
}

/* Dark Mode Adjustments for Auth Components */
.dark-mode .user-dropdown {
    background: #2c2c2c;
}

.dark-mode .user-email {
    background: #1f1f1f;
    color: #ccc;
    border-bottom-color: #444;
}

.dark-mode .dropdown-item {
    background: #2c2c2c;
    color: #e0e0e0;
}

.dark-mode .dropdown-item:hover {
    background: #3a3a3a;
}

.dark-mode .referral-box {
    background: #2c2c2c;
}

.dark-mode .referral-link-input {
    background: #1f1f1f;
    border-color: #444;
    color: #e0e0e0;
}

.dark-mode .referral-item {
    background: #2c2c2c;
    color: #e0e0e0;
}

.dark-mode .modal-note {
    background: #1f3a52;
    color: #64b5f6;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .credits-badge {
        font-size: 12px;
        padding: 6px 12px;
    }
    
    .share-buttons {
        flex-direction: column;
    }
    
    .share-btn {
        min-width: 100%;
    }
    
    .referral-stats {
        grid-template-columns: 1fr;
    }
    
    .referral-link-container {
        flex-direction: column;
    }
}
/* Profile Modal Styles */
.profile-section {
    margin-bottom: 30px;
}

.profile-section h3 {
    font-size: 16px;
    color: #667eea;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.profile-info {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 15px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #e0e0e0;
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    font-weight: 600;
    color: #555;
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-value {
    color: #333;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-value code {
    background: #667eea;
    color: white;
    padding: 4px 12px;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    letter-spacing: 1px;
}

.copy-btn-small {
    background: none;
    border: none;
    color: #667eea;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.3s;
}

.copy-btn-small:hover {
    background: #667eea;
    color: white;
}

.profile-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
}

.stat-card-small {
    background: -webkit-linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--text-white);
    padding: var(--spacing-md);
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.stat-card-small i {
    font-size: 24px;
    margin-bottom: 8px;
    opacity: 0.9;
}

.stat-card-small .stat-value {
    font-size: 24px;
    font-weight: bold;
    margin: 5px 0;
}

.stat-card-small .stat-label {
    font-size: 12px;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.profile-actions {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

.modal-btn.primary {
    background: -webkit-linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--text-white);
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.modal-btn.primary:hover {
    -webkit-transform: translateY(-2px);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.modal-btn.primary:focus,
.modal-btn.primary:focus-visible {
    outline: 3px solid var(--border-focus);
    outline-offset: 2px;
}

.dark-mode .profile-section h3 {
    color: #8b9cff;
}

.dark-mode .profile-info {
    background: #2c2c2c;
}

.dark-mode .info-row {
    border-bottom-color: #444;
}

.dark-mode .info-label {
    color: #b0b0b0;
}

.dark-mode .info-value {
    color: #e0e0e0;
}

.dark-mode .stat-card-small {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.dark-mode .copy-btn-small {
    color: #8b9cff;
}

.dark-mode .copy-btn-small:hover {
    background: #667eea;
    color: white;
}

/* Pricing Section Styles */
.pricing-section {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 25px;
    margin-top: 25px;
}

.pricing-section h3 {
    color: #667eea;
    margin-bottom: 10px;
    font-size: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.pricing-info {
    color: #666;
    margin-bottom: 20px;
    font-size: 14px;
}

.pricing-plans {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.pricing-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    padding: 20px 15px;
    text-align: center;
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.pricing-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
}

.pricing-card.popular {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.pricing-card.best-value {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.popular-badge {
    position: absolute;
    top: 10px;
    right: -30px;
    background: #ffd700;
    color: #333;
    padding: 3px 35px;
    font-size: 11px;
    font-weight: bold;
    transform: rotate(45deg);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.plan-credits {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 10px;
}

.plan-price {
    font-size: 24px;
    font-weight: bold;
}

.payment-info {
    background: white;
    border-radius: 10px;
    padding: 20px;
    border-left: 4px solid #667eea;
}

.payment-info h4 {
    color: #667eea;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.payment-info ol {
    margin-left: 20px;
    color: #555;
}

.payment-info li {
    margin-bottom: 12px;
    line-height: 1.6;
}

.email-link {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s;
}

.email-link:hover {
    color: #764ba2;
    text-decoration: underline;
}

.upi-id {
    color: #f5576c;
    background: #fff3f3;
    padding: 4px 12px;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    letter-spacing: 0.5px;
}

.copy-upi-btn {
    background: none;
    border: none;
    color: #667eea;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.3s;
    margin-left: 5px;
}

.copy-upi-btn:hover {
    background: #667eea;
    color: white;
}

/* Dark Mode - Pricing */
.dark-mode .pricing-section {
    background: #2c2c2c;
}

.dark-mode .pricing-info {
    color: #b0b0b0;
}

.dark-mode .payment-info {
    background: #1e1e1e;
    border-left-color: #8b9cff;
}

.dark-mode .payment-info h4 {
    color: #8b9cff;
}

.dark-mode .payment-info li {
    color: #b0b0b0;
}

.dark-mode .email-link {
    color: #8b9cff;
}

.dark-mode .email-link:hover {
    color: #a8b6ff;
}

.dark-mode .upi-id {
    background: #3a2a2a;
    color: #ff8ba0;
}

.dark-mode .copy-upi-btn {
    color: #8b9cff;
}

.dark-mode .copy-upi-btn:hover {
    background: #667eea;
    color: white;
}

/* Credit History Styles */
.credit-history-container {
    background: white;
    border-radius: 10px;
    padding: 15px;
    max-height: 400px;
    overflow-y: auto;
}

.credit-history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.credit-history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #667eea;
    transition: all 0.3s;
}

.credit-history-item:hover {
    background: #e9ecef;
    transform: translateX(5px);
}

.credit-history-item.credit-added {
    border-left-color: #4caf50;
}

.credit-history-item.credit-used {
    border-left-color: #f44336;
}

.history-info {
    flex: 1;
}

.history-type {
    font-weight: 600;
    color: #333;
    text-transform: capitalize;
    margin-bottom: 4px;
}

.history-description {
    font-size: 13px;
    color: #666;
}

.history-amount {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.amount-value {
    font-size: 18px;
    font-weight: bold;
}

.amount-value.positive {
    color: #4caf50;
}

.amount-value.negative {
    color: #f44336;
}

.history-date {
    font-size: 11px;
    color: #999;
}

.history-balance {
    font-size: 12px;
    color: #667eea;
    font-weight: 600;
}

.loading-message {
    text-align: center;
    color: #999;
    padding: 20px;
}

.no-history {
    text-align: center;
    color: #999;
    padding: 30px;
}

.no-history i {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.3;
}

/* Dark Mode - Credit History */
.dark-mode .credit-history-container {
    background: #1e1e1e;
}

.dark-mode .credit-history-item {
    background: #2c2c2c;
}

.dark-mode .credit-history-item:hover {
    background: #3a3a3a;
}

.dark-mode .history-type {
    color: #e0e0e0;
}

.dark-mode .history-description {
    color: #b0b0b0;
}

.dark-mode .history-balance {
    color: #8b9cff;
}

/* ============================================================================
   CUSTOM SCROLLBAR STYLING
   ============================================================================ */

/* WebKit Browsers (Chrome, Safari, Edge) */
.modal-body::-webkit-scrollbar,
.preview-table-wrapper::-webkit-scrollbar,
.history-items::-webkit-scrollbar,
.referral-items::-webkit-scrollbar,
.credit-history-list::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.modal-body::-webkit-scrollbar-track,
.preview-table-wrapper::-webkit-scrollbar-track,
.history-items::-webkit-scrollbar-track,
.referral-items::-webkit-scrollbar-track,
.credit-history-list::-webkit-scrollbar-track {
    background: var(--bg-light);
    border-radius: 10px;
}

.modal-body::-webkit-scrollbar-thumb,
.preview-table-wrapper::-webkit-scrollbar-thumb,
.history-items::-webkit-scrollbar-thumb,
.referral-items::-webkit-scrollbar-thumb,
.credit-history-list::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

.modal-body::-webkit-scrollbar-thumb:hover,
.preview-table-wrapper::-webkit-scrollbar-thumb:hover,
.history-items::-webkit-scrollbar-thumb:hover,
.referral-items::-webkit-scrollbar-thumb:hover,
.credit-history-list::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Firefox */
.modal-body,
.preview-table-wrapper,
.history-items,
.referral-items,
.credit-history-list {
    scrollbar-width: thin;
    scrollbar-color: #888 var(--bg-light);
}

/* Dark Mode Scrollbar */
.dark-mode .modal-body::-webkit-scrollbar-track,
.dark-mode .preview-table-wrapper::-webkit-scrollbar-track,
.dark-mode .history-items::-webkit-scrollbar-track,
.dark-mode .referral-items::-webkit-scrollbar-track,
.dark-mode .credit-history-list::-webkit-scrollbar-track {
    background: var(--bg-darker);
}

.dark-mode .modal-body,
.dark-mode .preview-table-wrapper,
.dark-mode .history-items,
.dark-mode .referral-items,
.dark-mode .credit-history-list {
    scrollbar-color: #555 var(--bg-darker);
}

/* ============================================================================
   ACCESSIBILITY MEDIA QUERIES
   ============================================================================ */

/* Reduced Motion - For users with motion sensitivity */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        -webkit-animation-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        -webkit-animation-iteration-count: 1 !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* High Contrast Mode - For users who need higher contrast */
@media (prefers-contrast: high) {
    .convert-button,
    .download-button,
    .secondary-button,
    .preview-button,
    .icon-btn,
    .modal-btn,
    .template-btn,
    .share-btn,
    .btn-primary {
        border: 2px solid currentColor;
    }
    
    .file-upload-label {
        border-width: 3px;
    }
    
    .form-section {
        border-width: 2px;
    }
}

/* Auto Dark Mode Detection - Respects system preference */
@media (prefers-color-scheme: dark) {
    /* Future: Could auto-enable dark mode based on system preference */
    /* Currently users must manually toggle via dark mode button */
    /* Commented out to allow explicit user control */
}

/* ============================================================================
   PRINT STYLES
   ============================================================================ */

@media print {
    /* Remove unnecessary elements */
    .header-controls,
    .convert-button,
    .icon-btn,
    .template-controls,
    .modal,
    .toast-message,
    .drop-overlay,
    .footer,
    .button-wrapper {
        display: none !important;
    }
    
    /* Simplify layout */
    body {
        background: white !important;
        padding: 0;
    }
    
    .container {
        background: white !important;
        box-shadow: none !important;
        max-width: 100% !important;
        padding: var(--spacing-lg) !important;
    }
    
    /* Optimize colors for print */
    .header h1 {
        color: black !important;
    }
    
    .form-section {
        border: 1px solid black !important;
        box-shadow: none !important;
        page-break-inside: avoid;
    }
    
    /* Remove backgrounds to save ink */
    .preview-table th {
        background: white !important;
        color: black !important;
        border: 1px solid black !important;
    }
    
    .preview-table td {
        border: 1px solid black !important;
    }
    
    /* Ensure readable text */
    * {
        color: black !important;
    }
}

/* ============================================================================
   RTL (RIGHT-TO-LEFT) SUPPORT
   ============================================================================ */

/* Auto-detect RTL languages */
[dir="rtl"] .modal-header,
[dir="rtl"] .result-section,
[dir="rtl"] .error-section {
    text-align: start;
}

[dir="rtl"] .history-download-btn,
[dir="rtl"] .download-button {
    margin-inline-end: 0;
    margin-inline-start: var(--spacing-sm);
}

/* ============================================================================
   UTILITY CLASSES FOR FOCUS MANAGEMENT
   ============================================================================ */

/* Skip to main content link for screen readers */
.skip-to-main {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-color);
    color: var(--text-white);
    padding: var(--spacing-sm) var(--spacing-md);
    text-decoration: none;
    z-index: var(--z-toast);
}

.skip-to-main:focus {
    top: 0;
}

/* Visually hidden but accessible to screen readers */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Focus within for complex components */
.form-section:focus-within {
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

/* ============================================================================
   PERFORMANCE OPTIMIZATIONS
   ============================================================================ */

/* GPU Acceleration for animated elements */
.modal.active .modal-content,
.container,
.progress-bar,
.toast-message {
    will-change: transform, opacity;
}

/* Remove will-change after animation completes */
.modal-content.loaded,
.container.loaded,
.toast-message.sent {
    will-change: auto;
}
