/* ========================================
   Zodiakku - Mobile First CSS
   Optimized for WebView APK
   ======================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

:root {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --secondary: #ec4899;
    --accent: #fbbf24;
    --bg-dark: #0f0f23;
    --bg-card: rgba(30, 30, 60, 0.9);
    --text-light: #f8fafc;
    --text-muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.1);

    /* Safe area for notch devices */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #0f0f23 0%, #1a1a3e 50%, #0f0f23 100%);
    min-height: 100vh;
    min-height: -webkit-fill-available;
    color: var(--text-light);
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
    padding-left: var(--safe-left);
    padding-right: var(--safe-right);
}

/* Disable pull-to-refresh */
body {
    overscroll-behavior-y: contain;
}

/* Stars Background */
.stars {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background-image:
        radial-gradient(2px 2px at 20px 30px, #fff, transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255,255,255,0.8), transparent),
        radial-gradient(1px 1px at 90px 40px, #fff, transparent),
        radial-gradient(2px 2px at 130px 80px, rgba(255,255,255,0.6), transparent),
        radial-gradient(1px 1px at 160px 120px, #fff, transparent),
        radial-gradient(2px 2px at 200px 50px, rgba(255,255,255,0.7), transparent),
        radial-gradient(1px 1px at 250px 160px, #fff, transparent),
        radial-gradient(2px 2px at 300px 100px, rgba(255,255,255,0.5), transparent);
    background-size: 350px 250px;
    animation: twinkle 8s ease-in-out infinite;
    z-index: 0;
}

@keyframes twinkle {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Container */
.container {
    max-width: 100%;
    width: 100%;
    margin: 0 auto;
    padding: 20px 16px;
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 24px;
    padding-top: 10px;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 6px;
    letter-spacing: -0.5px;
}

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

/* Main */
main {
    flex: 1;
}

/* Form Styles */
.zodiac-form {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 24px 20px;
    border: 1px solid var(--border);
    box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.5);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-light);
    font-size: 0.9rem;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 16px;
    border: 2px solid var(--border);
    border-radius: 14px;
    background: rgba(15, 15, 35, 0.7);
    color: var(--text-light);
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.3s ease;
    /* Touch friendly */
    min-height: 54px;
    -webkit-appearance: none;
    appearance: none;
}

.form-group select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 20px;
    padding-right: 48px;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.25);
}

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

.form-group select option {
    background: var(--bg-dark);
    color: var(--text-light);
    padding: 12px;
}

/* Form Row - Stack on mobile */
.form-row {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Submit Button */
.btn-submit {
    width: 100%;
    padding: 18px 32px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    border-radius: 14px;
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s ease;
    font-family: inherit;
    margin-top: 8px;
    min-height: 56px;
    /* Touch feedback */
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.btn-submit:active {
    transform: scale(0.98);
    opacity: 0.9;
}

.btn-icon {
    font-size: 1.4rem;
}

/* Loading State */
.loading {
    text-align: center;
    padding: 80px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

.spinner {
    width: 56px;
    height: 56px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    margin-bottom: 20px;
    animation: spin 1s linear infinite;
}

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

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

/* Result Section */
.result {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 24px 20px;
    border: 1px solid var(--border);
    box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.5);
}

.zodiac-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.zodiac-icon {
    width: 90px;
    height: 90px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.8rem;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
}

.zodiac-info h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.zodiac-info h3 {
    font-size: 1.3rem;
    font-weight: 500;
    color: var(--accent);
    margin-bottom: 4px;
}

.zodiac-info p {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Horoscope Grid - Single column on mobile */
.horoscope-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.horoscope-card {
    background: rgba(15, 15, 35, 0.7);
    border-radius: 16px;
    padding: 20px;
    border: 1px solid var(--border);
    transition: transform 0.2s ease;
}

.horoscope-card:active {
    transform: scale(0.98);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.card-icon {
    font-size: 1.4rem;
}

.card-header h4 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-light);
}

.horoscope-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.7;
}

.horoscope-card.general { border-left: 4px solid var(--accent); }
.horoscope-card.love { border-left: 4px solid var(--secondary); }
.horoscope-card.career { border-left: 4px solid var(--primary); }
.horoscope-card.health { border-left: 4px solid #10b981; }

/* Lucky Section */
.lucky-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px;
    background: rgba(15, 15, 35, 0.7);
    border-radius: 16px;
    margin-bottom: 20px;
}

.lucky-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.lucky-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.lucky-item:first-child {
    padding-top: 0;
}

.lucky-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.lucky-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent);
}

