/* ═══ 逐夢 DreamApproach — Design System ═══ */
/* Aesthetic: 深夜書房 (Intimate Study) */

@import url('https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=DM+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --bg:           #0c0e1a;
    --bg-card:      #151828;
    --bg-input:     #1c2035;
    --bg-hover:     #212540;
    --text:         #e4e0ed;
    --text-muted:   #8b87a3;
    --text-dim:     #5a577a;
    --accent:       #6366f1;
    --accent-hover: #818cf8;
    --accent-glow:  rgba(99, 102, 241, 0.12);
    --warm:         #f5a623;
    --warm-glow:    rgba(245, 166, 35, 0.10);
    --border:       #2a2d45;
    --success:      #4ecb71;
    --danger:       #ff5c5c;
    --radius:       12px;
    --radius-sm:    8px;

    --font-display: 'Instrument Serif', Georgia, serif;
    --font-body:    'DM Sans', -apple-system, sans-serif;
    --font-mono:    'JetBrains Mono', monospace;
}

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

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

/* Paper texture overlay */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.02'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 9999;
}

/* ═══ Navbar ═══ */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    font-family: var(--font-display);
    font-size: 1.2rem;
    color: var(--accent);
    text-decoration: none;
}

.nav-links { display: flex; gap: 20px; align-items: center; }
.nav-links a { color: var(--text-muted); text-decoration: none; font-size: 0.85rem; transition: color 0.2s; }
.nav-links a:hover { color: var(--text); }
.nav-user { color: var(--text); font-size: 0.85rem; }
.nav-logout { color: var(--danger) !important; }

/* ═══ Container ═══ */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 32px 24px;
    flex: 1;
    width: 100%;
}

/* ═══ Cards ═══ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    margin-bottom: 20px;
}

.card-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 400;
    margin-bottom: 16px;
    color: var(--text);
}

/* ═══ Forms ═══ */
.form-group { margin-bottom: 20px; }

.form-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.95rem;
    font-family: var(--font-body);
    transition: border-color 0.2s;
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

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

.form-textarea {
    min-height: 180px;
    resize: vertical;
    line-height: 1.7;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 4px;
}

/* ═══ Buttons ═══ */
.btn {
    display: inline-block;
    padding: 12px 28px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    text-align: center;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-warm { background: var(--warm); color: #0c0e1a; }
.btn-warm:hover { background: #ffb940; }

.btn-outline {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
}
.btn-outline:hover { background: var(--accent-glow); }

.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); }

.btn-block { display: block; width: 100%; }

/* ═══ Tags ═══ */
.tag {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.tag-accent { background: var(--accent-glow); color: var(--accent-hover); border: 1px solid rgba(99, 102, 241, 0.3); }
.tag-warm { background: var(--warm-glow); color: var(--warm); border: 1px solid rgba(245, 166, 35, 0.3); }
.tag-muted { background: rgba(138, 135, 163, 0.08); color: var(--text-muted); border: 1px solid rgba(138, 135, 163, 0.2); }

/* ═══ Alerts ═══ */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 8px;
}

.alert-info { background: var(--accent-glow); border: 1px solid var(--accent); color: var(--accent-hover); }
.alert-success { background: rgba(78, 203, 113, 0.08); border: 1px solid var(--success); color: var(--success); }
.alert-warning { background: var(--warm-glow); border: 1px solid var(--warm); color: var(--warm); }
.alert-error { background: rgba(255, 92, 92, 0.08); border: 1px solid var(--danger); color: var(--danger); }

/* ═══ Dream Result ═══ */
.dream-result {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 36px;
    line-height: 1.9;
}

.dream-result h2 {
    font-family: var(--font-display);
    color: var(--warm);
    font-size: 1.4rem;
    font-weight: 400;
    margin-top: 32px;
    margin-bottom: 14px;
}

.dream-result h2:first-child { margin-top: 0; }

.dream-result h3 {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 1rem;
    margin-top: 20px;
    margin-bottom: 8px;
}

.dream-result p { margin-bottom: 14px; font-size: 0.95rem; }
.dream-result strong { color: var(--accent-hover); }

.dream-result table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 0.85rem;
}

.dream-result th,
.dream-result td {
    padding: 10px 14px;
    border: 1px solid var(--border);
    text-align: left;
}

.dream-result th {
    background: var(--bg-input);
    color: var(--text-muted);
    font-weight: 500;
}

.dream-result em { color: var(--text-muted); font-style: italic; }

.dream-result pre,
.dream-result code {
    background: var(--bg-input);
    border-radius: 6px;
    padding: 16px;
    overflow-x: auto;
    font-size: 0.85rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
}

/* ═══ Loading ═══ */
.loading { text-align: center; padding: 60px 20px; }

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

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

.loading-text { color: var(--text-muted); font-size: 0.95rem; }

/* ═══ Dream Journal ═══ */
.dream-list { list-style: none; }

.dream-item {
    display: block;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.2s, background 0.2s;
}

.dream-item:hover { border-color: var(--accent); background: var(--bg-hover); }

