/**
 * Theme Variables - Light and Dark Mode
 * CSS Custom Properties for dynamic theming
 */

:root {
    /* Light Theme Colors (Default) */
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --bg-card: #ffffff;
    --bg-hover: #f3f4f6;

    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    --text-inverted: #ffffff;

    --border-color: #e5e7eb;
    --border-hover: #d1d5db;

    --color-primary: #12b4b0;
    --color-primary-hover: #0e9d99;
    --color-primary-light: #d1fae5;

    --color-error: #ef4444;
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-info: #3b82f6;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    --input-bg: #ffffff;
    --input-border: #d1d5db;
    --input-focus-border: #12b4b0;
    --input-text: #111827;

    --dropdown-bg: #ffffff;
    --dropdown-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);

    --modal-overlay: rgba(0, 0, 0, 0.5);
    --modal-bg: #ffffff;

    --code-bg: #f3f4f6;
    --code-text: #1f2937;
}

/* Dark Theme Colors */
.dark-theme {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-card: #1e293b;
    --bg-hover: #334155;

    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    --text-inverted: #0f172a;

    --border-color: #334155;
    --border-hover: #475569;

    --color-primary: #14b8a6;
    --color-primary-hover: #0d9488;
    --color-primary-light: #134e4a;

    --color-error: #f87171;
    --color-success: #34d399;
    --color-warning: #fbbf24;
    --color-info: #60a5fa;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6), 0 10px 10px -5px rgba(0, 0, 0, 0.5);

    --input-bg: #1e293b;
    --input-border: #475569;
    --input-focus-border: #14b8a6;
    --input-text: #f1f5f9;

    --dropdown-bg: #1e293b;
    --dropdown-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.6);

    --modal-overlay: rgba(0, 0, 0, 0.75);
    --modal-bg: #1e293b;

    --code-bg: #0f172a;
    --code-text: #e2e8f0;

    /* Override existing variables from styles.css */
    --color-white: #1e293b;
    --color-dark: #f1f5f9;
    --color-gray-50: #1e293b;
    --color-gray-100: #334155;
    --color-gray-200: #475569;
    --color-gray-300: #64748b;
    --color-gray-400: #94a3b8;
    --color-gray-500: #cbd5e1;
    --color-gray-600: #e2e8f0;
    --color-gray-700: #f1f5f9;
    --color-gray-800: #f8fafc;
}

/* Theme Toggle Button */
#theme-toggle {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

#theme-toggle:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
    transform: scale(1.05);
}

#theme-toggle:active {
    transform: scale(0.95);
}

#theme-toggle svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Smooth transitions for theme changes */
* {
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

/* Override transitions for elements that should be instant */
.no-theme-transition,
.no-theme-transition * {
    transition: none !important;
}

/* Apply theme colors globally */
body {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

/* Dark theme global overrides */
.dark-theme body {
    background: #0f172a !important;
    color: #f1f5f9 !important;
}

.dark-theme h1,
.dark-theme h2,
.dark-theme h3,
.dark-theme h4,
.dark-theme h5,
.dark-theme h6 {
    color: #f1f5f9 !important;
}

.dark-theme p,
.dark-theme span,
.dark-theme div {
    color: inherit;
}

.dark-theme a:not(.btn-primary):not(.btn-signup):not(.btn-login) {
    color: #14b8a6;
}

.dark-theme .header {
    background: #1e293b !important;
    border-bottom-color: #334155 !important;
}

.dark-theme .nav-link {
    color: #cbd5e1 !important;
}

.dark-theme .nav-link:hover {
    color: #14b8a6 !important;
}

/* User menu in dark theme */
.dark-theme .user-menu-trigger {
    color: #f1f5f9 !important;
}

.dark-theme .user-name {
    color: #f1f5f9 !important;
}

.dark-theme .user-avatar {
    background: #334155 !important;
    color: #14b8a6 !important;
}

.dark-theme .chevron-icon {
    color: #cbd5e1 !important;
}

.dark-theme .user-dropdown {
    background: #1e293b !important;
    border-color: #334155 !important;
}

.dark-theme .dropdown-user-name {
    color: #f1f5f9 !important;
}

.dark-theme .dropdown-user-email {
    color: #94a3b8 !important;
}

.dark-theme .dropdown-user-plan {
    color: #ffffff !important;
}

.dark-theme .dropdown-item {
    color: #cbd5e1 !important;
}

.dark-theme .dropdown-item:hover {
    background: #334155 !important;
    color: #14b8a6 !important;
}

.dark-theme .dropdown-divider {
    border-color: #334155 !important;
}

/* Common element styling */
.card,
.plan-card,
.info-card,
.balance-card,
.stat-card,
.transaction-card,
.usage-card {
    background: var(--bg-card);
    border-color: var(--border-color);
}

.card:hover,
.plan-card:hover,
.transaction-card:hover {
    border-color: var(--border-hover);
}

/* Input elements */
input,
textarea,
select {
    background-color: var(--input-bg);
    border-color: var(--input-border);
    color: var(--input-text);
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--input-focus-border);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-tertiary);
}