/* Buttons */
.btn-back,
.btn-retry {
    width: 100%;
    padding: 16px 28px;
    background: transparent;
    border: 2px solid var(--primary);
    border-radius: 14px;
    color: var(--primary-light);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    min-height: 54px;
    touch-action: manipulation;
}

.btn-back:active,
.btn-retry:active {
    background: var(--primary);
    color: white;
    transform: scale(0.98);
}

/* Error State */
.error {
    text-align: center;
    padding: 60px 20px;
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.error-icon {
    font-size: 3.5rem;
    margin-bottom: 16px;
}

.error p {
    color: var(--text-muted);
    font-size: 1rem;
    margin-bottom: 24px;
    line-height: 1.6;
}

/* Footer */
footer {
    text-align: center;
    margin-top: auto;
    padding: 20px 0 10px;
}

footer p {
    color: var(--text-muted);
    font-size: 0.75rem;
    opacity: 0.7;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result:not(.hidden),
.error:not(.hidden) {
    animation: slideUp 0.4s ease-out;
}

.zodiac-form {
    animation: fadeIn 0.3s ease-out;
}

/* ========================================
   Tablet / Larger Mobile (min-width: 480px)
   ======================================== */
@media (min-width: 480px) {
    .container {
        padding: 24px 20px;
        max-width: 480px;
    }

    header h1 {
        font-size: 2.8rem;
    }

    .form-row {
        flex-direction: row;
        gap: 12px;
    }

    .form-row .form-group {
        flex: 1;
        margin-bottom: 20px;
    }

    .zodiac-header {
        flex-direction: row;
        text-align: left;
        gap: 20px;
    }

    .zodiac-icon {
        width: 80px;
        height: 80px;
        font-size: 2.5rem;
    }

    .lucky-section {
        flex-direction: row;
        justify-content: space-around;
    }

    .lucky-item {
        flex-direction: column;
        text-align: center;
        border-bottom: none;
        padding: 0;
    }

    .lucky-label {
        margin-bottom: 6px;
    }
}

/* ========================================
   Tablet (min-width: 600px)
   ======================================== */
@media (min-width: 600px) {
    .container {
        max-width: 560px;
        padding: 30px 24px;
    }

    .zodiac-form,
    .result {
        padding: 32px 28px;
    }

    .horoscope-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    .zodiac-icon {
        width: 90px;
        height: 90px;
        font-size: 2.8rem;
    }
}

/* ========================================
   Landscape Mode Adjustments
   ======================================== */
@media (max-height: 500px) and (orientation: landscape) {
    .container {
        padding: 12px 20px;
    }

    header {
        margin-bottom: 16px;
    }

    header h1 {
        font-size: 2rem;
    }

    .zodiac-form {
        padding: 16px;
    }

    .form-group {
        margin-bottom: 12px;
    }

    .form-row {
        flex-direction: row;
        gap: 12px;
    }

    .form-row .form-group {
        margin-bottom: 12px;
    }

    .btn-submit {
        padding: 14px 24px;
        min-height: 48px;
    }

    .loading {
        padding: 40px 20px;
        min-height: 200px;
    }
}

/* ========================================
   Dark Mode / OLED Optimization
   ======================================== */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-dark: #000000;
        --bg-card: rgba(20, 20, 40, 0.95);
    }
}

/* ========================================
   Reduce Motion for Accessibility
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .stars {
        animation: none;
    }
}

/* ========================================
   High Contrast Mode
   ======================================== */
@media (prefers-contrast: high) {
    .form-group input,
    .form-group select {
        border-width: 3px;
    }

    .horoscope-card {
        border-width: 2px;
    }
}

/* ========================================
   Print Styles (for sharing)
   ======================================== */
@media print {
    .stars,
    .btn-back,
    .btn-submit,
    footer {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }

    .result {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}
