/**
 * Quisinio - Main Stylesheet
 * Combines best features from both MVPs
 */

/* ===== CSS Variables ===== */
:root {
    /* Colors */
    --color-primary: #667eea;
    --color-primary-dark: #5568d3;
    --color-secondary: #764ba2;
    --color-ink: #1a1a1a;
    --color-ink-light: #666;
    --color-paper: #ffffff;
    --color-paper-warm: #faf8f5;
    --color-border: #e0e0e0;
    --color-error: #dc3545;
    --color-success: #28a745;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;

    /* Typography */
    --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-serif: 'Cormorant Garamond', 'Playfair Display', serif;
    --font-sans: 'Source Sans 3', 'Inter', sans-serif;
    --font-handwritten: 'Caveat', cursive;

    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.15);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.2);

    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 300ms ease;
}

/* ===== Base Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-ui);
    color: var(--color-ink);
    background: var(--color-paper-warm);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== Screen Management ===== */
.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: block;
}

/* ===== Login Screen ===== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    padding: var(--space-lg);
}

.login-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--space-xl);
    width: 100%;
    max-width: 420px;
}

.login-header {
    text-align: center;
    margin-bottom: var(--space-xl);
}

.app-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-ink);
    margin-bottom: var(--space-sm);
}

.app-subtitle {
    color: var(--color-ink-light);
    font-size: 0.95rem;
}

.login-form .form-group {
    margin-bottom: var(--space-lg);
}

.login-footer {
    margin-top: var(--space-xl);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--color-border);
}

.privacy-note {
    font-size: 0.85rem;
    color: var(--color-ink-light);
    text-align: center;
    line-height: 1.5;
}

/* ===== Dashboard ===== */
.dashboard-container {
    min-height: 100vh;
    background: var(--color-paper-warm);
}

.dashboard-header {
    background: white;
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-md);
}

.header-left h1 {
    font-size: 1.5rem;
    margin-bottom: var(--space-xs);
}

.user-name {
    font-size: 0.9rem;
    color: var(--color-ink-light);
}

.dashboard-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-xl) var(--space-lg);
}

.dashboard-actions {
    margin-bottom: var(--space-xl);
}

.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-lg);
}

.menu-card {
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    cursor: pointer;
}

.menu-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.menu-card-preview {
    height: 200px;
    background: var(--color-paper-warm);
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--color-border);
}

.menu-card-content {
    padding: var(--space-md);
}

.menu-card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: var(--space-xs);
}

.menu-card-meta {
    font-size: 0.85rem;
    color: var(--color-ink-light);
    margin-bottom: var(--space-md);
}

.menu-card-actions {
    display: flex;
    gap: var(--space-sm);
}

/* ===== Editor ===== */
.editor-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--color-paper-warm);
}

.toolbar {
    background: white;
    padding: var(--space-md) var(--space-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-md);
    flex-wrap: wrap;
    z-index: 100;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.title-input {
    font-size: 1.1rem;
    font-weight: 600;
    border: 2px solid transparent;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    min-width: 200px;
    transition: border-color var(--transition-fast);
}

.title-input:focus {
    outline: none;
    border-color: var(--color-primary);
}

.ai-status {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--color-paper-warm);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--color-success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.editor-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ===== Sidebar ===== */
.editor-sidebar {
    width: 380px;
    background: white;
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-tabs {
    display: flex;
    border-bottom: 2px solid var(--color-border);
    background: var(--color-paper-warm);
}

.tab-btn {
    flex: 1;
    padding: var(--space-md);
    background: none;
    border: none;
    cursor: pointer;
    font-weight: 500;
    color: var(--color-ink-light);
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition-fast);
}

.tab-btn.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
    background: white;
}

.tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding: var(--space-lg);
}

.tab-content.active {
    display: block;
}

.tab-content h3 {
    font-size: 0.95rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-ink-light);
    margin-bottom: var(--space-md);
    margin-top: var(--space-lg);
}

.tab-content h3:first-child {
    margin-top: 0;
}

