/* ===== CSS Variables ===== */
:root {
    --dark-bg-start: #0a0a23;
    --dark-bg-mid: #12123a;
    --dark-bg-end: #1a1a4e;
    --gold: #e9c46a;
    --gold-bright: #FFD700;
    --gold-hover: #f4a261;
    --gold-dim: rgba(233, 196, 106, 0.15);
    --white: #ffffff;
    --glass-bg: rgba(255, 255, 255, 0.04);
    --glass-bg-hover: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --radius-sm: 12px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-full: 50px;
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-spring: 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
}

/* ===== Reset & Base ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: 'Tajawal', 'Cairo', sans-serif;
    background: linear-gradient(160deg, var(--dark-bg-start) 0%, var(--dark-bg-mid) 50%, var(--dark-bg-end) 100%);
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    padding: 1.5rem 1rem;
    padding-top: calc(1.5rem + var(--safe-top));
    padding-bottom: calc(1.5rem + var(--safe-bottom));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    color: var(--white);
    overflow-x: hidden;
    position: relative;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== Stars Background ===== */
.stars {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    contain: strict;
}

.star {
    position: absolute;
    background: white;
    border-radius: 50%;
    will-change: opacity;
    animation: twinkle linear infinite;
}

@keyframes twinkle {
    0%, 100% {
        opacity: 0.15;
    }
    50% {
        opacity: 0.7;
    }
}

/* ===== Floating Particles ===== */
.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    contain: strict;
}

.particle {
    position: absolute;
    border-radius: 50%;
    will-change: transform, opacity;
    animation: floatUp linear infinite;
}

@keyframes floatUp {
    0% {
        transform: translateY(100vh) scale(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-10vh) scale(1);
        opacity: 0;
    }
}

/* ===== Main Container ===== */
.container {
    width: 100%;
    max-width: 520px;
    text-align: center;
    padding: 2rem 1.5rem;
    z-index: 10;
    position: relative;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow);
    animation: fadeIn 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ===== Header Section ===== */
.header-section {
    margin-bottom: 2rem;
}

.crescent-icon {
    margin-bottom: 0.75rem;
    animation: gentleFloat 4s ease-in-out infinite;
}

@keyframes gentleFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.crescent-icon svg {
    filter: drop-shadow(0 0 12px rgba(255, 215, 0, 0.4));
}

h1 {
    font-size: 2rem;
    font-weight: 900;
    margin: 0 0 0.5rem;
    line-height: 1.3;
    background: linear-gradient(180deg, #FFD700 0%, #FDB931 40%, #e9c46a 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.subtitle {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.5);
    margin: 0;
    font-weight: 400;
}

/* ===== Input Section ===== */
.input-section {
    margin-bottom: 0.5rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.input-wrapper {
    position: relative;
    width: 100%;
}

.input-wrapper input {
    width: 100%;
    padding: 14px 20px;
    padding-left: 48px;
    border-radius: var(--radius-md);
    border: 1.5px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.25);
    color: var(--white);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    text-align: right;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.input-wrapper input:focus {
    border-color: var(--gold);
    background: rgba(0, 0, 0, 0.35);
    box-shadow: 0 0 0 3px var(--gold-dim), 0 0 20px rgba(233, 196, 106, 0.1);
}

.input-wrapper input::placeholder {
    color: rgba(255, 255, 255, 0.35);
    font-weight: 400;
}

.input-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.3);
    transition: color var(--transition-fast);
    display: flex;
    pointer-events: none;
}

.input-wrapper input:focus ~ .input-icon {
    color: var(--gold);
}

