@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #6366f1; /* Indigo */
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --secondary: #10b981; /* Emerald */
    --accent: #f43f5e; /* Rose */
    
    --bg-main: #f8fafc;
    --surface: rgba(255, 255, 255, 0.7);
    --surface-solid: #ffffff;
    
    --text-main: #0f172a;
    --text-muted: #64748b;
    
    --border: rgba(226, 232, 240, 0.8);
    --border-highlight: rgba(99, 102, 241, 0.2);
    
    --shadow-soft: 0 4px 20px -2px rgba(0, 0, 0, 0.05);
    --shadow-heavy: 0 20px 40px -10px rgba(0, 0, 0, 0.1);
    
    --radius-sm: 0.75rem;
    --radius-lg: 1.5rem;
    
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-main);
    background-image: 
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.1) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(16, 185, 129, 0.05) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(244, 63, 94, 0.05) 0px, transparent 50%),
        radial-gradient(at 0% 100%, rgba(99, 102, 241, 0.05) 0px, transparent 50%);
    color: var(--text-main);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Background mesh animation */
body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: -1;
    background: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    opacity: 0.02;
    pointer-events: none;
}

.app-header {
    padding: 4rem 1rem 3rem 1rem;
    text-align: center;
    max-width: 800px;
    margin: 0 auto;
}

.header-container h1 {
    font-size: 3.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    letter-spacing: -0.02em;
    animation: slideDown 0.8s var(--transition-slow);
}

.header-container p {
    color: var(--text-muted);
    font-size: 1.25rem;
    font-weight: 400;
    max-width: 600px;
    margin: 0 auto;
    animation: fadeIn 1s var(--transition-slow) 0.2s both;
}

.app-main {
    max-width: 1100px;
    margin: 0 auto 5rem auto;
    padding: 0 1.5rem;
}

/* Tabs Navigation */
.tabs {
    display: flex;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(8px);
    padding: 0.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    gap: 0.5rem;
    margin-bottom: 3rem;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
    box-shadow: var(--shadow-soft);
    animation: fadeIn 1s var(--transition-slow) 0.4s both;
}

.tab-btn {
    background: transparent;
    border: none;
    padding: 0.75rem 1.75rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    border-radius: calc(var(--radius-lg) - 0.25rem);
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.tab-btn:hover {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.tab-btn i {
    font-size: 1.25rem;
}

.tab-btn.active {
    background: var(--surface-solid);
    color: var(--primary);
    box-shadow: var(--shadow-soft), 0 0 0 1px var(--border-highlight);
}

/* Tab Content */
.tab-content {
    display: none;
    animation: tabEnter 0.5s var(--transition-slow);
}

.tab-content.active {
    display: block;
}

@keyframes tabEnter {
    from { opacity: 0; transform: translateY(20px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-30px); }
    to { opacity: 1; transform: translateY(0); }
}

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

/* Glass Card Design */
.glass-card {
    background: var(--surface);
    backdrop-filter: blur(24px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 3rem;
    box-shadow: var(--shadow-heavy);
    position: relative;
    overflow: hidden;
}

.glass-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    opacity: 0.8;
}

.glass-card h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-main);
    letter-spacing: -0.01em;
}

.glass-card > p {
    font-size: 1.1rem;
    margin-bottom: 2.5rem;
}

/* Step Card Styles */
.step-card {
    background: var(--surface-solid);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 2rem;
    margin-bottom: 2rem;
    transition: var(--transition-fast);
    position: relative;
}

.step-card:hover {
    box-shadow: var(--shadow-soft);
    border-color: var(--primary-light);
}

.step-card h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Forms & Inputs */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    padding-left: 0.25rem;
}

input[type="text"], input[type="number"], textarea {
    padding: 1rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition-fast);
    background: #ffffff;
    color: var(--text-main);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

input:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

/* Buttons Styling */
.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: var(--transition-fast);
    box-shadow: 0 8px 20px -6px rgba(99, 102, 241, 0.5);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 25px -8px rgba(99, 102, 241, 0.6);
}

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

.btn-secondary {
    background: var(--bg-main);
    color: var(--primary);
    border: 2px solid var(--primary-light);
    padding: 0.9rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-fast);
}

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

/* Gabarito Modes */
.gabarito-mode {
    display: none;
    margin-bottom: 1.5rem;
    animation: fadeIn 0.3s ease;
}

.gabarito-mode.active {
    display: block;
}

/* Grid Inputs for Answer Key */
.grid-inputs {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.grid-inputs .input-group label {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.grid-inputs input {
    text-align: center;
    padding: 0.75rem;
    font-weight: 700;
    color: var(--primary);
    border-radius: 12px;
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--primary-light);
    background: rgba(99, 102, 241, 0.02);
    border-radius: var(--radius-sm);
    padding: 3rem 2rem 2rem;
    text-align: center;
    margin-bottom: 2rem;
    transition: var(--transition-fast);
    cursor: pointer;
    position: relative;
}

.upload-area:hover,
.upload-area.drag-over {
    background: rgba(99, 102, 241, 0.07);
    border-color: var(--primary);
    border-style: solid;
}

.upload-area.has-files {
    padding-bottom: 1.5rem;
    border-color: var(--secondary);
    background: rgba(16, 185, 129, 0.03);
}

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

.upload-prompt {
    pointer-events: none;
}

.upload-prompt i {
    font-size: 3rem;
    color: var(--primary-light);
    display: block;
    margin-bottom: 0.75rem;
}

.upload-prompt p {
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.25rem;
}

.upload-prompt span {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* File list shown after selection */
.file-list {
    margin-top: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    pointer-events: none;
}

.file-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: white;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.35rem 0.85rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-main);
    box-shadow: var(--shadow-soft);
    animation: fadeIn 0.25s ease;
}

