/* ============================================
   OpenClaw AI — Design System
   ============================================ */

/* --- Tokens --- */
:root {
    /* Palette — dark with amber/orange ADU-construction accent */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #16161f;
    --bg-card-hover: #1c1c28;
    --bg-input: #1a1a26;
    --border: #2a2a3a;
    --border-focus: #f59e0b;

    --text-primary: #f0f0f5;
    --text-secondary: #9090a8;
    --text-muted: #606078;

    --accent: #f59e0b;
    --accent-hover: #d97706;
    --accent-glow: rgba(245, 158, 11, 0.25);
    --accent-2: #fb923c;
    --gradient: linear-gradient(135deg, #f59e0b, #fb923c, #f97316);
    --gradient-text: linear-gradient(135deg, #fbbf24, #fb923c);

    --success: #34d399;
    --error: #f87171;
    --info: #60a5fa;

    /* Surfaces */
    --glass: rgba(22, 22, 31, 0.65);
    --glass-border: rgba(255, 255, 255, 0.06);
    --glass-blur: 20px;

    /* Radii */
    --r-sm: 8px;
    --r-md: 14px;
    --r-lg: 20px;
    --r-xl: 28px;

    /* Spacing */
    --s-xs: 4px;
    --s-sm: 8px;
    --s-md: 16px;
    --s-lg: 24px;
    --s-xl: 40px;
    --s-2xl: 64px;

    /* Typography */
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --fw-light: 300;
    --fw-normal: 400;
    --fw-medium: 500;
    --fw-semi: 600;
    --fw-bold: 700;
    --fw-black: 900;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* --- Header --- */
#main-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--glass);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border-bottom: 1px solid var(--glass-border);
}
.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--s-md) var(--s-lg);
}
.logo {
    display: flex;
    align-items: center;
    gap: var(--s-sm);
}
.logo-icon {
    font-size: 1.6rem;
    filter: drop-shadow(0 0 8px var(--accent-glow));
}
.logo h1 {
    font-size: 1.4rem;
    font-weight: var(--fw-black);
    letter-spacing: -0.5px;
}
.accent { color: var(--accent); }

nav { display: flex; gap: var(--s-lg); }
.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: var(--fw-medium);
    transition: color 0.2s;
    position: relative;
}
.nav-link:hover, .nav-link.active { color: var(--text-primary); }
.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 0; right: 0;
    height: 2px;
    background: var(--gradient);
    border-radius: 2px;
}

.header-status { display: flex; align-items: center; gap: var(--s-sm); }
.status-dot {
    width: 8px; height: 8px;
    background: var(--success);
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(52, 211, 153, 0.5);
    animation: pulse-dot 2s ease-in-out infinite;
}
.status-text { font-size: 0.8rem; color: var(--text-muted); }

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* --- Hero --- */
#hero {
    text-align: center;
    padding: var(--s-2xl) var(--s-lg) var(--s-xl);
}
.hero-content h2 {
    font-size: clamp(2rem, 5vw, 3.2rem);
    font-weight: var(--fw-black);
    letter-spacing: -1px;
    margin-bottom: var(--s-md);
}
.gradient-text {
    background: var(--gradient-text);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.hero-content p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    max-width: 620px;
    margin: 0 auto;
}

/* --- Sections --- */
.section {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--s-xl) var(--s-lg);
}
.section-header {
    margin-bottom: var(--s-lg);
}
.section-header h3 {
    font-size: 1.5rem;
    font-weight: var(--fw-bold);
    margin-bottom: var(--s-xs);
}
.section-sub {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* --- Upload Zones --- */
.upload-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--s-lg);
    margin-bottom: var(--s-lg);
}
@media (max-width: 700px) {
    .upload-grid { grid-template-columns: 1fr; }
}

.upload-zone {
    position: relative;
    border: 2px dashed var(--border);
    border-radius: var(--r-lg);
    min-height: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color 0.3s, background 0.3s, transform 0.2s;
    overflow: hidden;
    background: var(--bg-card);
}
.upload-zone:hover {
    border-color: var(--accent);
    background: var(--bg-card-hover);
    transform: translateY(-2px);
}
.upload-zone.drag-over {
    border-color: var(--accent);
    background: var(--accent-glow);
    box-shadow: inset 0 0 40px var(--accent-glow);
}
.upload-zone.has-file {
    border-style: solid;
    border-color: var(--accent);
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--s-sm);
    pointer-events: none;
}
.upload-icon { font-size: 3rem; opacity: 0.8; }
.upload-label {
    font-weight: var(--fw-semi);
    font-size: 1.05rem;
}
.upload-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    max-width: 200px;
}

.upload-preview {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
    border-radius: var(--r-lg);
}
.upload-zone.has-file .upload-preview { display: block; }
.upload-zone.has-file .upload-placeholder { display: none; }

.clear-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px; height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.7);
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2;
    transition: background 0.2s;
}
.clear-btn:hover { background: var(--error); }
.upload-zone.has-file .clear-btn { display: flex; }

/* --- Options Panel --- */
.options-panel {
    display: flex;
    gap: var(--s-md);
    margin-bottom: var(--s-lg);
    flex-wrap: wrap;
}
.option-group {
    flex: 1;
    min-width: 200px;
}
.option-group.small {
    flex: 0 0 120px;
    min-width: unset;
}
.option-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: var(--fw-medium);
    color: var(--text-secondary);
    margin-bottom: var(--s-xs);
}
.optional { color: var(--text-muted); font-weight: var(--fw-normal); }

