/* 
 * TrioScan AI - Modern, Glassmorphism CSS 
 * Premium Aesthetic, Micro-animations, Dark Mode UI 
 */

 :root {
    --bg-color: transparent;
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(255, 255, 255, 0.5);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    --danger-color: #ef4444;
    --success-color: #10b981;
}

[data-theme="dark"] {
    --bg-color: #0f172a;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-hint: #cbd5e1;
    --accent-color: #60a5fa;
    --accent-hover: #3b82f6;
    --glass-bg: rgba(30, 41, 59, 0.75);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
    position: relative;
}

/* Animated Glowing Orbs Background */
.bg-animated {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    background: #f0f9ff;
    transition: background 0.3s ease;
}

[data-theme="dark"] .bg-animated {
    background: #020617;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.6;
    animation: float 10s infinite alternate ease-in-out;
}

[data-theme="dark"] .orb {
    opacity: 0.3;
}

.orb-1 {
    width: 400px;
    height: 400px;
    background: #3b82f6; /* Blue */
    top: -100px;
    left: -100px;
}

.orb-2 {
    width: 350px;
    height: 350px;
    background: #a855f7; /* Purple */
    bottom: -50px;
    right: -50px;
    animation-delay: -3s;
}

.orb-3 {
    width: 300px;
    height: 300px;
    background: #06b6d4; /* Cyan */
    bottom: 20%;
    left: 20%;
    animation-duration: 12s;
    animation-delay: -6s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(100px, -100px) scale(1.2); }
    66% { transform: translate(-50px, 100px) scale(0.8); }
    100% { transform: translate(0, 0) scale(1); }
}

/* Language Toggle */
.lang-toggle {
    position: absolute;
    top: 1.5rem;
    right: 2rem;
    display: flex;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.25rem;
    border-radius: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    z-index: 100;
}

.lang-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.4rem 0.8rem;
    border-radius: 1.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.lang-btn.active {
    background: var(--accent-color);
    color: white;
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.4);
}

/* Glassmorphism Container */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 1.5rem;
    padding: 2.5rem;
    width: 100%;
    max-width: 600px;
    margin: 4rem auto;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.glass-panel:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.5);
}

/* Typography */
h1 {
    font-size: 2.5rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.05em;
}

p.subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 1rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 600;
    font-size: 1rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    gap: 0.5rem;
    width: 100%;
}

.btn-primary {
    background: var(--accent-color);
    color: white;
    box-shadow: 0 4px 14px 0 rgba(59, 130, 246, 0.39);
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: scale(1.02);
}

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

.btn-google {
    background: white;
    color: #1f2937;
    margin-top: 1rem;
}

.btn-google:hover {
    background: #f3f4f6;
    transform: scale(1.02);
}

.btn-google img {
    width: 20px;
    height: 20px;
}

/* Form Elements */
.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

input, select {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.5);
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.2s;
    outline: none;
    min-height: 44px; /* Minimum touch target size */
}

input:focus, select:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
    background: rgba(255, 255, 255, 0.9);
}

/* Choices.js Custom Overrides */
.choices {
    margin-bottom: 0;
}
.choices__inner {
    border-radius: 0.75rem;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.5);
    min-height: 44px; /* 44px touch target */
    padding: 0.4rem 1rem;
    display: flex;
    align-items: center;
}
[data-theme="dark"] .choices__inner {
    background: rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.1);
}
.choices__list--dropdown {
    border-radius: 0.75rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    z-index: 1000;
}
[data-theme="dark"] .choices__list--dropdown {
    background: #1e293b;
    border-color: rgba(255, 255, 255, 0.1);
}
.choices__item {
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}
[data-theme="dark"] .choices__item--choice {
    color: #e2e8f0;
}

/* Email Pill Button */
.email-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 1rem;
    border-radius: 2rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 44px; /* 44px touch target */
    border: 2px solid #9ca3af;
    background: transparent;
    color: #6b7280;
}

.email-pill.active {
    border-color: #10b981;
    color: #10b981;
    background: rgba(16, 185, 129, 0.1);
}

[data-theme="dark"] .email-pill {
    border-color: #6b7280;
    color: #9ca3af;
}

[data-theme="dark"] .email-pill.active {
    border-color: #34d399;
    color: #34d399;
    background: rgba(52, 211, 153, 0.1);
}

/* Mode Header & Email Switch Row (Always clean 1-line layout on Desktop & Mobile) */
.mode-header {
    display: flex;
    flex-direction: row !important;
    justify-content: space-between;
    align-items: center !important;
    margin-bottom: 0.55rem;
    gap: 0.5rem;
}

.toggle-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(148, 163, 184, 0.12);
    padding: 0.28rem 0.65rem;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.25);
}

.toggle-label-text {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    line-height: 1;
}

/* Quick Upload Actions (Clipboard & Camera 2-column grid) */
.quick-upload-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.55rem;
    margin-bottom: 1.25rem;
}

.quick-action-btn {
    width: 100%;
    padding: 0.5rem 0.6rem;
    font-size: 0.82rem;
    border-radius: 0.65rem;
    border-color: rgba(148, 163, 184, 0.4);
    background: rgba(255, 255, 255, 0.45);
}

[data-theme="dark"] .quick-action-btn {
    background: rgba(30, 41, 59, 0.5);
    border-color: rgba(255, 255, 255, 0.15);
}

/* Selected File Card & 3-Button Row */
.file-info-card {
    margin-bottom: 1.35rem;
    padding: 0.8rem 0.9rem;
    background: rgba(59, 130, 246, 0.06);
    border: 1px solid rgba(59, 130, 246, 0.22);
    border-radius: 0.75rem;
    text-align: center;
}

