/* ═══════════════════════════════════════════
   KlasaAI - Shared Styles (Chalkboard Theme)
   ═══════════════════════════════════════════ */

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

:root {
    --chalk: #F5F0E8;
    --board: #1A2B2E;
    --board-light: #243B3F;
    --board-lighter: #2D4A4F;
    --teal: #2DD4A8;
    --teal-dim: rgba(45, 212, 168, 0.12);
    --teal-hover: #25B891;
    --amber: #F5A623;
    --amber-dim: rgba(245, 166, 35, 0.12);
    --red: #EF4444;
    --red-dim: rgba(239, 68, 68, 0.12);
    --text: #E8E2D6;
    --text-dim: #9CA3AF;
    --text-muted: #6B7280;
    --border: rgba(255,255,255,0.08);
    --border-hover: rgba(255,255,255,0.15);
    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'DM Sans', sans-serif;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
}

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-body);
    background: var(--board);
    color: var(--text);
    overflow-x: hidden;
    line-height: 1.6;
    min-height: 100vh;
}

body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(45, 212, 168, 0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(245, 166, 35, 0.02) 0%, transparent 40%);
    pointer-events: none;
    z-index: 0;
}

/* ═══════════════════════════════════════════
   Typography
   ═══════════════════════════════════════════ */

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    color: var(--chalk);
    letter-spacing: -0.5px;
}

a {
    color: var(--teal);
    text-decoration: none;
    transition: color 0.2s;
}
a:hover { color: var(--teal-hover); }

/* ═══════════════════════════════════════════
   Navigation
   ═══════════════════════════════════════════ */

.app-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
    z-index: 10;
}

.logo {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--chalk);
    letter-spacing: -0.5px;
    text-decoration: none;
}
.logo span { color: var(--teal); }

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

.nav-user {
    font-size: 0.9rem;
    color: var(--text-dim);
}

/* ═══════════════════════════════════════════
   Buttons
   ═══════════════════════════════════════════ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
}

.btn-primary {
    background: var(--teal);
    color: var(--board);
    font-weight: 600;
}
.btn-primary:hover {
    background: var(--teal-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(45, 212, 168, 0.3);
}
.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: var(--board-light);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover {
    background: var(--board-lighter);
    border-color: var(--border-hover);
}

.btn-ghost {
    background: transparent;
    color: var(--text-dim);
    padding: 0.5rem 0.75rem;
}
.btn-ghost:hover {
    color: var(--text);
    background: rgba(255,255,255,0.05);
}

.btn-danger {
    background: var(--red-dim);
    color: var(--red);
    border: 1px solid rgba(239, 68, 68, 0.2);
}
.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

.btn-sm {
    padding: 0.4rem 0.85rem;
    font-size: 0.85rem;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.05rem;
}

/* ═══════════════════════════════════════════
   Forms
   ═══════════════════════════════════════════ */

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

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-dim);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--board);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px var(--teal-dim);
}

.form-input::placeholder, .form-textarea::placeholder {
    color: var(--text-muted);
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239CA3AF' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
    cursor: pointer;
}

.form-select option {
    background: var(--board);
    color: var(--text);
}

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

.form-error {
    color: var(--red);
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

.form-hint {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

/* ═══════════════════════════════════════════
   Cards
   ═══════════════════════════════════════════ */

.card {
    background: linear-gradient(135deg, var(--board-light), var(--board));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    transition: border-color 0.3s, transform 0.3s;
}

.card:hover {
    border-color: rgba(45, 212, 168, 0.2);
}

.card-clickable {
    cursor: pointer;
}
.card-clickable:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

/* ═══════════════════════════════════════════
   Tags/Badges
   ═══════════════════════════════════════════ */

.tag {
    display: inline-flex;
    align-items: center;
    font-size: 0.75rem;
    padding: 0.25rem 0.65rem;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    border-radius: 100px;
    color: var(--text-dim);
    font-weight: 500;
}

.tag-teal {
    color: var(--teal);
    background: var(--teal-dim);
    border-color: rgba(45, 212, 168, 0.15);
}

.tag-amber {
    color: var(--amber);
    background: var(--amber-dim);
    border-color: rgba(245, 166, 35, 0.15);
}

/* ═══════════════════════════════════════════
   Auth Page Layout
   ═══════════════════════════════════════════ */

.auth-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

.auth-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: linear-gradient(135deg, var(--board-light), var(--board));
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2.5rem;
    box-shadow: var(--shadow);
}

.auth-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-align: center;
}

.auth-subtitle {
    color: var(--text-dim);
    text-align: center;
    margin-bottom: 2rem;
    font-size: 0.95rem;
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-dim);
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}
.auth-divider::before, .auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* ═══════════════════════════════════════════
   App Layout
   ═══════════════════════════════════════════ */

.app-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

.app-content {
    flex: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem 2rem;
    width: 100%;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2rem;
}

.tab {
    padding: 0.85rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-dim);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: var(--font-body);
}

.tab:hover {
    color: var(--text);
}

.tab.active {
    color: var(--teal);
    border-bottom-color: var(--teal);
}

.tab-panel {
    display: none;
}
.tab-panel.active {
    display: block;
}

