/* Nano Banana Pro Web Interface Styles */

/* Dark Theme (Default) */
:root {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #252525;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --accent: #f59e0b;
    --accent-hover: #d97706;
    --success: #22c55e;
    --warning: #eab308;
    --error: #ef4444;
    --border: #333333;
    --radius: 8px;
    --shadow-color: rgba(0, 0, 0, 0.5);
    --overlay-bg: rgba(0, 0, 0, 0.7);
}

/* Light Theme */
[data-theme="light"] {
    --bg-primary: #f8f6f3;
    --bg-secondary: #ffffff;
    --bg-tertiary: #edeae5;
    --text-primary: #1a1a1a;
    --text-secondary: #6b6b6b;
    --accent: #d97706;
    --accent-hover: #b45309;
    --success: #16a34a;
    --warning: #ca8a04;
    --error: #dc2626;
    --border: #d4d0c8;
    --shadow-color: rgba(0, 0, 0, 0.08);
    --overlay-bg: rgba(255, 255, 255, 0.9);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* Navigation */
.navbar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand a {
    color: var(--accent);
    text-decoration: none;
    font-size: 1.25rem;
    font-weight: 600;
}

.nav-links {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    transition: all 0.2s;
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.nav-dropdown {
    position: relative;
}

.nav-btn {
    background: var(--accent);
    color: var(--bg-primary);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 500;
}

.nav-btn:hover {
    background: var(--accent-hover);
}

.dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-width: 200px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    z-index: 10;
}

.nav-dropdown:hover .dropdown-content {
    display: block;
}

.dropdown-content a {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
}

.dropdown-content a:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.dropdown-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 0.5rem 0;
}

/* Theme Toggle */
.theme-toggle {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    margin-left: 0.5rem;
}

.theme-toggle:hover {
    background: var(--bg-tertiary);
    color: var(--accent);
    border-color: var(--accent);
}

/* Show sun in dark mode, moon in light mode */
.theme-toggle .icon-sun {
    display: block;
}

.theme-toggle .icon-moon {
    display: none;
}

[data-theme="light"] .theme-toggle .icon-sun {
    display: none;
}

[data-theme="light"] .theme-toggle .icon-moon {
    display: block;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Page Titles */
.page-title {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 2rem;
}

/* Dashboard */
.dashboard h1 {
    margin-bottom: 2rem;
}

/* Stats Grid - 4 equal columns */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-secondary);
    padding: 1.25rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    text-align: center;
    animation: fadeIn 0.3s ease-out backwards;
    /* Vertical centering */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.stat-card:nth-child(1) { animation-delay: 0s; }
.stat-card:nth-child(2) { animation-delay: 0.05s; }
.stat-card:nth-child(3) { animation-delay: 0.1s; }
.stat-card:nth-child(4) { animation-delay: 0.15s; }

.stat-card.success {
    border-color: var(--success);
}

.stat-card.warning {
    border-color: var(--warning);
}

.stat-card.pulse .stat-value {
    animation: gentlePulse 2s ease-in-out infinite;
}