/* ===== AI Quick Add ===== */
.ai-quick-add {
    background: linear-gradient(135deg, #f0f4ff 0%, #e8f0fe 100%);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
}

.input-group {
    display: flex;
    gap: var(--space-sm);
}

.input-group input {
    flex: 1;
}

/* ===== Block List ===== */
.block-list-container {
    margin-bottom: var(--space-lg);
}

.block-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.block-item {
    background: var(--color-paper-warm);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    cursor: move;
    transition: all var(--transition-fast);
}

.block-item:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-sm);
}

.block-item.dragging {
    opacity: 0.5;
}

.block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-sm);
}

.block-type {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-ink-light);
}

.block-actions {
    display: flex;
    gap: var(--space-xs);
}

.block-body input,
.block-body textarea {
    width: 100%;
    margin-bottom: var(--space-sm);
}

.block-body textarea {
    min-height: 60px;
    resize: vertical;
}

/* ===== Theme Selector ===== */
.theme-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
}

.theme-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.theme-option:hover,
.theme-option.active {
    border-color: var(--color-primary);
    background: var(--color-paper-warm);
}

.theme-preview {
    font-size: 1.5rem;
    font-weight: 600;
}

.theme-option[data-theme="classic"] .theme-preview {
    font-family: var(--font-serif);
}

.theme-option[data-theme="modern"] .theme-preview {
    font-family: var(--font-sans);
}

.theme-option[data-theme="handwritten"] .theme-preview {
    font-family: var(--font-handwritten);
}

/* ===== Frame Selector ===== */
.frame-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
}

.frame-option {
    padding: var(--space-md);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    text-align: center;
    font-size: 0.85rem;
    transition: all var(--transition-fast);
}

.frame-option:hover,
.frame-option.active {
    border-color: var(--color-primary);
    background: var(--color-paper-warm);
}

/* ===== Preview ===== */
.editor-preview {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #f5f7fa;
}

.preview-controls {
    padding: var(--space-md);
    background: white;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-md);
}

.preview-container {
    flex: 1;
    overflow: auto;
    padding: var(--space-lg);
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* ===== A4 Page ===== */
.a4-page {
    width: 210mm;
    min-height: 297mm;
    background: white;
    box-shadow: var(--shadow-lg);
    position: relative;
    page-break-after: always;
}

.menu-preview {
    padding: 20mm;
}

/* Menu Header */
.menu-header {
    text-align: center;
    margin-bottom: 15mm;
    position: relative;
}

.menu-header.with-image {
    margin-bottom: 0;
}

.header-image-container {
    position: relative;
    margin: -20mm -20mm 15mm -20mm;
    overflow: hidden;
}

.header-image {
    width: 100%;
    height: auto;
    display: block;
}

.header-image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.menu-logo {
    max-width: 80mm;
    height: auto;
    margin-bottom: 10mm;
}

.menu-main-title {
    font-size: 28pt;
    font-weight: 700;
    margin-bottom: 5mm;
}

.menu-subtitle {
    font-size: 16pt;
    color: #666;
}

/* Menu Body */
.menu-body {
    position: relative;
}

.section-header {
    font-size: 20pt;
    font-weight: 700;
    margin-top: 8mm;
    margin-bottom: 5mm;
    padding-bottom: 2mm;
}

.section-header.underlined {
    border-bottom: 2px solid currentColor;
}

.menu-dish {
    margin-bottom: 5mm;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.dish-content {
    flex: 1;
    padding-right: 5mm;
}

.dish-title {
    font-size: 14pt;
    font-weight: 600;
    margin-bottom: 1mm;
}

.dish-subtitle {
    font-size: 11pt;
    color: #666;
    line-height: 1.4;
}

.dish-price {
    font-size: 14pt;
    font-weight: 600;
    white-space: nowrap;
}

.spacer-block {
    height: 5mm;
}

/* Menu Footer */
.menu-footer {
    margin-top: 10mm;
    padding-top: 5mm;
    border-top: 1px solid #ddd;
    text-align: center;
    font-size: 11pt;
    color: #666;
}

/* Background Image */
.menu-background {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-size: cover;
    background-position: center;
    pointer-events: none;
    z-index: -1;
}

/* Frames */
/* Frames */
.frame-simple {
    border: 2px solid currentColor;
}

.frame-double {
    border: 4px double currentColor;
}

.frame-elegant {
    border: 1px solid currentColor;
    box-shadow: inset 0 0 0 3px white, inset 0 0 0 4px currentColor;
}

.frame-corners {
    position: relative;
}

.frame-corners::before,
.frame-corners::after {
    content: '';
    position: absolute;
    width: 15mm;
    height: 15mm;
    border: 2px solid currentColor;
    pointer-events: none;
}

.frame-corners::before {
    top: 10mm;
    left: 10mm;
    border-right: none;
    border-bottom: none;
}

.frame-corners::after {
    bottom: 10mm;
    right: 10mm;
    border-left: none;
    border-top: none;
}

/* Form Grid */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-sm);
}

