:root {
    /* Modern Color Palette - Dark Mode (Default) */
    --bg-main: #0f172a;       /* Slate 900 */
    --bg-surface: #1e293b;    /* Slate 800 */
    --bg-input: #334155;      /* Slate 700 */
    --border-color: #475569;  /* Slate 600 */
    
    --primary-accent: #48947a;
    --primary-accent-hover: #5aa88d;
    --primary-accent-rgb: 72, 148, 122;
    
    --text-primary: #f1f5f9;  /* Slate 100 */
    --text-secondary: #94a3b8; /* Slate 400 */
    --text-headings: #ffffff;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-color: rgba(0, 0, 0, 0.3);
    
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
}

body.light-theme {
    --bg-main: #e2e8f0;       /* Slate 200 - Darker background to reduce glare */
    --bg-surface: #f8fafc;    /* Slate 50 - Off-white surface, easier on the eyes */
    --bg-input: #ffffff;      /* Pure white inputs for clear contrast */
    --border-color: #cbd5e1;  /* Slate 300 */
    
    --text-primary: #334155;  /* Slate 700 */
    --text-secondary: #64748b; /* Slate 500 */
    --text-headings: #0f172a; /* Slate 900 */
    
    --shadow-color: rgba(148, 163, 184, 0.2);
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.6;
    margin: 0;
    padding: 40px 20px;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

.container {
    max-width: 700px;
    margin: 0 auto;
    background: var(--bg-surface);
    padding: 40px;
    border-radius: 16px; /* Larger radius for modern look */
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 25px -5px var(--shadow-color), 0 8px 10px -6px var(--shadow-color);
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

/* Header Styling */
header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 24px;
    margin-bottom: 32px;
}

header h1 {
    color: var(--text-headings);
    margin: 0 0 4px 0;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.025em; /* Tighter tracking for headings */
}

header h1 .brand-accent {
    color: var(--primary-accent);
    background: linear-gradient(135deg, var(--primary-accent), #64d2b0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
}

.subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
    font-weight: 400;
}

.controls-container {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Theme Switcher */
.theme-switcher .theme-button {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 42px;
    height: 42px;
    border-radius: 12px; /* Squircle shape */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.theme-switcher .theme-button:hover {
    border-color: var(--primary-accent);
    color: var(--primary-accent);
    background: var(--bg-surface);
    box-shadow: 0 0 0 2px rgba(var(--primary-accent-rgb), 0.2);
}

.theme-switcher .theme-button .fa-sun,
.theme-switcher .theme-button .fa-moon {
    position: absolute;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.light-theme .theme-button .fa-sun { transform: translateY(150%) rotate(90deg); }
.light-theme .theme-button .fa-moon { transform: translateY(0) rotate(0); }
.theme-button .fa-sun { transform: translateY(0) rotate(0); }
.theme-button .fa-moon { transform: translateY(-150%) rotate(-90deg); }

/* Language Selector */
.language-selector {
    display: flex;
    align-items: center;
}

.language-selector label {
    display: none; /* Hide label for cleaner look, rely on icon or context */
}

#language-select {
    padding: 10px 36px 10px 16px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-input);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
}

#language-select:hover {
    border-color: var(--text-secondary);
}

#language-select:focus {
    outline: none;
    border-color: var(--primary-accent);
    box-shadow: 0 0 0 3px rgba(var(--primary-accent-rgb), 0.2);
}

/* Form Styles */
section {
    margin-bottom: 32px;
}

section h2 {
    color: var(--text-headings);
    font-size: 18px;
    font-weight: 600;
    margin-top: 0;
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
}

section h2::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 18px;
    background-color: var(--primary-accent);
    margin-right: 12px;
    border-radius: 2px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

label {
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    display: block;
}

input[type="text"],
textarea,
select {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 15px;
    background-color: var(--bg-input);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

input[type="text"]::placeholder,
textarea::placeholder {
    color: var(--text-secondary);
    opacity: 0.5;
}

input[type="text"]:hover,
textarea:hover {
    border-color: var(--text-secondary);
}

input[type="text"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary-accent);
    background-color: var(--bg-surface);
    box-shadow: 0 0 0 4px rgba(var(--primary-accent-rgb), 0.15);
}

textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.6;
}

/* Email validation styling */
input[type="email"]:invalid:not(:placeholder-shown) {
    border-color: #ff4d4d;
}

