/* ============================================
   IevScan — Alea Ambiente Inspired Design
   ============================================ */

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

:root {
    --alea-teal: #0A5D66;
    --alea-beige: #C4C1A0;
    --alea-slate: #30373D;
    --alea-white: #FFFFFF;
    
    --bg: #f8f9fa;
    --bg-card: #ffffff;
    --border: #dee2e6;
    --text: #333333;
    --text-muted: #6c757d;
    
    --radius: 4px; /* More institutional/square style */
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --font: 'Titillium Web', sans-serif;
    --transition: all 0.3s ease;
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* --- Header --- */
.alea-header {
    background: var(--alea-white);
    border-bottom: 1px solid var(--border);
    padding: 15px 0;
    width: 100%;
}

.header-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-square {
    width: 40px;
    height: 40px;
    background: var(--alea-teal);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--alea-beige);
    font-weight: 700;
    font-size: 24px;
    border-radius: 4px;
}

.logo-text {
    font-size: 24px;
    font-weight: 700;
    color: var(--alea-teal);
    letter-spacing: -0.5px;
    text-transform: uppercase;
}

.alea-nav {
    background: var(--alea-beige);
    padding: 10px 0;
    width: 100%;
}

.nav-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px;
    color: var(--alea-teal);
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    max-width: 600px;
    margin: 40px auto;
    padding: 0 20px;
    width: 100%;
}

/* --- Big Camera Block --- */
.camera-block {
    background: var(--alea-white);
    border: 2px dashed var(--alea-teal);
    border-radius: 8px;
    aspect-ratio: 3 / 4; /* Vertical */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow);
    max-width: 320px;
    margin: 0 auto;
}

.object-name-overlay {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    background: rgba(10, 93, 102, 0.85);
    color: white;
    padding: 10px 15px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 18px;
    text-align: center;
    z-index: 20;
    display: none;
}

.camera-block.has-result .object-name-overlay {
    display: block;
    animation: slideDown 0.4s ease;
}

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

.camera-block:hover {
    background: #f0f7f8;
    border-style: solid;
}

#preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    padding: 20px;
}

.camera-block svg {
    width: 64px;
    height: 64px;
    color: var(--alea-teal);
    margin-bottom: 0; /* Managed by gap */
}

.camera-block span {
    font-size: 16px;
    font-weight: 600;
    color: var(--alea-teal);
    text-align: center;
    max-width: 200px;
}

.camera-block video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 5;
    display: none;
}

.camera-block video.visible { display: block; }

/* --- Capture Bar (visible when camera active) --- */
.capture-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(10, 93, 102, 0.9);
    padding: 15px;
    display: flex;
    justify-content: space-around;
    z-index: 10;
    display: none;
}

.camera-active .capture-overlay { display: flex; }

/* --- Upload Button (Smaller) --- */
.upload-container {
    margin-top: 20px;
    text-align: center;
}

.btn-upload-small {
    background: none;
    border: 1px solid var(--alea-teal);
    color: var(--alea-teal);
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-upload-small:hover {
    background: var(--alea-teal);
    color: white;
}

/* --- Card Results --- */
.result-cards-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    margin-top: 30px;
}

.result-card {
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.05), 0 8px 10px -6px rgba(0,0,0,0.01);
    overflow: hidden;
    border: 1px solid #f4f4f5;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.result-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
}

.card-header-accent {
    height: 4px;
    background: var(--alea-teal);
    width: 100%;
}

.card-content {
    padding: 24px;
}

.category-badge {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 20px;
    background: #f8f9fa;
    color: var(--alea-teal);
    font-weight: 700;
    font-size: 16px;
    border-radius: 4px;
    text-transform: uppercase;
    border: 1px solid #ddd;
}

/* Custom class for Alea-style square icons */
.alea-category-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    color: white;
    font-size: 20px;
    font-weight: 700;
}

.result-card-main {
    transition: background-color 0.3s ease;
    border: none;
}

.secondary-card {
    border: 1px solid #f4f4f5;
    background: white;
}

.icon-box {
    padding: 12px;
    border-radius: 14px;
    display: flex;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

/* --- Footer --- */
.alea-footer {
    background: var(--alea-slate);
    color: white;
    padding: 40px 0 20px;
    margin-top: 60px;
}

.footer-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px;
}

.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 30px;
    margin-bottom: 40px;
}

.footer-col h4 {
    color: var(--alea-beige);
    font-size: 16px;
    margin-bottom: 15px;
    text-transform: uppercase;
}

.footer-col p, .footer-col ul {
    font-size: 13px;
    color: #cbd5e1;
    list-style: none;
}

.footer-bottom {
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 20px;
    text-align: center;
    font-size: 12px;
    color: #94a3b8;
}

/* --- Loading Spinner --- */
.loading-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(10, 93, 102, 0.1);
    border-top-color: var(--alea-teal);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* --- Utils --- */
[hidden] { display: none !important; }

#file-input { display: none; }

.btn-action {
    padding: 8px 20px;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    border: none;
}

.btn-capture { background: var(--alea-beige); color: var(--alea-teal); }
.btn-cancel { background: white; color: var(--text); border: 1px solid var(--border); }

/* --- Custom Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    animation: fadeIn 0.3s forwards;
}

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

.modal-content {
    background: white;
    width: 100%;
    max-width: 400px;
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
    overflow: hidden;
    transform: translateY(20px);
    animation: slideUp 0.3s forwards;
}

@keyframes slideUp { to { transform: translateY(0); } }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.btn-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

.modal-body {
    padding: 24px;
}

.alea-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.alea-input:focus {
    border-color: var(--alea-teal);
}

.modal-footer {
    padding: 16px 24px;
    background: #f8f9fa;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    border-top: 1px solid var(--border);
}

#btn-confirm-modal {
    border-radius: 8px;
    padding: 10px 20px;
}
#btn-cancel-modal {
    border-radius: 8px;
    padding: 10px 20px;
}