/* ============================================================
   Image Captioning Web App — Styles (Dual Model Comparison)
   ============================================================ */

:root {
    --bg: #0b0f19;
    --surface: #151d30;
    --surface-light: #1e293b;
    --primary: #3b82f6;
    --primary-light: #60a5fa;
    --accent: #8b5cf6;
    --accent-light: #a78bfa;
    --success: #10b981;
    --warning: #f59e0b;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --border: #26334d;
    --radius: 18px;
    --shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
}

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

body {
    font-family: 'Outfit', 'Noto Sans Thai', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 32px 20px;
    line-height: 1.6;
}

.container {
    width: 100%;
    max-width: 900px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 24px;
}

header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #60a5fa 0%, #a78bfa 50%, #f472b6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.05rem;
}

.model-badge {
    display: inline-block;
    margin-top: 12px;
    padding: 6px 16px;
    border-radius: 999px;
    font-size: 0.825rem;
    font-weight: 500;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.model-badge.ready {
    color: #4ade80;
    border-color: rgba(34, 197, 94, 0.4);
    background: rgba(34, 197, 94, 0.08);
}

/* Selector Control Bar */
.selector-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 28px;
}

.selector-label {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.segmented-control {
    display: inline-flex;
    background: var(--surface);
    padding: 6px;
    border-radius: 999px;
    border: 1px solid var(--border);
    gap: 4px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.segmented-control input[type="radio"] {
    display: none;
}

.control-btn {
    padding: 10px 20px;
    border-radius: 999px;
    font-size: 0.925rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 6px;
}

.control-btn:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
}

.segmented-control input[type="radio"]:checked + .control-btn {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 54px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--surface);
}

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

.drop-zone.dragover {
    transform: scale(1.015);
}

.upload-icon {
    width: 60px;
    height: 60px;
    color: var(--primary-light);
    margin-bottom: 16px;
}

.drop-text {
    font-size: 1.2rem;
    color: var(--text);
    margin-bottom: 4px;
}

.drop-text strong {
    color: var(--primary-light);
}

.drop-hint {
    font-size: 0.925rem;
    color: var(--text-muted);
}

/* Result Area */
.result-area {
    animation: fadeIn 0.4s ease;
}

.preview-card {
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.preview-card img {
    width: 100%;
    height: auto;
    display: block;
    max-height: 420px;
    object-fit: contain;
    background: #060911;
}

/* Results Grid */
.results-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.results-grid.dual-grid {
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
}

.caption-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    position: relative;
}

.caption-card.fine-tuned-card {
    border-color: rgba(139, 92, 246, 0.4);
    background: linear-gradient(180deg, rgba(139, 92, 246, 0.05) 0%, var(--surface) 100%);
}

.caption-card.pretrained-card {
    border-color: rgba(59, 130, 246, 0.4);
    background: linear-gradient(180deg, rgba(59, 130, 246, 0.05) 0%, var(--surface) 100%);
}

.caption-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.model-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
}

.tag {
    font-size: 0.75rem;
    padding: 5px 12px;
    border-radius: 999px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.tag-pre {
    background: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
    border: 1px solid rgba(59, 130, 246, 0.4);
}

.tag-ft {
    background: rgba(139, 92, 246, 0.2);
    color: #c4b5fd;
    border: 1px solid rgba(139, 92, 246, 0.4);
}

.captions-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.caption-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.975rem;
    animation: slideIn 0.3s ease both;
}

.caption-item .num {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}

.fine-tuned-card .caption-item .num {
    background: var(--accent);
    color: #ffffff;
}

.pretrained-card .caption-item .num {
    background: var(--primary);
    color: #ffffff;
}

.caption-item .text {
    color: var(--text);
}

.text-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
}

.text-en {
    color: var(--text);
    font-weight: 500;
}

.text-th {
    color: #34d399;
    font-family: 'Noto Sans Thai', sans-serif;
    font-size: 0.935rem;
    font-weight: 500;
}

/* Spinner */
.spinner {
    display: none;
    text-align: center;
    padding: 36px;
}

.spinner.active {
    display: block;
}

.spinner-ring {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary-light);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

.spinner-text {
    font-size: 0.95rem;
    color: var(--text-muted);
}

/* Clear Button */
.clear-btn {
    width: 100%;
    padding: 16px 24px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: var(--shadow);
}

.clear-btn:hover {
    background: var(--surface-light);
    border-color: var(--primary-light);
}

/* Error */
.error-msg {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #fca5a5;
    padding: 16px 20px;
    border-radius: 14px;
    margin-top: 16px;
    font-size: 0.95rem;
}

/* Footer */
footer {
    text-align: center;
    margin-top: 36px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.875rem;
}

footer a {
    color: var(--primary-light);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Utilities */
.hidden {
    display: none !important;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-8px); }
    to { opacity: 1; transform: translateX(0); }
}

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

/* Responsive */
@media (max-width: 600px) {
    header h1 {
        font-size: 1.6rem;
    }
    .segmented-control {
        flex-direction: column;
        border-radius: 16px;
        width: 100%;
    }
    .control-btn {
        justify-content: center;
    }
    .results-grid.dual-grid {
        grid-template-columns: 1fr;
    }
}