.dream-item-date {
    font-size: 0.75rem;
    color: var(--text-dim);
    font-family: var(--font-mono);
}

.dream-item-preview {
    margin-top: 4px;
    font-size: 0.9rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dream-item-tags { margin-top: 8px; display: flex; gap: 6px; }

/* ═══ MBTI Compass ═══ */
.compass-wrapper {
    display: flex;
    justify-content: center;
    padding: 40px 0;
}

.compass {
    position: relative;
    width: 340px;
    height: 340px;
}

.compass-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: radial-gradient(circle at center, var(--bg-card) 0%, var(--bg) 100%);
}

.compass-inner-ring {
    position: absolute;
    top: 40px; left: 40px;
    width: calc(100% - 80px);
    height: calc(100% - 80px);
    border-radius: 50%;
    border: 1px solid rgba(99, 102, 241, 0.15);
}

.compass-line-v {
    position: absolute;
    top: 40px; left: 50%;
    width: 1px;
    height: calc(100% - 80px);
    background: linear-gradient(to bottom, var(--accent), transparent 45%, transparent 55%, var(--accent));
    opacity: 0.3;
}

.compass-line-h {
    position: absolute;
    top: 50%; left: 40px;
    width: calc(100% - 80px);
    height: 1px;
    background: linear-gradient(to right, var(--accent), transparent 45%, transparent 55%, var(--accent));
    opacity: 0.3;
}

.compass-center {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 12px; height: 12px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.4), 0 0 40px rgba(99, 102, 241, 0.15);
    z-index: 3;
}

.compass-dot {
    position: absolute;
    width: 52px; height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
    z-index: 2;
    transform: translate(-50%, -50%);
    transition: box-shadow 0.3s;
}

.dot-hero {
    top: -26px; left: 170px;
    background: var(--accent); color: #fff;
    box-shadow: 0 0 24px rgba(99, 102, 241, 0.35);
}

.dot-second {
    top: 170px; left: -26px;
    background: rgba(78, 203, 113, 0.15); color: var(--success);
    border: 1px solid rgba(78, 203, 113, 0.35);
}

.dot-third {
    top: 170px; left: 366px;
    background: rgba(245, 166, 35, 0.12); color: var(--warm);
    border: 1px solid rgba(245, 166, 35, 0.3);
}

.dot-inferior {
    top: 366px; left: 170px;
    background: rgba(187, 136, 255, 0.12); color: #bb88ff;
    border: 1px solid rgba(187, 136, 255, 0.3);
}

.compass-func-label {
    position: absolute;
    text-align: center;
    z-index: 2;
    white-space: nowrap;
}

.compass-func-label .fl-name { font-size: 0.7rem; color: var(--text-muted); }
.compass-func-label .fl-role { font-family: var(--font-mono); font-size: 0.6rem; color: var(--text-dim); }

/* 標籤在羅盤內部，dot 和中心之間 */
.fl-hero    { top: 50px; left: 50%; transform: translateX(-50%); }
.fl-inferior { bottom: 50px; left: 50%; transform: translateX(-50%); }
.fl-second  { top: 50%; left: 60px; transform: translateY(-50%); }
.fl-third   { top: 50%; right: 60px; transform: translateY(-50%); }

.compass-tick {
    position: absolute;
    width: 1px;
    height: 8px;
    background: var(--border);
    top: 8px;
    left: 50%;
    transform-origin: 0 162px;
}

/* ═══ Pricing ═══ */
.pricing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin: 24px 0;
}

.pricing-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    text-align: center;
    transition: border-color 0.2s;
}

.pricing-card.featured {
    border-color: var(--warm);
    box-shadow: 0 0 24px var(--warm-glow);
}

.pricing-count {
    font-family: var(--font-display);
    font-size: 3rem;
    color: var(--accent);
}

.pricing-card.featured .pricing-count { color: var(--warm); }

.pricing-label { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 12px; }
.pricing-price { font-size: 1.3rem; font-weight: 700; margin-bottom: 4px; }
.pricing-per { font-size: 0.75rem; color: var(--text-dim); margin-bottom: 20px; }

/* ═══ Usage Badge ═══ */
.usage-badge {
    display: inline-block;
    padding: 4px 12px;
    background: var(--accent-glow);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--accent-hover);
}

/* ═══ Flash Messages ═══ */
.flash {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.flash-error { background: rgba(255, 92, 92, 0.08); border: 1px solid var(--danger); color: var(--danger); }
.flash-success { background: rgba(78, 203, 113, 0.08); border: 1px solid var(--success); color: var(--success); }

/* ═══ Footer ═══ */
.footer {
    text-align: center;
    padding: 24px;
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--text-dim);
}

.disclaimer { margin-top: 4px; font-size: 0.7rem; }

/* ═══ Responsive ═══ */
@media (max-width: 600px) {
    .container { padding: 20px 16px; }
    .card { padding: 20px; }
    .compass { transform: scale(0.8); transform-origin: center; }
    .navbar { padding: 12px 16px; }
    .nav-links { gap: 12px; }
    .nav-links a { font-size: 0.8rem; }
}
