/* ===== Global Styles ===== */
:root {
    --primary-gradient: linear-gradient(135deg, #1a73e8 0%, #0d47a1 100%);
    --card-radius: 12px;
    --transition-speed: 0.3s;
}

* {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
    background: #f0f4f8;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== Navbar ===== */
.bg-gradient-primary {
    background: var(--primary-gradient) !important;
}

/* ===== Cards ===== */
.card-glass {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: var(--card-radius);
}

/* ===== Input Styles ===== */
.form-control:focus,
.form-select:focus {
    border-color: #1a73e8;
    box-shadow: 0 0 0 0.2rem rgba(26, 115, 232, 0.15);
}

.form-control-lg {
    font-size: 1.25rem;
    font-weight: 500;
}

#numberInput {
    letter-spacing: 1px;
}

/* ===== Convert Button ===== */
.btn-convert {
    background: var(--primary-gradient);
    border: none;
    border-radius: 8px;
    font-weight: 600;
    letter-spacing: 0.5px;
    transition: all var(--transition-speed) ease;
    box-shadow: 0 4px 15px rgba(26, 115, 232, 0.3);
}

.btn-convert:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(26, 115, 232, 0.4);
}

.btn-convert:active {
    transform: translateY(0);
}

/* ===== Divider ===== */
.divider-with-text {
    display: flex;
    align-items: center;
    text-align: center;
}

.divider-with-text::before,
.divider-with-text::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid #dee2e6;
}

.divider-with-text span {
    padding: 0 1rem;
    color: #6c757d;
    font-size: 0.85rem;
    font-weight: 500;
}

/* ===== Image Preview ===== */
.image-preview-wrapper {
    position: relative;
    display: inline-block;
    max-width: 100%;
}

.image-preview-wrapper img {
    max-height: 200px;
    border: 2px solid #dee2e6;
}

/* ===== Result Cards ===== */
.result-card {
    border-radius: var(--card-radius);
    overflow: hidden;
    transition: all var(--transition-speed) ease;
}

.result-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1) !important;
}

.result-card .card-header {
    font-weight: 600;
    padding: 0.75rem 1rem;
    border-bottom: none;
}

.result-card .card-body {
    padding: 1rem 1.25rem;
}

.result-text {
    font-size: 1.05rem;
    line-height: 1.6;
    margin: 0;
    word-wrap: break-word;
}

.flag-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 20px;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 700;
    color: #fff;
    margin-right: 8px;
    letter-spacing: 0.5px;
}

/* ===== Language-specific Header Colors ===== */
.result-header-en {
    background: linear-gradient(135deg, #1a237e, #283593);
    color: #fff;
}
.result-header-en .flag-icon { background: #c62828; }

.result-header-th {
    background: linear-gradient(135deg, #0d47a1, #1565c0);
    color: #fff;
}
.result-header-th .flag-icon { background: #e53935; }

.result-header-cn {
    background: linear-gradient(135deg, #b71c1c, #c62828);
    color: #fff;
}
.result-header-cn .flag-icon { background: #d32f2f; }

.result-header-mm {
    background: linear-gradient(135deg, #1b5e20, #2e7d32);
    color: #fff;
}
.result-header-mm .flag-icon { background: #fdd835; color: #333; }

.result-header-vn {
    background: linear-gradient(135deg, #bf360c, #d84315);
    color: #fff;
}
.result-header-vn .flag-icon { background: #d32f2f; }

.result-header-kh {
    background: linear-gradient(135deg, #0d47a1, #1565c0);
    color: #fff;
}
.result-header-kh .flag-icon { background: #c62828; }

/* ===== Copy Button ===== */
.btn-copy {
    opacity: 0.7;
    transition: opacity var(--transition-speed) ease;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.btn-copy:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.3);
    color: #fff;
}

/* ===== Loading Overlay ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* ===== Footer ===== */
.footer {
    margin-top: auto !important;
}

/* ===== Animations ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-card {
    animation: fadeInUp 0.4s ease forwards;
}

.result-card:nth-child(1) { animation-delay: 0.05s; }
.result-card:nth-child(2) { animation-delay: 0.1s; }
.result-card:nth-child(3) { animation-delay: 0.15s; }
.result-card:nth-child(4) { animation-delay: 0.2s; }
.result-card:nth-child(5) { animation-delay: 0.25s; }
.result-card:nth-child(6) { animation-delay: 0.3s; }

/* ===== Print Styles ===== */
@media print {
    .navbar, .footer, .btn-copy, .btn-convert,
    .divider-with-text, #imageInput, #cameraInput,
    #btnExtract, #imagePreviewContainer, #ocrProgress,
    .btn-outline-success, .btn-outline-primary,
    .btn-outline-secondary, .card-glass {
        display: none !important;
    }

    body {
        background: #fff !important;
    }

    .result-card {
        break-inside: avoid;
        box-shadow: none !important;
        border: 1px solid #dee2e6 !important;
    }

    #resultsSection {
        display: block !important;
    }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .container {
        padding-left: 12px;
        padding-right: 12px;
    }

    .form-control-lg {
        font-size: 1rem;
    }

    .btn-convert {
        margin-top: 0.5rem;
    }

    .result-text {
        font-size: 0.95rem;
    }

    h4 {
        font-size: 1.2rem;
    }
}

@media (max-width: 576px) {
    .navbar-brand .fs-5 {
        font-size: 1rem !important;
    }

    .card-body {
        padding: 1rem;
    }
}
