/* ============================================================
   Tarot4You - Global Design Tokens & Base Styles
   Exact implementation of Figma design
   ============================================================ */

:root {
    /* Color tokens from design */
    --color-bg-dark: #202b22;
    --color-bg-dark-2: #2a3529;
    --color-bg-dark-3: #26372b;
    --color-bg-dark-4: #3d4f3f;
    --color-bg-cream: #f5efd9;
    --color-bg-cream-2: #e8dcc8;
    --color-bg-cream-3: #d5c6a5;
    --color-bg-cream-4: #e8d5b7;
    --color-gold: #d4b896;
    --color-gold-2: #c9b591;
    --color-gold-3: #a89876;
    --color-gold-4: #c9b591;
    --color-text-dark: #3d4f3f;
    --color-text-medium: #6b7f6a;
    --color-text-light: #f5efd9;
    --color-text-placeholder: #a89876;
    --color-border: #d4b896;
    --color-border-light: rgba(212, 184, 150, 0.3);
    --color-border-faint: rgba(212, 184, 150, 0.5);

    /* Typography */
    --font-serif: 'Georgia', 'Cormorant Garamond', 'Times New Roman', serif;
    --font-sans: system-ui, -apple-system, sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;

    /* Spacing */
    --radius-sm: 0.375rem;
    --radius-md: 0.625rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.4);
}

/* Base */
html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    font-family: var(--font-sans);
    font-size: 16px;
    background-color: var(--color-bg-dark);
    color: var(--color-text-light);
    /* Allow the page to scroll on devices where content exceeds the visible
       viewport (mobile browser chrome reduces the real height). Horizontal
       scrolling stays disabled so decorative corners never cause overflow. */
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

* {
    box-sizing: border-box;
}

*::-webkit-scrollbar {
    display: none;
}

* {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

/* ============================================================
   Auth screens (Login, Register, ForgotPassword)
   ============================================================ */
.auth-screen {
    min-height: 100dvh;
    background: linear-gradient(180deg, #e8dcc8 0%, #f5efd9 50%, #e8dcc8 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    /* Scroll when the form is taller than the visible viewport (small phones).
       min-height + overflow-y:auto avoids the flex-centering clip where the top
       of an over-tall centered child becomes unreachable. */
    overflow-x: hidden;
    overflow-y: auto;
    padding: 2rem 1rem;
    position: relative;
}

.auth-corner {
    position: absolute;
    width: 8rem;
    height: auto;
    pointer-events: none;
    z-index: 10;
}

.auth-corner--top-left { top: 0; left: 0; }
.auth-corner--top-right { top: 0; right: 0; }
.auth-corner--bottom-left { bottom: 0; left: 0; }
.auth-corner--bottom-right { bottom: 0; right: 0; }

.auth-container {
    width: 100%;
    max-width: 28rem;
    position: relative;
    z-index: 20;
}

.auth-form-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 3.5rem 2.5rem;
}

.auth-logo-decoration {
    width: 12rem;
    height: auto;
    margin-bottom: 0.5rem;
}

.auth-logo-text {
    width: 16rem;
    height: auto;
    margin-bottom: 1rem;
}

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

/* Input fields */
.auth-input-wrapper {
    position: relative;
    width: 100%;
}

.auth-input {
    width: 100%;
    padding: 0.875rem 3.5rem;
    background: rgba(245, 239, 217, 0.9);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-full);
    color: var(--color-text-dark);
    font-size: var(--font-size-sm);
    font-family: var(--font-sans);
    outline: none;
    transition: border-color 0.2s;
}

.auth-input::placeholder {
    color: var(--color-text-placeholder);
}

.auth-input:focus {
    border-color: #8a6d5b;
}

.auth-input-icon {
    position: absolute;
    left: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1.25rem;
    height: 1.25rem;
    color: var(--color-border);
    pointer-events: none;
}

.auth-input-toggle {
    position: absolute;
    right: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-border);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    transition: color 0.2s;
}

.auth-input-toggle:hover {
    color: #8a6d5b;
}