input[type="email"]:valid {
    border-color: var(--primary-accent);
}

input[type="email"] {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 15px;
    background-color: var(--bg-input);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

/* File Input Styling */
input[type="file"] {
    padding: 12px;
    width: 100%;
    background-color: var(--bg-input);
    border: 1px dashed var(--border-color);
    border-radius: 10px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

input[type="file"]:hover {
    border-color: var(--primary-accent);
    background-color: rgba(var(--primary-accent-rgb), 0.05);
}

input[type="file"]::file-selector-button {
    margin-right: 16px;
    padding: 8px 16px;
    border-radius: 6px;
    border: none;
    background-color: var(--bg-surface);
    color: var(--text-primary);
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
    box-shadow: var(--shadow-sm);
}

input[type="file"]::file-selector-button:hover {
    background-color: var(--border-color);
}

/* Button Styling */
.button-group {
    display: flex;
    justify-content: flex-end;
    margin-top: 16px;
}

.button {
    background: linear-gradient(135deg, var(--primary-accent), #3a7662);
    color: white;
    border: none;
    padding: 14px 32px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: 0 4px 6px rgba(var(--primary-accent-rgb), 0.25);
    letter-spacing: 0.02em;
}

.button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 12px rgba(var(--primary-accent-rgb), 0.3);
    filter: brightness(1.1);
}

.button:active {
    transform: translateY(0);
}

.button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
    filter: grayscale(0.5);
}

/* Message Container */
#message-container {
    margin-top: 24px;
    padding: 16px 20px;
    border-radius: 10px;
    font-weight: 500;
    animation: slideUp 0.3s ease-out;
    border: 1px solid transparent;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

footer {
    text-align: center;
    margin-top: 40px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

@media (max-width: 600px) {
    body {
        padding: 0;
        /* On mobile, use the surface color for the whole background for an app-like feel */
        background-color: var(--bg-surface); 
    }
    .container {
        padding: 24px 24px 40px 24px; /* Added bottom padding for scrolling */
        border-radius: 0;
        box-shadow: none;
        border: none;
        background: transparent;
        max-width: 100%;
        margin: 0;
    }
    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
        padding-bottom: 20px;
        margin-bottom: 24px;
    }
    .controls-container {
        width: 100%;
        justify-content: space-between;
    }
    
    /* iPhone Optimization: Font size 16px prevents auto-zoom on focus */
    input[type="text"],
    textarea,
    select {
        font-size: 16px; 
        padding: 16px; /* Larger touch area */
    }

    .button {
        width: 100%;
        padding: 16px; /* Larger touch area */
        font-size: 16px;
        margin-bottom: 20px; /* Safe area spacing */
    }

    /* Stack form groups tighter on mobile */
    .form-grid {
        gap: 20px;
        grid-template-columns: 1fr; /* Force single column */
    }
    
    /* Android-specific fixes */
    input[type="file"] {
        /* Android Chrome needs explicit styling */
        -webkit-appearance: none;
        appearance: none;
        font-size: 16px;
        min-height: 50px;
    }
    
    /* Prevent Android tap highlight causing "stuck" appearance */
    button, input, textarea, select {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
    
    /* Fix for Android keyboard pushing content */
    .container {
        min-height: 100vh;
        min-height: -webkit-fill-available;
    }
}

/* Fix for Android Chrome's slow animations */
@media (pointer: coarse) {
    * {
        -webkit-tap-highlight-color: transparent;
    }
    
    .button:active {
        transform: scale(0.98);
    }
}

/* Mobile capture buttons */
.mobile-capture-options {
    display: none; /* Hidden on desktop by default */
}

.capture-btn {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all var(--transition-fast);
}

.capture-btn:hover {
    border-color: var(--primary-accent);
    background: rgba(var(--primary-accent-rgb), 0.1);
}

.capture-btn i {
    font-size: 16px;
}

#file-list {
    font-size: 13px;
    color: var(--text-secondary);
}

#file-list .file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-input);
    border-radius: 6px;
    margin-bottom: 6px;
}

#file-list .file-item .remove-file {
    background: none;
    border: none;
    color: #ff4d4d;
    cursor: pointer;
    padding: 4px 8px;
}

@media (max-width: 600px) {
    .mobile-capture-options {
        display: flex !important; /* Show on mobile */
    }
}