/* Buttons */
.btn-primary,
.btn-add-balance {
    background: var(--color-primary);
    color: var(--text-inverted);
}

.btn-primary:hover,
.btn-add-balance:hover {
    background: var(--color-primary-hover);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
}

/* Modals */
.modal-overlay {
    background: var(--modal-overlay);
}

.modal,
.modal-content {
    background: var(--modal-bg);
    color: var(--text-primary);
}

/* Dropdowns */
.dropdown-menu {
    background: var(--dropdown-bg);
    box-shadow: var(--dropdown-shadow);
    border-color: var(--border-color);
}

.dropdown-item:hover {
    background: var(--bg-hover);
}

/* Code blocks */
code,
pre {
    background: var(--code-bg);
    color: var(--code-text);
}

/* Tables */
table {
    border-color: var(--border-color);
}

thead {
    background: var(--bg-secondary);
}

tbody tr:hover {
    background: var(--bg-hover);
}

/* Status badges */
.status-badge.completed,
.status-success {
    background: var(--color-success);
    color: var(--text-inverted);
}

.status-badge.pending,
.status-warning {
    background: var(--color-warning);
    color: var(--text-inverted);
}

.status-badge.failed,
.status-error {
    background: var(--color-error);
    color: var(--text-inverted);
}

/* Dark theme specific adjustments */
.dark-theme .gradient-bg {
    opacity: 0.7;
}

.dark-theme img {
    opacity: 0.9;
}

.dark-theme .shadow-sm {
    box-shadow: var(--shadow-sm);
}

.dark-theme .shadow-md {
    box-shadow: var(--shadow-md);
}

.dark-theme .shadow-lg {
    box-shadow: var(--shadow-lg);
}

.dark-theme .shadow-xl {
    box-shadow: var(--shadow-xl);
}

/* Keep footer dark in both themes */
.dark-theme .footer {
    background: #0C2C3D !important;
    color: #ffffff !important;
}

.dark-theme .footer-link {
    color: rgba(255, 255, 255, 0.7) !important;
}

.dark-theme .footer-link:hover {
    color: #14b8a6 !important;
}

.dark-theme .footer-tagline {
    color: rgba(255, 255, 255, 0.7) !important;
}

.dark-theme .footer-title {
    color: #ffffff !important;
}

.dark-theme .footer-bottom {
    color: rgba(255, 255, 255, 0.5) !important;
}

/* Signup page plan selector */
.dark-theme .plan-option {
    background: #1e293b !important;
    border-color: #334155 !important;
}

.dark-theme .plan-option.active {
    border-color: #14b8a6 !important;
}

.dark-theme .plan-option-name {
    color: #f1f5f9 !important;
}

.dark-theme .plan-option-price {
    color: #14b8a6 !important;
}

.dark-theme .plan-option-features span {
    color: #cbd5e1 !important;
}