.stat-value {
    font-family: 'SF Mono', 'Monaco', 'Menlo', monospace;
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: -0.02em;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-top: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Cost breakdown inside card */
.stat-breakdown {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    width: 100%;
    font-size: 0.7rem;
}

.breakdown-row {
    display: flex;
    justify-content: space-between;
    color: var(--text-secondary);
    padding: 0.15rem 0;
}

.breakdown-row span:first-child {
    opacity: 0.7;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.breakdown-row span:last-child {
    font-family: 'SF Mono', 'Monaco', 'Menlo', monospace;
}

.stat-since {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    opacity: 0.6;
}

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

@keyframes gentlePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Responsive */
@media (max-width: 900px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 500px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* Quick Actions */
.quick-actions {
    margin-bottom: 2rem;
}

.quick-actions h2 {
    margin-bottom: 1rem;
}

.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.action-card {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    text-decoration: none;
    text-align: center;
    transition: all 0.2s;
    animation: fadeIn 0.4s ease-out backwards;
}

/* Staggered animation delays for action cards */
.action-card:nth-child(1) { animation-delay: 0.1s; }
.action-card:nth-child(2) { animation-delay: 0.15s; }
.action-card:nth-child(3) { animation-delay: 0.2s; }
.action-card:nth-child(4) { animation-delay: 0.25s; }
.action-card:nth-child(5) { animation-delay: 0.3s; }
.action-card:nth-child(6) { animation-delay: 0.35s; }
.action-card:nth-child(7) { animation-delay: 0.4s; }
.action-card:nth-child(8) { animation-delay: 0.45s; }
.action-card:nth-child(9) { animation-delay: 0.5s; }

.action-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.15);
}

.action-icon {
    width: 48px;
    height: 48px;
    background: var(--accent);
    color: var(--bg-primary);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.action-title {
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.action-desc {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Tables */
.jobs-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.jobs-table th,
.jobs-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.jobs-table th {
    color: var(--text-secondary);
    font-weight: 500;
}

.jobs-table a {
    color: var(--accent);
    text-decoration: none;
}

.jobs-table a:hover {
    text-decoration: underline;
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.status-pending {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.status-running {
    background: rgba(234, 179, 8, 0.2);
    color: var(--warning);
}

.status-completed {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
}

.status-failed {
    background: rgba(239, 68, 68, 0.2);
    color: var(--error);
}

/* Buttons */
.btn {
    display: inline-block;
    background: var(--accent);
    color: var(--bg-primary);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    text-decoration: none;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-danger {
    background: var(--error);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-danger-outline {
    background: transparent;
    color: var(--error);
    border: 1px solid var(--error);
}

.btn-danger-outline:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 1rem;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.form-textarea {
    min-height: 120px;
    resize: vertical;
}

/* File Upload */
.file-upload {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.file-upload:hover {
    border-color: var(--accent);
}

.file-upload input {
    display: none;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

/* Footer */
.footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}

/* Error Page */
.error-page {
    text-align: center;
    padding: 4rem 2rem;
}

.error-page h1 {
    font-size: 4rem;
    color: var(--error);
}

/* Generation Form */
.generate-form {
    max-width: 800px;
    margin: 0 auto;
    background: var(--bg-secondary);
    padding: 2rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.generate-form h1 {
    margin-bottom: 1.5rem;
}

/* Info boxes with YAML examples */
.info-box pre {
    overflow-x: auto;
    white-space: pre;
    word-wrap: normal;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Gallery Header */
.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.gallery-header h1 {
    margin-bottom: 0.25rem;
}

.gallery-view-toggle {
    display: flex;
    gap: 0.25rem;
    background: var(--bg-secondary);
    padding: 0.25rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.view-btn {
    background: transparent;
    border: none;
    padding: 0.5rem 0.625rem;
    border-radius: calc(var(--radius) - 2px);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease, background 0.2s ease, transform 0.15s ease;
}

.view-btn:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.view-btn:active {
    transform: scale(0.92);
}

.view-btn.active {
    background: var(--accent);
    color: var(--bg-primary);
}

.view-btn.active:hover {
    background: var(--accent-hover);
}

/* Gallery Filter Tabs */
.gallery-filters {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.filter-tab {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.filter-tab:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.filter-tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg-primary);
}

/* Gallery Grid - Base */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.25rem;
}

/* Reset figure margin (browser default) */
figure.gallery-item {
    margin: 0;
}

/* Square View (default) */
.gallery-grid.view-square {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
}

.gallery-grid.view-square .gallery-item {
    aspect-ratio: 1;
}

.gallery-grid.view-square .gallery-item img {
    object-fit: cover;
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.gallery-grid.view-square .gallery-item:hover img {
    transform: scale(1.05);
}

.gallery-grid.view-square .gallery-item-meta {
    display: none;
}

.gallery-grid.view-square .caption-prompt {
    display: none;
}

/* Fitted View - CSS Grid with contained images */
.gallery-grid.view-fitted {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.25rem;
}

.gallery-grid.view-fitted .gallery-item {
    aspect-ratio: 4/3;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-grid.view-fitted .gallery-item > a:first-child {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-grid.view-fitted .gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.gallery-grid.view-fitted .gallery-item:hover img {
    transform: scale(1.05);
}

.gallery-grid.view-fitted .gallery-item-meta {
    display: none;
}

.gallery-grid.view-fitted .caption-prompt {
    display: none;
}

/* List View */
.gallery-grid.view-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.gallery-grid.view-list .gallery-item {
    aspect-ratio: auto;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 1.25rem;
    padding: 0.875rem 1rem;
    border-radius: var(--radius);
    transform: none;
}

.gallery-grid.view-list .gallery-item:hover {
    transform: none;
    background: var(--bg-tertiary);
}

.gallery-grid.view-list .gallery-item > a:first-child {
    width: 100px;
    height: 68px;
    flex-shrink: 0;
    border-radius: calc(var(--radius) - 2px);
    overflow: hidden;
}

.gallery-grid.view-list .gallery-item img {
    width: 100px;
    height: 68px;
    object-fit: cover;
    border-radius: calc(var(--radius) - 2px);
    transition: transform 0.3s ease;
}

.gallery-grid.view-list .gallery-item:hover img {
    transform: scale(1.08);
}

.gallery-grid.view-list .gallery-caption {
    position: static;
    background: none;
    opacity: 1;
    padding: 0;
    flex: 1;
    min-width: 0;
}

.gallery-grid.view-list .gallery-caption p {
    color: var(--text-primary);
    font-size: 0.9rem;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.gallery-grid.view-list .caption-prompt {
    display: none;
}

.gallery-grid.view-list .caption-filename {
    display: block;
    font-weight: 500;
    letter-spacing: -0.01em;
}

.gallery-grid.view-list .gallery-item-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.gallery-grid.view-list .gallery-download {
    position: static;
    opacity: 0.6;
    flex-shrink: 0;
    transition: opacity 0.2s, background 0.2s, color 0.2s;
}

.gallery-grid.view-list .gallery-item:hover .gallery-download {
    opacity: 1;
}

/* Hide load more in columns layout (needs special handling) */
.gallery-grid.view-fitted .gallery-load-more {
    break-inside: avoid;
    column-span: all;
}

.gallery-item {
    aspect-ratio: 1;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    position: relative;
}

.gallery-item:hover {
    border-color: var(--accent);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--accent);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-item > a:first-child {
    display: block;
    height: 100%;
    overflow: hidden;
}

.gallery-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem 0.75rem 0.75rem;
    background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.5) 60%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.gallery-item:hover .gallery-caption {
    opacity: 1;
}

.gallery-caption p {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.95);
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.gallery-load-more {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2.5rem;
}

.gallery-download {
    position: absolute;
    top: 0.625rem;
    right: 0.625rem;
    width: 36px;
    height: 36px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.9);
    opacity: 0;
    transition: opacity 0.25s ease, background 0.2s ease, transform 0.2s ease;
    z-index: 2;
}

.gallery-item:hover .gallery-download {
    opacity: 1;
}

.gallery-download:hover {
    background: var(--accent);
    color: var(--bg-primary);
    transform: scale(1.1);
}

.gallery-download:active {
    transform: scale(0.95);
}

/* Job Detail */
.job-detail {
    background: var(--bg-secondary);
    padding: 2rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.job-detail h1 {
    margin-bottom: 1rem;
}

.job-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.meta-item {
    background: var(--bg-tertiary);
    padding: 1rem;
    border-radius: var(--radius);
}

.meta-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.meta-value {
    font-weight: 600;
    margin-top: 0.25rem;
}

.job-images {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

.job-image {
    border-radius: var(--radius);
    overflow: hidden;
}

.job-image img {
    width: 100%;
    height: auto;
}

.job-image-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.75rem;
}

.job-image-path {
    font-size: 0.75rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Login Page */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.login-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem;
    width: 100%;
    max-width: 380px;
}

.login-card h1 {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--accent);
    font-size: 1.75rem;
}

.login-card .form-group {
    margin-bottom: 1.25rem;
}

.login-card label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
}

.login-card input[type="text"],
.login-card input[type="password"] {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 1rem;
}

.login-card input:focus {
    outline: none;
    border-color: var(--accent);
}

.btn-primary {
    background: var(--accent);
    color: var(--bg-primary);
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-full {
    width: 100%;
    padding: 0.875rem;
    font-size: 1rem;
}

.alert {
    padding: 0.875rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
    font-size: 0.875rem;
}

.alert-error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Logout Button in Nav */
.nav-logout-form {
    display: inline-flex;
    margin: 0;
}

.nav-logout-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