/* ═══════════════════════════════════════════
   Generator Section
   ═══════════════════════════════════════════ */

.generator-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 2rem;
    align-items: start;
}

.generator-form {
    position: sticky;
    top: 1rem;
}

.generator-form .card {
    padding: 1.75rem;
}

.generator-form h3 {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.generate-btn {
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.85rem;
    font-size: 1rem;
}

/* Result area */
.result-area {
    min-height: 400px;
}

.result-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    text-align: center;
    color: var(--text-dim);
    padding: 3rem;
}

.result-empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.result-empty h3 {
    font-size: 1.2rem;
    color: var(--text-dim);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.result-empty p {
    font-size: 0.9rem;
    max-width: 350px;
}

.result-card {
    background: linear-gradient(135deg, var(--board-light), var(--board));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: rgba(0,0,0,0.1);
}

.result-header-title {
    font-size: 0.85rem;
    color: var(--teal);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.result-actions {
    display: flex;
    gap: 0.5rem;
}

.result-content {
    padding: 2rem;
    line-height: 1.8;
    font-size: 0.95rem;
}

/* Markdown rendered content */
.result-content h1 {
    font-size: 1.6rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--teal-dim);
}

.result-content h2 {
    font-size: 1.2rem;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    color: var(--teal);
}

.result-content h3 {
    font-size: 1.05rem;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--amber);
}

.result-content p {
    margin-bottom: 0.75rem;
}

.result-content ul, .result-content ol {
    margin-bottom: 0.75rem;
    padding-left: 1.5rem;
}

.result-content li {
    margin-bottom: 0.35rem;
}

.result-content strong {
    color: var(--chalk);
}

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

/* Loading animation */
.generating-indicator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    color: var(--teal);
    font-size: 0.9rem;
    font-weight: 500;
}

.dot-pulse {
    display: inline-flex;
    gap: 4px;
}
.dot-pulse span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--teal);
    animation: pulse 1.4s infinite;
}
.dot-pulse span:nth-child(2) { animation-delay: 0.2s; }
.dot-pulse span:nth-child(3) { animation-delay: 0.4s; }

@keyframes pulse {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1); }
}

/* ═══════════════════════════════════════════
   Plans List (My Plans tab)
   ═══════════════════════════════════════════ */

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

.plans-count {
    font-size: 0.9rem;
    color: var(--text-dim);
}

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

.plan-card {
    padding: 1.5rem;
    cursor: pointer;
}

.plan-card-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.plan-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.plan-card-date {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.plan-card-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.plans-empty {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-dim);
}

.plans-empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}

.plans-empty h3 {
    color: var(--text-dim);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

/* ═══════════════════════════════════════════
   Plan View Modal
   ═══════════════════════════════════════════ */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 100;
    align-items: flex-start;
    justify-content: center;
    padding: 2rem;
    overflow-y: auto;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    width: 100%;
    max-width: 800px;
    background: var(--board);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    margin: 2rem 0;
    box-shadow: 0 16px 48px rgba(0,0,0,0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.75rem;
    border-bottom: 1px solid var(--border);
    background: var(--board-light);
}

.modal-header h2 {
    font-size: 1.15rem;
    font-weight: 600;
}

.modal-body {
    padding: 2rem;
    max-height: 70vh;
    overflow-y: auto;
}

.modal-body .result-content {
    padding: 0;
}

/* ═══════════════════════════════════════════
   Alerts
   ═══════════════════════════════════════════ */

.alert {
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    display: none;
}

.alert.show { display: block; }

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

.alert-success {
    background: var(--teal-dim);
    color: var(--teal);
    border: 1px solid rgba(45, 212, 168, 0.2);
}

/* ═══════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════ */

@media (max-width: 900px) {
    .generator-layout {
        grid-template-columns: 1fr;
    }

    .generator-form {
        position: static;
    }
}

@media (max-width: 640px) {
    .app-nav {
        padding: 1rem 1.25rem;
    }

    .app-content {
        padding: 0 1.25rem 1.25rem;
    }

    .auth-card {
        padding: 1.75rem;
    }

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

    .plans-grid {
        grid-template-columns: 1fr;
    }

    .modal {
        margin: 1rem 0;
    }

    .modal-body {
        padding: 1.25rem;
    }

    .result-content {
        padding: 1.25rem;
    }
}

/* ═══════════════════════════════════════════
   Print Styles
   ═══════════════════════════════════════════ */

@media print {
    body {
        background: white;
        color: #1a1a1a;
    }

    body::before { display: none; }

    .app-nav, .tabs, .generator-form, .result-actions,
    .btn, .modal-overlay { display: none !important; }

    .result-content {
        padding: 0;
    }

    .result-content h1 { color: #1a1a1a; border-bottom-color: #ccc; }
    .result-content h2 { color: #2DD4A8; }
    .result-content h3 { color: #F5A623; }
    .result-content strong { color: #1a1a1a; }
}

/* ═══════════════════════════════════════════
   Utilities
   ═══════════════════════════════════════════ */

.hidden { display: none !important; }
.text-center { text-align: center; }
.text-dim { color: var(--text-dim); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
