:root {
    --primary: #D4AF37;
    /* Gold */
    --primary-light: #F1D592;
    --bg-deep: #0F0C29;
    --bg-mid: #302B63;
    --bg-light: #24243E;
    --text-primary: #FFFFFF;
    --text-secondary: #E0E0E0;
    --text-muted: #BDBDBD;
    --glass: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.12);
    --accent-purple: #8E24AA;
    --gold-gradient: linear-gradient(135deg, #D4AF37 0%, #F1D592 50%, #D4AF37 100%);
    --mystic-gradient: linear-gradient(180deg, #0F0C29 0%, #302B63 50%, #24243E 100%);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Tajawal', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: var(--bg-deep);
    background: var(--mystic-gradient);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

.app-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    padding-bottom: 100px;
    /* Space for bottom nav */
}

/* --- Components --- */

/* Header */
header {
    text-align: center;
    padding: 30px 0 20px;
}

header h1 {
    font-size: 32px;
    font-weight: 800;
    background: var(--gold-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 5px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

header p {
    font-size: 14px;
    color: var(--primary-light);
    letter-spacing: 1px;
    opacity: 0.9;
}

/* Glass Card */
.glass-card {
    background: var(--glass);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 20px;
    margin-bottom: 20px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.glass-card:active {
    transform: scale(0.98);
}

/* Feature Grid */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 30px;
}

.feature-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 140px;
    text-align: center;
    text-decoration: none; /* Added for links */
}

.feature-icon {
    font-size: 40px;
    margin-bottom: 10px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.feature-title {
    font-weight: 700;
    font-size: 16px;
    color: var(--primary-light);
}

.feature-desc {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Section Title */
.section-title {
    font-size: 20px;
    font-weight: 700;
    margin: 25px 0 15px;
    border-right: 4px solid var(--primary);
    padding-right: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Zodiac Grid */
.zodiac-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.zodiac-card {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
    cursor: pointer;
}

.zodiac-icon {
    font-size: 36px;
    margin-bottom: 5px;
}

.zodiac-name {
    font-size: 14px;
    font-weight: 600;
}

/* --- Views --- */
.view {
    display: none;
    animation: fadeIn 0.4s ease-out;
}

.view.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Detail View Styles */
.detail-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 25px;
}

.detail-icon {
    font-size: 80px;
    background: rgba(255, 255, 255, 0.05);
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 30px;
    border: 1px solid var(--glass-border);
}

.detail-names h2 {
    font-size: 32px;
    background: var(--gold-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.detail-names p {
    font-size: 18px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.fact-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 25px;
}

.fact-item {
    text-align: center;
    padding: 12px;
}

.fact-label {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.fact-value {
    font-weight: 600;
    color: var(--primary-light);
    font-size: 14px;
}

/* Accordion */
.accordion-item {
    margin-bottom: 15px;
}

.accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    cursor: pointer;
}

.accordion-content {
    padding: 0 15px 15px;
    display: none;
    color: var(--text-secondary);
    font-size: 14px;
}

/* AI Feature Generic */
.ai-input-group {
    margin-bottom: 20px;
}

.ai-input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--primary-light);
}

textarea,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
select {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 12px;
    color: #fff;
    font-size: 16px;
    outline: none;
}

/* Auth & Profile Styles */
.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-header .auth-icon {
    font-size: 60px;
    display: block;
    margin-bottom: 10px;
    filter: drop-shadow(0 4px 12px rgba(212, 175, 55, 0.4));
}

.auth-header h2 {
    font-size: 26px;
    font-weight: 800;
    background: var(--gold-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-header p {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 5px;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--primary-light);
    font-size: 14px;
}

.form-error {
    color: #ff6b6b;
    font-size: 12px;
    margin-top: 4px;
    display: none;
}

.toggle-group {
    display: flex;
    gap: 8px;
}

.toggle-btn {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: all 0.3s ease;
}

.toggle-btn.selected {
    background: rgba(212, 175, 55, 0.2);
    border-color: var(--primary);
    color: var(--primary-light);
}

.auth-link {
    text-align: center;
    margin-top: 20px;
    color: var(--text-muted);
    font-size: 14px;
}

.auth-link a {
    color: var(--primary);
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.auth-message {
    padding: 12px;
    border-radius: 10px;
    text-align: center;
    font-size: 14px;
    margin-bottom: 15px;
    display: none;
}

.auth-message.success {
    background: rgba(39, 174, 96, 0.15);
    border: 1px solid rgba(39, 174, 96, 0.3);
    color: #2ecc71;
    display: block;
}

.auth-message.error {
    background: rgba(231, 76, 60, 0.15);
    border: 1px solid rgba(231, 76, 60, 0.3);
    color: #e74c3c;
    display: block;
}

/* Profile card */
.profile-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--gold-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    margin: 0 auto 15px;
    box-shadow: 0 8px 25px rgba(212, 175, 55, 0.3);
}

.profile-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 20px;
}

.profile-info-item {
    background: rgba(0, 0, 0, 0.15);
    padding: 14px;
    border-radius: 12px;
    text-align: center;
}

.profile-info-item .info-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.profile-info-item .info-value {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary-light);
}

.btn-logout {
    background: rgba(231, 76, 60, 0.15);
    border: 1px solid rgba(231, 76, 60, 0.3);
    color: #e74c3c;
    border-radius: 12px;
    padding: 14px;
    width: 100%;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    margin-top: 20px;
    transition: all 0.3s ease;
}

.btn-logout:hover {
    background: rgba(231, 76, 60, 0.25);
}

.btn-secondary {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 14px;
    width: 100%;
    font-weight: 700;
    font-size: 15px;
    color: var(--primary-light);
    cursor: pointer;
    margin-top: 10px;
    transition: all 0.3s ease;
}

.btn-primary {
    background: var(--gold-gradient);
    border: none;
    border-radius: 12px;
    padding: 15px;
    width: 100%;
    font-weight: 700;
    font-size: 16px;
    color: #000;
    cursor: pointer;
    margin-top: 10px;
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.ai-result {
    margin-top: 25px;
    white-space: pre-wrap;
    line-height: 1.8;
    font-size: 15px;
}

/* Bottom Nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 600px;
    background: rgba(15, 12, 41, 0.95);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-around;
    padding: 10px 0 25px;
    z-index: 1000;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 11px;
    font-weight: 500;
}

.nav-item.active {
    color: var(--primary);
}

.nav-icon {
    font-size: 24px;
    margin-bottom: 4px;
}

/* Back Button */
.back-btn {
    position: sticky;
    top: 10px;
    z-index: 100;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(10px);
    text-decoration: none;
    color: inherit;
}

/* Loading */
#loader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-deep);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(212, 175, 55, 0.1);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

/* Articles */
.article-card {
    display: flex;
    gap: 15px;
    align-items: center;
    cursor: pointer;
}

.article-img {
    width: 80px;
    height: 80px;
    border-radius: 16px;
    object-fit: cover;
    background: #333;
}

.article-info h4 {
    font-size: 16px;
    margin-bottom: 4px;
}

.article-info p {
    font-size: 12px;
    color: var(--text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Tarot Redesign */
.tarot-area {
    perspective: 1000px;
    margin-top: 20px;
    text-align: center;
}

.tarot-deck {
    display: flex;
    justify-content: center;
    gap: -20px;
    margin-bottom: 40px;
    height: 150px;
    position: relative;
}

.tarot-card {
    width: 80px;
    height: 130px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.tarot-card.flipped {
    transform: rotateY(180deg);
}

.tarot-card.selected-anim {
    position: absolute;
    z-index: 100;
    transition: all 0.5s ease-in-out;
}

.tarot-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
}

.tarot-card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--primary);
}

.tarot-card-back {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    background-image:
        radial-gradient(circle at 50% 50%, rgba(212, 175, 55, 0.1) 0%, transparent 50%),
        url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M20 0l2 18 18 2-18 2-2 18-2-18-18-2 18-2z' fill='%23d4af37' fill-opacity='0.1' fill-rule='evenodd'/%3E%3C/svg%3E");
}

.tarot-card-front {
    background: var(--bg-light);
    transform: rotateY(180deg);
    font-size: 40px;
}

.tarot-slots {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 30px;
}

.tarot-slot {
    height: 150px;
    border: 2px dashed rgba(212, 175, 55, 0.2);
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.tarot-slot-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 10px;
    position: absolute;
    bottom: -25px;
}

.tarot-card-back::after {
    content: '✨';
    font-size: 24px;
    color: var(--primary);
}

.tarot-deck .tarot-card {
    margin-left: -30px;
    transform: rotate(calc(var(--r) * 1deg)) translateY(calc(var(--y) * 1px));
}

.tarot-deck .tarot-card:hover {
    transform: rotate(calc(var(--r) * 1deg)) translateY(calc(var(--y) * 1px - 20px)) scale(1.1);
    z-index: 50;
}

@media (max-width: 480px) {
    header h1 {
        font-size: 28px;
    }
    .feature-card {
        height: 120px;
    }
    .feature-icon {
        font-size: 32px;
    }
    .zodiac-icon {
        font-size: 30px;
    }
}