/* Primary button */
.btn-primary {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(to right, #3d4f3f, #2a3529);
    color: var(--color-gold);
    border-radius: var(--radius-full);
    border: 2px solid var(--color-border);
    font-family: var(--font-serif);
    font-size: var(--font-size-base);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow-card);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary:hover {
    background: linear-gradient(to right, #4d5f4f, #3a4539);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    width: 100%;
    padding: 0.875rem;
    background: rgba(245, 239, 217, 0.8);
    color: var(--color-text-dark);
    border-radius: var(--radius-full);
    border: 2px solid var(--color-border);
    font-family: var(--font-sans);
    font-size: var(--font-size-base);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-secondary:hover {
    background: rgba(245, 239, 217, 1);
}

.btn-link {
    background: none;
    border: none;
    color: var(--color-text-medium);
    font-size: var(--font-size-xs);
    cursor: pointer;
    transition: color 0.2s;
    padding: 0;
}

.btn-link:hover {
    color: #8a6d5b;
}

.auth-divider {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1.5rem 0;
}

.auth-divider-line {
    flex: 1;
    height: 1px;
    background: var(--color-border-light);
}

.auth-divider-text {
    color: var(--color-gold-3);
    font-size: var(--font-size-xs);
}

.auth-validation-error {
    color: #d4183d;
    font-size: var(--font-size-xs);
    text-align: center;
    margin-top: -0.5rem;
}

/* ============================================================
   Splash Screen
   ============================================================ */
.splash-screen {
    position: fixed;
    inset: 0;
    background-color: var(--color-bg-dark);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    z-index: 9999;
}

.splash-logo-decoration {
    width: 12rem;
    height: auto;
    animation: splashFadeIn 0.6s ease 0.2s both;
}

.splash-logo-text {
    width: 20rem;
    height: auto;
    animation: splashFadeIn 0.6s ease 0.4s both;
}

.splash-corner {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    width: 8rem;
    height: auto;
    opacity: 0.6;
    pointer-events: none;
}

@keyframes splashFadeIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

/* ============================================================
   Chat Interface
   ============================================================ */
.chat-screen {
    height: 100dvh;
    background-color: var(--color-bg-dark);
    padding: 2px;
}

.chat-frame {
    height: 100%;
    display: flex;
    flex-direction: column;
    border: 4px solid var(--color-gold);
    border-radius: 1.5rem;
    overflow: hidden;
    background-color: var(--color-bg-dark);
}

.chat-header {
    background-color: var(--color-bg-dark);
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chat-header-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chat-header-logo-img-small {
    width: 3rem;
    height: auto;
}

.chat-header-logo-img-text {
    height: 2.5rem;
    width: auto;
}

.chat-header-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.chat-header-user-info {
    text-align: right;
}

.chat-header-username {
    color: var(--color-gold);
    font-size: var(--font-size-sm);
}

.chat-header-credits {
    color: var(--color-gold-2);
    font-size: var(--font-size-xs);
}

.chat-menu-btn {
    color: var(--color-gold);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    transition: background-color 0.2s;
}

.chat-menu-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.chat-menu-dropdown {
    background-color: var(--color-bg-dark);
    border-bottom: 1px solid var(--color-border-light);
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex-shrink: 0;
}

.chat-menu-user {
    color: var(--color-gold);
    font-size: var(--font-size-sm);
}

.chat-menu-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    font-size: var(--font-size-sm);
    transition: color 0.2s;
    width: 100%;
}

.chat-menu-item--gold {
    color: var(--color-gold);
}

.chat-menu-item--gold:hover {
    color: var(--color-gold-2);
}

.chat-menu-item--danger {
    color: #d89b9b;
}

.chat-menu-item--danger:hover {
    color: #e8abab;
}

.chat-messages-area {
    flex: 1;
    overflow: hidden;
    padding: 1rem;
    min-height: 0;
}

.chat-messages-inner {
    height: 100%;
    background-color: var(--color-bg-cream-3);
    border-radius: 1.5rem;
    border: 3px solid #7d6436;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    font-family: var(--font-serif);
}

.chat-input-area {
    background-color: var(--color-bg-dark);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-shrink: 0;
}

.chat-input-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.chat-input {
    flex: 1;
    padding: 0.75rem 1rem;
    background-color: var(--color-bg-dark-2);
    border: 2px solid var(--color-border-faint);
    border-radius: var(--radius-full);
    color: var(--color-bg-cream);
    font-family: var(--font-sans);
    font-size: var(--font-size-sm);
    outline: none;
    transition: border-color 0.2s;
}

.chat-input::placeholder {
    color: rgba(201, 181, 145, 0.5);
}

.chat-input:focus {
    border-color: var(--color-gold);
}

.chat-send-btn {
    width: 3.5rem;
    height: 3.5rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    transition: transform 0.2s, opacity 0.2s;
    flex-shrink: 0;
}

.chat-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-send-btn img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.chat-target-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.chat-target-btn {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    white-space: nowrap;
}

.chat-target-btn--active {
    background-color: var(--color-gold);
    color: var(--color-bg-dark);
}

.chat-target-btn--inactive {
    background-color: var(--color-bg-dark-2);
    color: var(--color-gold-2);
    border: 1px solid var(--color-border-light);
}

.chat-other-fields {
    display: flex;
    gap: 0.5rem;
    flex: 1;
    flex-wrap: wrap;
}

.chat-other-input {
    padding: 0.5rem 0.75rem;
    background-color: var(--color-bg-dark-2);
    border: 1px solid var(--color-border-faint);
    border-radius: var(--radius-full);
    color: var(--color-bg-cream);
    font-size: var(--font-size-xs);
    outline: none;
    transition: border-color 0.2s;
    min-width: 0;
}

.chat-other-input:focus {
    border-color: var(--color-gold);
}

/* ============================================================
   Chat Messages
   ============================================================ */
.message-row {
    display: flex;
}

.message-row--user { justify-content: flex-end; }
.message-row--ai { justify-content: flex-start; }

.message-bubble {
    border-radius: 1rem;
    padding: 0.75rem 1rem;
    position: relative;
    border: 3px double var(--color-border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.message-bubble--user {
    background-color: var(--color-bg-dark-3);
    color: var(--color-bg-cream);
    border-radius: 1rem 1rem 0.25rem 1rem;
    max-width: 85%;
}

.message-bubble--ai-light {
    background-color: var(--color-bg-cream);
    color: var(--color-text-dark);
    border-radius: 1rem 1rem 1rem 0.25rem;
    width: 100%;
}

.message-bubble--ai-dark {
    background-color: var(--color-bg-dark-3);
    color: var(--color-bg-cream);
    border-radius: 1rem 1rem 1rem 0.25rem;
    width: 100%;
}

.message-text {
    white-space: pre-wrap;
    line-height: 1.6;
}

.message-decoration {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 4rem;
    height: auto;
    opacity: 0.6;
    pointer-events: none;
}

.typing-indicator {
    display: flex;
    justify-content: flex-start;
}

.typing-bubble {
    background-color: var(--color-bg-cream);
    border-radius: 1rem;
    border-radius: 1rem 1rem 1rem 0.25rem;
    padding: 0.75rem 1rem;
    border: 3px double var(--color-border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.typing-dots {
    display: flex;
    gap: 0.25rem;
}

.typing-dot {
    width: 0.5rem;
    height: 0.5rem;
    background-color: var(--color-gold-2);
    border-radius: 50%;
    animation: bounce 1.2s ease infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-0.5rem); }
}

/* ============================================================
   Tarot Cards
   ============================================================ */
.cards-container {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    padding: 4rem 1rem;
    flex-wrap: nowrap;
    overflow-x: auto;
}

.tarot-card-wrapper {
    position: relative;
    flex-shrink: 0;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.tarot-card-wrapper:hover {
    transform: scale(1.8);
    z-index: 9999;
}

.tarot-card {
    width: 6rem;
    height: 9rem;
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.tarot-card--reversed {
    transform: rotate(180deg);
}

.tarot-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ============================================================
   Celtic Cross Layout
   ============================================================ */
.celtic-cross {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(5, auto);
    gap: 0.5rem;
    padding: 1rem;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
}

/* ============================================================
   Payment / Pricing Screen
   ============================================================ */
.payment-screen {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    position: relative;
    overflow-x: hidden;
    overflow-y: auto;
    background: linear-gradient(135deg, #f5efd9 0%, #e8d5b7 50%, #f5efd9 100%);
}

.payment-card {
    width: 100%;
    max-width: 42rem;
    position: relative;
    z-index: 10;
}

.payment-logo-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 2rem;
}

.payment-logo-decoration {
    width: 8rem;
    height: auto;
    margin-bottom: 1rem;
}

.payment-logo-text {
    height: 4rem;
    width: auto;
}

.payment-panel {
    background: rgba(32, 43, 34, 0.95);
    border-radius: 1.5rem;
    padding: 2rem;
    border: 4px double var(--color-gold);
    box-shadow: var(--shadow-lg);
}

.payment-panel-title {
    color: var(--color-gold);
    font-size: var(--font-size-2xl);
    text-align: center;
    margin-bottom: 1.5rem;
    font-family: var(--font-serif);
}

.payment-section-title {
    color: var(--color-gold);
    font-size: var(--font-size-xl);
    margin-bottom: 1rem;
    font-family: var(--font-serif);
}

.payment-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.payment-option {
    width: 100%;
    padding: 1rem;
    border-radius: 0.75rem;
    border: 2px solid;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.payment-option--selected {
    background-color: var(--color-gold);
    color: var(--color-bg-dark);
    border-color: var(--color-gold);
}

.payment-option--unselected {
    background-color: var(--color-bg-dark-3);
    color: var(--color-bg-cream);
    border-color: var(--color-border-faint);
}

.payment-option--unselected:hover {
    border-color: var(--color-gold);
}

.payment-option-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.payment-option-name { font-weight: 600; }
.payment-option-price { font-weight: 700; }
.payment-option-detail { font-size: var(--font-size-sm); opacity: 0.8; text-align: right; }

.payment-actions {
    display: flex;
    gap: 0.75rem;
}

.payment-btn-back {
    flex: 1;
    background-color: var(--color-bg-dark-3);
    color: var(--color-bg-cream);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-full);
    border: 2px solid var(--color-border-faint);
    cursor: pointer;
    transition: border-color 0.2s;
    font-size: var(--font-size-base);
}

.payment-btn-back:hover {
    border-color: var(--color-gold);
}

.payment-btn-pay {
    flex: 1;
    background-color: var(--color-gold);
    color: var(--color-bg-dark);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-full);
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: var(--font-size-base);
    font-weight: 600;
}

.payment-btn-pay:hover:not(:disabled) {
    background-color: var(--color-gold-2);
}

.payment-btn-pay:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================================
   Validation Error Messages
   ============================================================ */
.validation-message {
    color: #d4183d;
    font-size: var(--font-size-xs);
    margin-top: 0.25rem;
    padding-left: 0.5rem;
}

/* ============================================================
   Loading state
   ============================================================ */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(32, 43, 34, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-spinner {
    width: 3rem;
    height: 3rem;
    border: 3px solid var(--color-border-light);
    border-top-color: var(--color-gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ============================================================
   Error Alert
   ============================================================ */
.alert-error {
    background: rgba(212, 24, 61, 0.15);
    border: 1px solid #d4183d;
    border-radius: var(--radius-md);
    color: #ff6b6b;
    padding: 0.75rem 1rem;
    font-size: var(--font-size-sm);
    margin-bottom: 1rem;
    text-align: center;
}

.alert-success {
    background: rgba(61, 79, 63, 0.3);
    border: 1px solid var(--color-gold);
    border-radius: var(--radius-md);
    color: var(--color-gold);
    padding: 0.75rem 1rem;
    font-size: var(--font-size-sm);
    margin-bottom: 1rem;
    text-align: center;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 640px) {
    .auth-form-wrapper {
        padding: 1.5rem 1.25rem;
    }

    .auth-logo-decoration { width: 9rem; }
    .auth-logo-text { width: 13rem; }
    .auth-subtitle { margin-bottom: 1.25rem; }

    .payment-panel {
        padding: 1.5rem 1.25rem;
    }

    .cards-container {
        padding: 3rem 0.5rem;
    }

    /* Smaller decorative corners so they don't crowd the form on phones */
    .auth-corner { width: 5rem; }

    /* Chat takes the real visible height and respects the notch / home bar */
    .chat-screen {
        padding: 0;
    }

    .chat-frame {
        border-width: 2px;
        border-radius: 0;
    }

    .chat-header { padding: 0.75rem; }
    .chat-messages-area { padding: 0.625rem; }

    .chat-input-area {
        padding: 0.75rem;
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
    }

    /* Slightly smaller cards so a three-card spread fits the width */
    .tarot-card { width: 5rem; height: 7.5rem; }
}

/* Disable the hover-zoom on touch devices (it can push cards off-screen) */
@media (hover: none) {
    .tarot-card-wrapper:hover { transform: none; }
}