/* Pay-as-you-go info box in signup */
.dark-theme .signup-form-wrapper > div[style*="background: linear-gradient"] {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%) !important;
    border-color: #334155 !important;
}

.dark-theme .signup-form-wrapper > div[style*="background: linear-gradient"] div[style*="font-weight: 600"] {
    color: #14b8a6 !important;
}

.dark-theme .signup-form-wrapper > div[style*="background: linear-gradient"] div[style*="font-size: 0.875rem"] {
    color: #cbd5e1 !important;
}

.dark-theme .signup-form-wrapper > div[style*="background: linear-gradient"] svg {
    color: #14b8a6 !important;
}

/* Sidebar menu in dark theme */
.dark-theme .sidebar-item {
    color: #cbd5e1 !important;
}

.dark-theme .sidebar-item:hover {
    color: #14b8a6 !important;
}

.dark-theme .sidebar-item.active {
    color: #ffffff !important;
}

/* Verified badge in dark theme */
.dark-theme .badge-verified {
    background: #ffffff !important;
    color: #065f46 !important;
}

/* Smooth theme transitions */
html {
    visibility: visible;
}

/* Pricing packages - keep prices black in dark mode */
.dark-theme #pricing [style*="color: var(--text-primary)"],
.dark-theme #pricing [style*="font-size: 1.25rem"] {
    color: #111827 !important;
}

/* Format tags - keep same colors as light mode in dark mode */
.dark-theme .format-tag,
.dark-theme .formats-list span {
    background: #f3f4f6 !important;
    color: #374151 !important;
    border-color: #e5e7eb !important;
}