.file-item i {
    color: var(--secondary);
    font-size: 1rem;
}

.file-item .file-size {
    color: var(--text-muted);
    font-weight: 400;
}

.file-count-badge {
    display: block;
    margin-top: 1rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--secondary);
}

/* Feedback & Progress */
.feedback-msg {
    margin-top: 1.5rem;
    padding: 1.25rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    display: none;
    animation: fadeIn 0.3s ease;
}

.feedback-msg.success {
    background: rgba(16, 185, 129, 0.1);
    color: #065f46;
    border: 1px solid rgba(16, 185, 129, 0.2);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.feedback-msg.error {
    background: rgba(244, 63, 94, 0.1);
    color: #9f1239;
    border: 1px solid rgba(244, 63, 94, 0.2);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Custom OpenCV Loading Overlay */
#cv-loading-overlay {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
}

#cv-loading-overlay .spinner {
    width: 60px;
    height: 60px;
    border-width: 4px;
    border-top-color: var(--primary);
}

/* Download Actions - hidden by default, shown via JS after processing */
#download-actions {
    display: none;
    grid-template-columns: 1fr;
    gap: 1rem;
}

#download-actions.visible {
    display: grid;
}

@media (min-width: 768px) {
    #download-actions.visible {
        grid-template-columns: repeat(2, 1fr);
    }
    #download-actions.visible #btn-download-relatorio { grid-column: span 2; }
}

/* Footer Overhaul */
.app-footer {
    background: var(--surface-solid);
    border-top: 1px solid var(--border);
    padding: 5rem 1rem;
    margin-top: 5rem;
}

.footer-content {
    max-width: 1100px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 4rem;
    align-items: start;
}

.footer-info h4 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    font-weight: 700;
}

.footer-info p {
    margin-bottom: 1rem;
    color: var(--text-muted);
}

.footer-info a {
    color: var(--primary);
    font-weight: 600;
    transition: var(--transition-fast);
    text-decoration: none;
}

.footer-info a:hover {
    color: var(--primary-dark);
}

.footer-donate {
    background: var(--bg-main);
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.pix-qrcode {
    width: 180px;
    height: 180px;
    margin-top: 1.5rem;
    border-radius: 20px;
    box-shadow: var(--shadow-soft);
}

/* Animations */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.spinner {
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

#loading-overlay {
    background: var(--surface-solid);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 3rem;
    box-shadow: var(--shadow-heavy);
}

#loading-text {
    font-weight: 600;
    color: var(--primary);
    margin-top: 1rem;
    font-size: 1.1rem;
}

#progress-container {
    height: 10px;
    background: #eef2ff;
    border-radius: 20px;
    margin-top: 2rem;
}

#progress-bar {
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 20px;
    box-shadow: 0 2px 10px rgba(99, 102, 241, 0.3);
}

/* Decorative Background Blobs */
.bg-blobs {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: -1;
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.3;
    animation: blobMove 20s infinite alternate ease-in-out;
}

.blob-1 {
    width: 400px; height: 400px;
    background: var(--primary);
    top: -100px; left: -100px;
}

.blob-2 {
    width: 300px; height: 300px;
    background: var(--secondary);
    top: 20%; right: -50px;
    animation-delay: -5s;
}

.blob-3 {
    width: 500px; height: 500px;
    background: var(--accent);
    bottom: -100px; left: 30%;
    animation-delay: -10s;
}

@keyframes blobMove {
    from { transform: translate(0, 0) rotate(0deg); }
    to { transform: translate(100px, 100px) rotate(360deg); }
}

/* Info Alert */
.info-alert {
    background: rgba(99, 102, 241, 0.05);
    border-left: 4px solid var(--primary);
    padding: 1.25rem;
    border-radius: 0 8px 8px 0;
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1.5rem;
}

.info-alert i {
    font-size: 1.5rem;
    color: var(--primary);
}

.info-alert p {
    font-size: 0.95rem;
    color: var(--text-main);
    margin: 0;
}

/* Radio Custom */
.radio-group input[type="radio"] {
    display: none;
}

.radio-custom {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-radius: 50%;
    display: inline-block;
    position: relative;
    transition: var(--transition-fast);
    vertical-align: middle;
    margin-right: 0.5rem;
}

input[type="radio"]:checked + .radio-custom {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.hidden {
    display: none !important;
}

input[type="radio"]:checked + .radio-custom::after {
    content: '';
    width: 10px;
    height: 10px;
    background: var(--primary);
    border-radius: 50%;
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
}