/* ===== Primary Button ===== */
.primary-btn {
    width: 100%;
    padding: 14px 24px;
    border-radius: var(--radius-md);
    border: none;
    background: linear-gradient(135deg, #FFD700 0%, #FDB931 50%, #e9a000 100%);
    color: #1a0533;
    font-weight: 700;
    font-family: inherit;
    font-size: 1.05rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
    touch-action: manipulation;
    -webkit-appearance: none;
    appearance: none;
    min-height: 50px;
}

.primary-btn:active {
    transform: scale(0.97);
}

.primary-btn .btn-loader {
    display: none;
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(26, 5, 51, 0.2);
    border-top-color: #1a0533;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.primary-btn.loading .btn-text {
    display: none;
}

.primary-btn.loading .btn-loader {
    display: block;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Shimmer effect on button */
.primary-btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.3), transparent);
    transform: skewX(-25deg);
    animation: shimmer 4s ease-in-out infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    15% { left: 100%; }
    100% { left: 100%; }
}

/* ===== Error Message ===== */
.error-msg {
    color: #ff6b6b;
    margin-top: 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
    opacity: 0;
    transform: translateY(-4px);
    transition: all var(--transition-fast);
    min-height: 1.2rem;
}

.error-msg.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ===== Canvas Section ===== */
.canvas-section {
    display: none;
}

.canvas-section.visible {
    display: block;
    animation: revealCard 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes revealCard {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.canvas-wrapper {
    margin-top: 1.5rem;
    position: relative;
    display: flex;
    justify-content: center;
    border-radius: var(--radius-md);
    overflow: hidden;
}

canvas {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: var(--radius-md);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

/* ===== Action Buttons ===== */
.actions {
    margin-top: 1rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.action-btn {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border: none;
    color: white;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    touch-action: manipulation;
    -webkit-appearance: none;
    appearance: none;
    min-height: 48px;
}

.action-btn:active {
    transform: scale(0.96);
}

.action-btn svg {
    flex-shrink: 0;
}

.download-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.whatsapp-btn {
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
}

/* ===== Site Footer ===== */
.site-footer {
    margin-top: 2rem;
    padding: 1.25rem 1rem;
    padding-bottom: calc(1.25rem + var(--safe-bottom));
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.8rem;
    width: 100%;
    z-index: 10;
}

.site-footer p {
    margin: 0;
}

.site-footer a {
    color: var(--gold);
    text-decoration: none;
    font-weight: 600;
    transition: color var(--transition-fast);
}

.site-footer a:hover {
    color: var(--gold-hover);
}

.support-info {
    margin-top: 0.4rem !important;
    font-size: 0.75rem;
    opacity: 0.7;
}

/* ===== Responsive - Tablet and up ===== */
@media (min-width: 600px) {
    body {
        padding: 2rem;
        justify-content: center;
    }

    .container {
        max-width: 560px;
        padding: 2.5rem 2rem;
    }

    h1 {
        font-size: 2.5rem;
    }

    .subtitle {
        font-size: 1.05rem;
    }

    .input-group {
        flex-direction: row;
        gap: 0.75rem;
    }

    .input-wrapper {
        flex: 1;
    }

    .primary-btn {
        width: auto;
        padding: 14px 32px;
        white-space: nowrap;
    }
}

/* ===== Responsive - Desktop ===== */
@media (min-width: 900px) {
    .container {
        max-width: 640px;
        padding: 3rem 2.5rem;
    }

    h1 {
        font-size: 2.8rem;
    }

    .primary-btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 24px rgba(255, 215, 0, 0.3);
    }

    .action-btn:hover {
        transform: translateY(-2px);
    }

    .download-btn:hover {
        box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    }

    .whatsapp-btn:hover {
        box-shadow: 0 6px 20px rgba(37, 211, 102, 0.4);
    }
}

/* ===== Very Small Screens ===== */
@media (max-width: 380px) {
    .container {
        padding: 1.5rem 1rem;
    }

    h1 {
        font-size: 1.7rem;
    }

    .actions {
        grid-template-columns: 1fr;
    }

    .action-btn {
        font-size: 0.85rem;
    }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    html {
        scroll-behavior: auto;
    }

    .star,
    .particle {
        animation: none !important;
        opacity: 0.3;
    }
}

/* ===== Dark mode scrollbar ===== */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}