.option-group input,
.option-group select {
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.9rem;
    transition: border-color 0.2s;
    outline: none;
}
.option-group input:focus,
.option-group select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.option-group input::placeholder { color: var(--text-muted); }

/* --- Buttons --- */
.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-sm);
    width: 100%;
    padding: 16px 32px;
    border: none;
    border-radius: var(--r-md);
    background: var(--gradient);
    color: #000;
    font-family: var(--font);
    font-size: 1.05rem;
    font-weight: var(--fw-bold);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.3s, opacity 0.2s;
    position: relative;
    overflow: hidden;
}
.btn-primary::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent, rgba(255,255,255,0.15), transparent);
    transform: translateX(-100%);
    transition: transform 0.5s;
}
.btn-primary:hover:not(:disabled)::before { transform: translateX(100%); }
.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px var(--accent-glow);
}
.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-secondary {
    padding: 10px 20px;
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: var(--fw-medium);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
.btn-secondary:hover {
    border-color: var(--accent);
    background: var(--bg-card-hover);
}

/* Spinner */
.spinner {
    display: inline-block;
    width: 18px; height: 18px;
    border: 2.5px solid rgba(0,0,0,0.2);
    border-top-color: #000;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Analysis Card --- */
.analysis-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--s-lg);
}
.analysis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--s-md);
    margin-bottom: var(--s-lg);
}
.analysis-item {
    background: var(--bg-secondary);
    border-radius: var(--r-sm);
    padding: var(--s-md);
}
.analysis-item .label {
    font-size: 0.75rem;
    font-weight: var(--fw-semi);
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--s-xs);
}
.analysis-item .value {
    font-size: 0.95rem;
    color: var(--text-primary);
}

.prompt-block {
    border-top: 1px solid var(--border);
    padding-top: var(--s-md);
}
.prompt-label {
    font-size: 0.75rem;
    font-weight: var(--fw-semi);
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.prompt-block p {
    margin-top: var(--s-xs);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-style: italic;
}

/* --- Debug Panel --- */
.debug-row {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--s-lg);
    margin-bottom: var(--s-md);
}
.debug-label {
    font-size: 0.85rem;
    font-weight: var(--fw-bold);
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: var(--s-md);
}
.debug-img {
    width: 100%;
    max-width: 800px;
    border-radius: var(--r-md);
    border: 2px solid var(--border);
    transition: transform 0.2s;
}
.debug-img:hover {
    transform: scale(1.02);
    border-color: var(--accent);
}

/* --- Results Grid --- */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: var(--s-lg);
}
.result-card {
    position: relative;
    border-radius: var(--r-lg);
    overflow: hidden;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    aspect-ratio: 16/9;
}
.result-card:hover {
    transform: translateY(-4px) scale(1.01);
    box-shadow: 0 12px 40px rgba(0,0,0,0.4);
}
.result-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.result-card .result-label {
    position: absolute;
    bottom: 0;
    left: 0; right: 0;
    padding: var(--s-md);
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
    font-size: 0.85rem;
    font-weight: var(--fw-medium);
}

/* --- Library Grid --- */
.library-toolbar {
    margin-bottom: var(--s-md);
}
.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--s-md);
}
.library-card {
    position: relative;
    border-radius: var(--r-md);
    overflow: hidden;
    border: 2px solid transparent;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.2s;
    aspect-ratio: 4/3;
    background: var(--bg-card);
}
.library-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}
.library-card.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.library-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.library-card .lib-name {
    position: absolute;
    bottom: 0;
    left: 0; right: 0;
    padding: 6px 10px;
    background: rgba(0,0,0,0.75);
    font-size: 0.7rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.library-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: var(--s-xl);
    color: var(--text-muted);
}

/* --- Lightbox --- */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}
.lightbox[hidden] { display: none; }
.lightbox-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(10px);
}
.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
}
.lightbox-content img {
    max-width: 90vw;
    max-height: 85vh;
    border-radius: var(--r-md);
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.lightbox-close {
    position: absolute;
    top: -16px; right: -16px;
    width: 40px; height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.lightbox-close:hover { background: var(--error); }
.lightbox-download {
    position: absolute;
    bottom: -50px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 24px;
    border-radius: var(--r-sm);
    background: var(--gradient);
    color: #000;
    font-weight: var(--fw-semi);
    text-decoration: none;
    font-size: 0.9rem;
    transition: transform 0.2s;
}
.lightbox-download:hover { transform: translateX(-50%) translateY(-2px); }

/* --- Toast Notifications --- */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 14px 24px;
    border-radius: var(--r-sm);
    font-size: 0.9rem;
    font-weight: var(--fw-medium);
    color: var(--text-primary);
    z-index: 300;
    animation: toast-in 0.4s ease-out;
    box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}
.toast.success { background: var(--success); color: #000; }
.toast.error { background: var(--error); color: #000; }
.toast.info { background: var(--info); color: #000; }

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

/* --- Responsive --- */
@media (max-width: 600px) {
    .header-inner { padding: var(--s-sm) var(--s-md); }
    nav { display: none; }
    .section { padding: var(--s-lg) var(--s-md); }
    .options-panel { flex-direction: column; }
    .option-group.small { flex: 1; }
    .results-grid { grid-template-columns: 1fr; }
}
