/* Ketubah Tov Studio - Main Styles */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --bg: #fafafa;
    --surface: #ffffff;
    --text: #1a1a2e;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --success: #22c55e;
    --error: #ef4444;
    --warning: #f59e0b;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

/* Navbar */
.navbar {
    background: var(--text);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand a {
    color: white;
    text-decoration: none;
    font-weight: 700;
    font-size: 1rem;
}

.navbar-links {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.navbar-links a {
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: color 0.15s;
}

.navbar-links a:hover { color: white; }

.nav-user {
    color: rgba(255,255,255,0.5);
    font-size: 0.8rem;
}

.nav-logout {
    opacity: 0.5;
    font-size: 0.8rem !important;
}

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

/* Page Header */
.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 800;
    margin-bottom: 0.25rem;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.back-link {
    display: inline-block;
    color: var(--primary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
}

.back-link:hover { text-decoration: underline; }

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.alert-error { background: #fef2f2; color: var(--error); border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all 0.15s;
    gap: 0.5rem;
}

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

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

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover { background: #f8fafc; }

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-lg { padding: 0.75rem 2rem; font-size: 1rem; }
.btn-full { width: 100%; }

/* Category Cards */
.categories-grid h2 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.category-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.category-card {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    text-decoration: none;
    color: inherit;
    transition: all 0.15s;
}

.category-card:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.category-icon {
    font-size: 1.5rem;
    display: block;
    margin-bottom: 0.5rem;
}

.category-card h3 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.category-card p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.category-card.disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

/* Section Header */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.section-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
}

/* Image Grid */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.image-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: box-shadow 0.15s;
}

.image-card:hover { box-shadow: var(--shadow-lg); }

.image-thumb {
    aspect-ratio: 3/4;
    overflow: hidden;
    background: #f1f5f9;
}

.image-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.placeholder-thumb {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.image-meta {
    padding: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.category-badge {
    background: #f1f5f9;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: capitalize;
}

.image-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.recent-section {
    margin-top: 2.5rem;
}

/* Forms */
.form-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
}

.form-section h2 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.form-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group:last-child { margin-bottom: 0; }

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

input[type="text"],
input[type="email"],
input[type="password"],
select,
textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-family: inherit;
    background: var(--surface);
    transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

textarea { resize: vertical; }

/* Range Controls */
.range-control {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.range-control input[type="range"] {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border);
    border-radius: 3px;
    outline: none;
}

.range-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
}

.range-value {
    min-width: 28px;
    text-align: center;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
}

/* Checkbox and Radio Groups */
.checkbox-group, .radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.checkbox-label, .radio-label {
    display: flex !important;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem !important;
    font-weight: 400 !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    color: var(--text) !important;
    cursor: pointer;
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all 0.15s;
}

.checkbox-label:has(input:checked),
.radio-label:has(input:checked) {
    background: #eef2ff;
    border-color: var(--primary-light);
    color: var(--primary-dark) !important;
}

.radio-label {
    flex-direction: row;
    width: 100%;
    padding: 0.75rem 1rem;
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    position: relative;
    transition: all 0.15s;
}

.upload-area:hover, .upload-area.drag-over {
    border-color: var(--primary-light);
    background: #fafaff;
}

.upload-area input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.upload-icon { font-size: 2rem; }

.upload-preview {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--radius);
}

/* Form Actions */
.form-actions {
    display: flex;
    justify-content: flex-end;
    padding-top: 0.5rem;
}

/* Result Page */
.result-container {
    max-width: 800px;
    margin: 0 auto;
}

.generating-state {
    text-align: center;
    padding: 4rem 2rem;
}

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

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

.result-image-wrapper {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 1.25rem;
}

.result-image {
    width: 100%;
    display: block;
}

.result-actions {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.result-meta {
    background: #f8fafc;
    border-radius: var(--radius);
    padding: 1rem;
    font-size: 0.85rem;
}

.result-meta p { margin-bottom: 0.25rem; }

.prompt-text {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    font-size: 0.8rem;
    white-space: pre-wrap;
    margin-top: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
}

.error-state {
    text-align: center;
    padding: 3rem 2rem;
}

.error-text {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    padding: 0.75rem;
    font-size: 0.8rem;
    white-space: pre-wrap;
    margin: 1rem 0;
    max-height: 200px;
    overflow-y: auto;
}

/* Login Page */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.login-card h1 {
    font-size: 1.5rem;
    font-weight: 800;
    text-align: center;
    margin-bottom: 0.25rem;
}

.login-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
}

/* Generate Form */
.generate-form {
    max-width: 700px;
}

/* Gallery Page */
.gallery-filters {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.filter-chip {
    padding: 0.35rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    color: var(--text);
    background: var(--surface);
    transition: all 0.15s;
}

.filter-chip:hover, .filter-chip.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Annotation Editor (Phase 5) */
.editor-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 1.5rem;
}

.canvas-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
}

.canvas-container canvas {
    display: block;
    width: 100%;
    cursor: crosshair;
}

.editor-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.tool-bar {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    flex-wrap: wrap;
}

.color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
}

.color-swatch:hover { transform: scale(1.1); }
.color-swatch.active { border-color: var(--text); box-shadow: 0 0 0 2px white, 0 0 0 4px var(--text); }

.instruction-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.instruction-item {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
}

.instruction-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    margin-top: 0.6rem;
    flex-shrink: 0;
}

.instruction-item textarea {
    flex: 1;
    min-height: 60px;
    font-size: 0.8rem;
}

/* Dashboard Layout */
.dashboard-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 2rem;
    align-items: start;
}

.dashboard-main {
    min-width: 0;
}

/* Changelog Panel */
.changelog-panel {
    position: sticky;
    top: 72px;
    max-height: calc(100vh - 88px);
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.changelog-panel h2 {
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.changelog-entry {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.changelog-entry:last-child {
    border-bottom: none;
}

.changelog-latest {
    background: #f0fdf4;
    margin: -0.25rem -0.75rem 0;
    padding: 0.75rem;
    border-radius: var(--radius);
    border-bottom: none;
    margin-bottom: 0.25rem;
}

.changelog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.25rem;
}

.changelog-version {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary);
    background: #eef2ff;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
}

.changelog-latest .changelog-version {
    background: #dcfce7;
    color: #166534;
}

.changelog-date {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.changelog-title {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: var(--text);
}

.changelog-changes {
    list-style: none;
    padding: 0;
    margin: 0;
}

.changelog-changes li {
    font-size: 0.72rem;
    color: var(--text-secondary);
    line-height: 1.4;
    padding: 0.15rem 0;
    padding-left: 0.75rem;
    position: relative;
}

.changelog-changes li::before {
    content: "\2022";
    position: absolute;
    left: 0;
    color: var(--border);
}

/* Responsive */
@media (max-width: 768px) {
    .dashboard-layout {
        grid-template-columns: 1fr;
    }
    .changelog-panel {
        position: static;
        max-height: none;
        order: 1;
    }
    .dashboard-main {
        order: 0;
    }
    .category-cards {
        grid-template-columns: 1fr;
    }
    .image-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .editor-layout {
        grid-template-columns: 1fr;
    }
    .result-actions {
        flex-direction: column;
    }
}