.file-info-title {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text-primary);
    margin-bottom: 0.6rem;
    word-break: break-word;
}

.file-info-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.45rem;
}

.file-action-chip {
    width: 100%;
    padding: 0.38rem 0.4rem;
    font-size: 0.78rem;
    border-radius: 0.55rem;
    white-space: nowrap;
}



/* File Upload Zone */
.upload-zone {
    border: 2px dashed rgba(0, 0, 0, 0.15);
    border-radius: 1rem;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.5);
    margin-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
}

.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--accent-color);
    background: rgba(59, 130, 246, 0.05);
}

.upload-zone input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.upload-icon {
    font-size: 2.5rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

/* Progress Bar */
.progress-container {
    display: none;
    margin-top: 1.5rem;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: var(--accent-color);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 4px;
    position: relative;
}

/* Micro-animation for active progress */
.progress-fill.active::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.3) 50%, rgba(255,255,255,0) 100%);
    animation: shimmer 1.5s infinite;
}

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

.progress-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
}

/* Validation Popup / Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1000;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 1.5rem;
    padding: 2rem;
    width: 90%;
    max-width: 500px;
    transform: translateY(20px);
    transition: transform 0.3s ease;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-title {
    color: var(--danger-color);
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-body {
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    gap: 1rem;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--text-secondary);
    color: var(--text-primary);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Toasts */
#toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 1rem 1.5rem;
    border-radius: 0.75rem;
    background: var(--glass-bg);
    border-left: 4px solid var(--accent-color);
    backdrop-filter: blur(10px);
    color: var(--text-primary);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transform: translateX(120%);
    transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.toast.show {
    transform: translateX(0);
}

.toast.error {
    border-left-color: var(--danger-color);
}

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

/* Sections */
.auth-section, .app-section {
    display: none;
}

.auth-section.active, .app-section.active {
    display: block;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Utilities */
.hidden { display: none !important; }
.hint-text { color: var(--text-secondary); }
[data-theme="dark"] .hint-text { color: var(--text-hint); }

/* Professional Vector Icon Buttons & History Row */
.icon-svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
    flex-shrink: 0;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-height: 36px;
    padding: 0;
    border-radius: 0.6rem;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(255, 255, 255, 0.55);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    flex-shrink: 0;
}

[data-theme="dark"] .icon-btn {
    background: rgba(30, 41, 59, 0.65);
    border-color: rgba(255, 255, 255, 0.14);
    color: #e2e8f0;
}

.icon-btn:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
    background: rgba(59, 130, 246, 0.1);
    transform: translateY(-1px);
}

.icon-btn.primary-icon {
    background: rgba(59, 130, 246, 0.12);
    border-color: rgba(59, 130, 246, 0.35);
    color: var(--accent-color);
}

.icon-btn.primary-icon:hover {
    background: var(--accent-color);
    color: #ffffff;
}

.history-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.45rem;
    border-radius: 0.65rem;
    background: rgba(255, 255, 255, 0.45);
    border: 1px solid rgba(148, 163, 184, 0.2);
    transition: background 0.2s ease;
}

[data-theme="dark"] .history-row {
    background: rgba(15, 23, 42, 0.45);
    border-color: rgba(255, 255, 255, 0.08);
}

.history-row:hover {
    background: rgba(59, 130, 246, 0.06);
}

.history-file-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.history-file-name {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-file-time {
    font-size: 0.74rem;
    color: var(--text-secondary);
}

.history-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    flex-shrink: 0;
}

.live-edit-textarea {
    width: 100%;
    min-height: 240px;
    max-height: 50vh;
    padding: 0.85rem 0.95rem;
    border-radius: 0.75rem;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(255, 255, 255, 0.85);
    color: var(--text-primary);
    font-size: 0.92rem;
    line-height: 1.6;
    resize: vertical;
    outline: none;
    font-family: inherit;
}

[data-theme="dark"] .live-edit-textarea {
    background: rgba(15, 23, 42, 0.85);
    border-color: rgba(255, 255, 255, 0.15);
    color: #f8fafc;
}

.live-edit-textarea:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* Result Preview Modal Responsive Card & Actions */
.result-preview-card {
    max-width: 780px;
    width: 94%;
    max-height: 92vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    transition: max-width 0.25s ease;
}

.result-modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    align-items: center;
    justify-content: flex-end;
}

.result-secondary-btns {
    display: flex;
    gap: 0.55rem;
    flex-wrap: wrap;
}

.result-modal-actions .btn {
    width: auto;
    padding: 0.6rem 1.05rem;
    font-size: 0.88rem;
}

@media (max-width: 640px) {
    .glass-panel {
        padding: 1.35rem 1.1rem;
        border-radius: 1.15rem;
    }

    .upload-zone {
        padding: 2rem 1rem;
    }

    .result-preview-card {
        width: 96%;
        max-height: 93vh;
        padding: 1.1rem 0.95rem;
        border-radius: 1.15rem;
    }

    .live-edit-textarea {
        min-height: 195px;
        max-height: 40vh;
        font-size: 0.88rem;
        padding: 0.7rem 0.8rem;
    }

    .result-modal-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 0.45rem;
    }

    .result-secondary-btns {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.45rem;
        width: 100%;
    }

    .result-modal-actions .btn {
        width: 100%;
        padding: 0.58rem 0.65rem;
        font-size: 0.82rem;
    }
}