/* Formats section - keep same background and colors as light mode */
.dark-theme .formats-section {
    background: linear-gradient(135deg, #0C2C3D 0%, #1a4255 100%) !important;
}

.dark-theme .formats-section .section-title,
.dark-theme .formats-section .section-subtitle {
    color: #ffffff !important;
}

/* Pricing buttons - keep "Get Started" button text white in dark mode */
.dark-theme .pricing-btn-primary {
    color: #ffffff !important;
}

/* Testimonial card - keep same background in dark mode */
.dark-theme .testimonial {
    background: linear-gradient(135deg, #0C2C3D 0%, #1a4255 100%) !important;
    color: #ffffff !important;
}

.dark-theme .testimonial-text {
    color: rgba(255, 255, 255, 0.95) !important;
}

/* Toast notifications - dark mode */
.dark-theme .toast-notification {
    background: #1e293b !important;
    color: #f1f5f9 !important;
    border: 1px solid #334155 !important;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.6), 0 4px 6px -2px rgba(0, 0, 0, 0.5) !important;
}

.dark-theme .toast-message {
    color: #f1f5f9 !important;
}

.dark-theme .toast-close {
    color: #cbd5e1 !important;
}

.dark-theme .toast-close:hover {
    color: #f1f5f9 !important;
}

/* Cookie Consent Banner */
.cookie-consent-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    z-index: 9999;
    display: none;
    animation: slideUp 0.3s ease-out;
}

.cookie-consent-banner.show {
    display: block;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.cookie-consent-content {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.cookie-consent-text {
    flex: 1;
    min-width: 300px;
}

.cookie-consent-text h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: #111827;
    margin-bottom: 0.5rem;
}

.cookie-consent-text p {
    font-size: 0.875rem;
    color: #6b7280;
    line-height: 1.5;
}

.cookie-consent-text a {
    color: #12b4b0;
    text-decoration: underline;
}

.cookie-consent-text a:hover {
    color: #0e9894;
}

.cookie-consent-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.cookie-btn {
    padding: 0.625rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.cookie-btn-accept {
    background: #12b4b0;
    color: #ffffff;
}

.cookie-btn-accept:hover {
    background: #0e9894;
}

.cookie-btn-decline {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
}

.cookie-btn-decline:hover {
    background: #e5e7eb;
}

/* Dark mode for cookie banner */
.dark-theme .cookie-consent-banner {
    background: #1e293b;
    border-top-color: #334155;
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.4);
}

.dark-theme .cookie-consent-text h3 {
    color: #f1f5f9;
}

.dark-theme .cookie-consent-text p {
    color: #cbd5e1;
}

.dark-theme .cookie-consent-text a {
    color: #14b8a6;
}

.dark-theme .cookie-consent-text a:hover {
    color: #0d9488;
}

.dark-theme .cookie-btn-decline {
    background: #334155;
    color: #f1f5f9;
    border-color: #475569;
}

.dark-theme .cookie-btn-decline:hover {
    background: #475569;
}

/* Responsive */
@media (max-width: 768px) {
    .cookie-consent-content {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .cookie-consent-actions {
        width: 100%;
    }

    .cookie-btn {
        flex: 1;
    }
}

/* Stats Banner - Keep light mode background in dark mode */
.dark-theme .stats-banner {
    background: linear-gradient(135deg, #0C2C3D 0%, #1a4255 100%) !important;
    color: #ffffff !important;
}

.dark-theme .stats-banner .stat-value {
    color: #14b8a6 !important;
}

.dark-theme .stats-banner .stat-label {
    color: rgba(255, 255, 255, 0.8) !important;
}

.dark-theme .stats-banner .stat-divider {
    background: rgba(255, 255, 255, 0.2) !important;
}

/* Points Display Dark Mode */
.dark-theme .nav-points-display {
    background: #1e293b !important;
    border-color: #334155 !important;
}

.dark-theme .points-label {
    color: #94a3b8 !important;
}

.dark-theme .points-value {
    color: #14b8a6 !important;
}

.dark-theme .add-points-btn {
    background: #14b8a6 !important;
}

.dark-theme .add-points-btn:hover {
    background: #0d9488 !important;
}

/* Format Selector - Dark Mode */
.dark-theme .format-name {
    color: #f1f5f9 !important;
}

.dark-theme .format-desc {
    color: #cbd5e1 !important;
}

.dark-theme .format-btn.selected .format-name {
    color: #ffffff !important;
}

.dark-theme .format-btn.selected .format-desc {
    color: rgba(255, 255, 255, 0.9) !important;
}

/* Featured OCR Button - Dark Mode */
.dark-theme .format-btn-featured {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%) !important;
    border-color: #14b8a6 !important;
    box-shadow: 0 4px 12px rgba(20, 184, 166, 0.3) !important;
}

.dark-theme .format-btn-featured:hover {
    border-color: #0d9488 !important;
    background: linear-gradient(135deg, #334155 0%, #475569 100%) !important;
    box-shadow: 0 8px 20px rgba(20, 184, 166, 0.4) !important;
}

.dark-theme .format-btn-featured.selected {
    background: linear-gradient(135deg, #14b8a6 0%, #0d9488 100%) !important;
    border-color: #14b8a6 !important;
}

.dark-theme .format-btn-featured .format-name {
    color: #14b8a6 !important;
}

.dark-theme .format-btn-featured .format-desc {
    color: #94a3b8 !important;
}

.dark-theme .format-btn-featured.selected .format-name,
.dark-theme .format-btn-featured.selected .format-desc {
    color: white !important;
}

.dark-theme .format-badge {
    background: linear-gradient(135deg, #a78bfa 0%, #8b5cf6 100%) !important;
}

/* Points Modal - Dark Mode */
.dark-theme #points-modal .modal-container {
    background: #1e293b !important;
}

.dark-theme #points-modal .modal-subtitle {
    color: #f1f5f9 !important;
}

.dark-theme #points-modal .amount-option {
    background: #0f172a !important;
    border-color: #334155 !important;
}

.dark-theme #points-modal .amount-option:hover {
    border-color: #14b8a6 !important;
    background: #1e293b !important;
}

.dark-theme #points-modal .amount-option.active {
    border-color: #14b8a6 !important;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%) !important;
}

/* Keep summary background light in dark mode, but with dark text */
.dark-theme #points-modal .payment-summary {
    background: #f9fafb !important;
    border-color: #e5e7eb !important;
}