.btn-group {
    display: flex;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.btn-group .btn {
    flex: 1;
    border-radius: 0;
    background: white;
    color: var(--color-ink);
    border: none;
}

.btn-group .btn.active {
    background: var(--color-primary);
    color: white;
}

/* ===== Form Elements ===== */
.form-group {
    margin-bottom: var(--space-md);
}

label {
    display: block;
    font-weight: 500;
    margin-bottom: var(--space-xs);
    font-size: 0.9rem;
    color: var(--color-ink);
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color var(--transition-fast);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--color-primary);
}

input[type="color"] {
    height: 40px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

input[type="range"] {
    width: 100%;
    height: 6px;
    background: var(--color-border);
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--color-primary);
    border-radius: 50%;
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--color-primary);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    color: white;
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-danger {
    background: var(--color-error);
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-block {
    width: 100%;
}

.btn-large {
    padding: var(--space-md) var(--space-lg);
    font-size: 1.05rem;
}

.btn-sm {
    padding: 4px 8px;
    font-size: 0.85rem;
}

.btn-icon {
    padding: var(--space-sm);
    aspect-ratio: 1;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== Modals ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: var(--radius-lg);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.25rem;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--color-ink-light);
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-body {
    padding: var(--space-lg);
}

/* ===== Voice Modal ===== */
.voice-visualizer {
    text-align: center;
    padding: var(--space-xl);
}

.recording-indicator {
    width: 120px;
    height: 120px;
    margin: 0 auto var(--space-lg);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary);
}

.recording-indicator .pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 3px solid var(--color-primary);
    border-radius: 50%;
    animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
    0% {
        transform: scale(0.8);
        opacity: 1;
    }
    100% {
        transform: scale(1.2);
        opacity: 0;
    }
}

.voice-transcript {
    margin-top: var(--space-lg);
    padding: var(--space-md);
    background: var(--color-paper-warm);
    border-radius: var(--radius-md);
    min-height: 60px;
    font-size: 0.95rem;
    color: var(--color-ink-light);
}

/* ===== Loading Overlay ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-lg);
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Mobile FAB ===== */
.mobile-fab {
    display: none;
    position: fixed;
    bottom: var(--space-lg);
    right: var(--space-lg);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    color: white;
    border: none;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    z-index: 999;
}

/* ===== Error Messages ===== */
.error-message {
    background: #fee;
    color: var(--color-error);
    padding: var(--space-md);
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--color-error);
    margin-bottom: var(--space-md);
}

/* ===== Responsive Design ===== */
@media (max-width: 900px) {
    .editor-sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        z-index: 998;
        transition: left var(--transition-normal);
    }

    .editor-sidebar.open {
        left: 0;
    }

    .mobile-fab {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .menu-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .login-card {
        padding: var(--space-lg);
    }

    .app-title {
        font-size: 1.5rem;
    }

    .toolbar {
        padding: var(--space-sm);
    }

    .title-input {
        min-width: 120px;
        font-size: 0.95rem;
    }
}

/* ===== Print Styles ===== */
@media print {
    body {
        background: white;
    }

    .a4-page {
        width: 210mm;
        height: 297mm;
        margin: 0;
        box-shadow: none;
        page-break-after: always;
    }

    @page {
        size: A4;
        margin: 0;
    }
}