.dark-theme #points-modal .summary-title {
    color: #111827 !important;
    border-bottom-color: #e5e7eb !important;
}

.dark-theme #points-modal .summary-item span {
    color: #6b7280 !important;
}

.dark-theme #points-modal .summary-item strong {
    color: #111827 !important;
}

.dark-theme #points-modal .summary-divider {
    background: #e5e7eb !important;
}

.dark-theme #points-modal .modal-close {
    background: #334155 !important;
    color: #cbd5e1 !important;
}

.dark-theme #points-modal .modal-close:hover {
    background: #475569 !important;
    color: #f1f5f9 !important;
}

.dark-theme .payment-method-selector {
    background: #0f172a !important;
}

.dark-theme .payment-method-btn {
    background: #1e293b !important;
    border-color: #334155 !important;
    color: #cbd5e1 !important;
}

.dark-theme .payment-method-btn:hover {
    border-color: #14b8a6 !important;
    background: #334155 !important;
}

.dark-theme .payment-method-btn.active {
    background: #14b8a6 !important;
    border-color: #14b8a6 !important;
    color: white !important;
}

/* ==========================================
   Quality Slider Styles (Light & Dark)
   ========================================== */
input[type="range"].quality-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, #ef4444 0%, #f59e0b 25%, #10b981 50%, #3b82f6 75%, #8b5cf6 100%);
    outline: none;
    opacity: 0.9;
    transition: opacity 0.2s;
}

input[type="range"].quality-slider:hover {
    opacity: 1;
}

/* Webkit (Chrome, Safari, Edge) */
input[type="range"].quality-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ffffff;
    border: 3px solid var(--color-primary, #12b4b0);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.2s;
}

input[type="range"].quality-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}

input[type="range"].quality-slider::-webkit-slider-thumb:active {
    transform: scale(1.05);
}

/* Firefox */
input[type="range"].quality-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ffffff;
    border: 3px solid var(--color-primary, #12b4b0);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.2s;
}

input[type="range"].quality-slider::-moz-range-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}

input[type="range"].quality-slider::-moz-range-thumb:active {
    transform: scale(1.05);
}

/* Firefox track */
input[type="range"].quality-slider::-moz-range-track {
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, #ef4444 0%, #f59e0b 25%, #10b981 50%, #3b82f6 75%, #8b5cf6 100%);
}

/* Dark theme slider thumb */
.dark-theme input[type="range"].quality-slider::-webkit-slider-thumb {
    background: #1e293b;
    border-color: #14b8a6;
}

.dark-theme input[type="range"].quality-slider::-moz-range-thumb {
    background: #1e293b;
    border-color: #14b8a6;
}

/* ==========================================
   Resize Section - Dark Mode Support
   ========================================== */
.dark-theme .resize-input-group input[type="number"] {
    background: var(--input-bg) !important;
    border-color: var(--input-border) !important;
    color: var(--input-text) !important;
}

.dark-theme .resize-input-group input[type="number"]:focus {
    border-color: var(--input-focus-border) !important;
}

.dark-theme .resize-input-group label {
    color: var(--text-secondary) !important;
}

.dark-theme .resize-input-group .unit-label {
    color: var(--text-tertiary) !important;
}

.dark-theme .resize-hint {
    color: var(--text-tertiary) !important;
}

.dark-theme .option-label {
    color: var(--text-primary) !important;
}

/* Quality marks */
.quality-marks {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.dark-theme .quality-marks {
    color: var(--text-tertiary) !important;
}

/* ==========================================
   Format Badges - Dark Mode (for Usage History)
   ========================================== */
.dark-theme .format-badge-table {
    background: linear-gradient(135deg, #1e3a5f 0%, #2d4a6f 100%) !important;
    color: #7dd3fc !important;
    border-color: #3b82f6 !important;
}
