/* ============================================================
   Aazhian Apps - Unified Application Template Stylesheet
   ============================================================ */

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

:root {
    --bg-color: #06080e;
    --box-bg-top: #0e1322;
    --box-bg-bottom: #090c15;
    --text-primary: #f8fafc;
    --text-muted: #94a3b8;
    --accent-blue: #3b82f6;
}

html, body {
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(circle at 50% 0%, rgba(99, 102, 241, 0.08) 0%, transparent 60%),
        radial-gradient(circle at 85% 85%, rgba(56, 189, 248, 0.04) 0%, transparent 50%);
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 24px 16px;
    overflow-x: hidden;
}

/* --- Unified App Container Box (Matches 3-Tier Device Ratio) --- */
.app-container {
    width: 100%;
    max-width: 900px;
    min-height: min(760px, calc(100vh - 80px));
    background: linear-gradient(180deg, var(--box-bg-top) 0%, var(--box-bg-bottom) 100%);
    border-radius: 44px;
    border: none;
    outline: none;
    padding: 28px 32px;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 
        0 40px 80px -20px rgba(0, 0, 0, 0.95),
        0 20px 40px -10px rgba(0, 0, 0, 0.75),
        0 0 60px -15px rgba(30, 41, 59, 0.25),
        inset 0 1px 1px 0 rgba(255, 255, 255, 0.09);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* --- Unified App Header --- */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    margin-bottom: 24px;
    flex-shrink: 0;
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #94a3b8;
    text-decoration: none;
    padding: 6px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.07);
    transition: all 0.2s ease;
}

.back-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
}

.app-title-badge {
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-badge-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    color: white;
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.3);
}

.app-title-text {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: #ffffff;
}

.beta-tag {
    font-size: 10px;
    font-family: monospace;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(59, 130, 246, 0.12);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.25);
}

.disclaimer-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    color: #94a3b8;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 6px 12px;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.disclaimer-btn:hover {
    color: #f59e0b;
    border-color: rgba(245, 158, 11, 0.3);
    background: rgba(245, 158, 11, 0.08);
}

/* --- Unified App Footer --- */
.app-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    margin-top: 24px;
    font-size: 12px;
    color: #64748b;
    flex-shrink: 0;
}

.app-footer-copyright {
    letter-spacing: 0.2px;
}

.app-footer-storage {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #10b981;
    font-size: 11px;
    font-weight: 500;
}

/* --- Disclaimer Modal Dialog --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* In Installed Standalone PWA mode, suppress auto-disclaimer unless clicked by user */
@media all and (display-mode: standalone) {
    .modal-overlay:not(.user-opened) {
        display: none !important;
    }
}

.modal-card {
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    background: #0f1422;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 28px;
    box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.95);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active .modal-card {
    transform: scale(1);
}

.modal-header {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    background: rgba(15, 20, 34, 0.8);
}

.modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    font-size: 13px;
    color: #cbd5e1;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-item h4 {
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-item p {
    color: #94a3b8;
    font-size: 12px;
}

.modal-footer {
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    background: rgba(15, 20, 34, 0.9);
}

.btn-decline {
    padding: 8px 18px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-decline:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

.btn-accept {
    padding: 8px 22px;
    border-radius: 999px;
    background: #2563eb;
    border: none;
    color: #ffffff;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.35);
    transition: all 0.2s;
}

.btn-accept:hover {
    background: #1d4ed8;
}

/* Modal Footer Mode Toggling: Entry Gatekeeper vs In-App Terms View */
.modal-overlay.user-opened .footer-entry-actions {
    display: none !important;
}
.modal-overlay.user-opened .footer-terms-actions {
    display: flex !important;
    width: 100%;
}
.modal-overlay:not(.user-opened) .footer-entry-actions {
    display: flex !important;
}
.modal-overlay:not(.user-opened) .footer-terms-actions {
    display: none !important;
}

/* --- Responsive Adjustments: Fullscreen Native Mobile & PWA App Experience --- */
@media (max-width: 768px) {
    html, body {
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        height: 100% !important;
        min-height: 100dvh !important;
        overflow: hidden !important;
        display: block !important;
    }

    .app-container {
        width: 100% !important;
        max-width: 100% !important;
        height: 100dvh !important;
        min-height: 100dvh !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        border: none !important;
        padding: max(16px, env(safe-area-inset-top)) 18px max(14px, env(safe-area-inset-bottom)) 18px !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: space-between !important;
    }

    .app-header {
        margin-bottom: 12px;
        padding-bottom: 12px;
        flex-shrink: 0;
    }

    /* On mobile screens, hide the in-page back button so user uses browser navigation */
    .back-btn {
        display: none !important;
    }

    .app-title-text {
        font-size: 16px;
    }

    .app-footer {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 6px;
        text-align: left;
        padding-top: 10px;
        margin-top: 10px;
        font-size: 11px;
        flex-shrink: 0;
    }

    .app-footer-copyright {
        font-size: 11px;
    }

    .app-footer-storage {
        font-size: 11px;
    }

    /* Mobile Disclaimer Modal - Clears Safari Bottom Widgets & Toolbars */
    .modal-overlay {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        height: 100dvh !important;
        height: 100svh !important;
        padding: max(16px, env(safe-area-inset-top, 16px)) 16px max(80px, calc(env(safe-area-inset-bottom, 0px) + 70px)) 16px !important;
        box-sizing: border-box !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        z-index: 99999 !important;
    }

    .modal-card {
        width: 100% !important;
        max-width: 500px !important;
        max-height: calc(100dvh - max(110px, calc(env(safe-area-inset-top, 0px) + env(safe-area-inset-bottom, 0px) + 95px))) !important;
        border-radius: 24px !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
        box-shadow: 0 20px 50px rgba(0, 0, 0, 0.95), 0 0 0 1px rgba(255, 255, 255, 0.12) !important;
        margin: auto 0 !important;
        flex-shrink: 0 !important;
    }

    .modal-header {
        padding: 14px 18px !important;
        flex-shrink: 0 !important;
    }

    .modal-body {
        padding: 14px 18px !important;
        flex: 1 1 auto !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        gap: 12px !important;
    }

    .modal-item h4 {
        font-size: 12px !important;
        margin-bottom: 3px !important;
    }

    .modal-item p {
        font-size: 11.5px !important;
        line-height: 1.5 !important;
    }

    .modal-footer {
        padding: 12px 18px !important;
        flex-shrink: 0 !important;
        background: rgba(13, 18, 30, 0.98) !important;
        border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
        display: flex !important;
        align-items: center !important;
        justify-content: flex-end !important;
        gap: 10px !important;
        z-index: 10 !important;
    }

    .btn-accept, .btn-decline {
        padding: 9px 18px !important;
        font-size: 12px !important;
        min-height: 40px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        touch-action: manipulation !important;
    }
}

/* Standalone PWA Mode (Installed on Home Screen) */
@media all and (display-mode: standalone) {
    html, body {
        padding: 0 !important;
        margin: 0 !important;
    }

    .app-container {
        border-radius: 0 !important;
        box-shadow: none !important;
        width: 100% !important;
        max-width: 100% !important;
        height: 100dvh !important;
        min-height: 100dvh !important;
        padding-top: max(18px, env(safe-area-inset-top)) !important;
        padding-bottom: max(16px, env(safe-area-inset-bottom)) !important;
    }

    /* Standalone installed PWA is dedicated and must never link back to the hub */
    .back-btn {
        display: none !important;
    }
}

body.standalone-mode .back-btn {
    display: none !important;
}

/* --- PWA Install Guidance Toasts (Android, iOS & Success) --- */
.install-toast,
.ios-install-toast {
    position: fixed;
    bottom: max(20px, calc(env(safe-area-inset-bottom, 0px) + 16px));
    left: 50%;
    transform: translateX(-50%) translateY(140px);
    background: #0f172a;
    border: 1px solid rgba(56, 189, 248, 0.3);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.75);
    border-radius: 18px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    z-index: 999;
    max-width: 92vw;
    width: 390px;
    color: #f1f5f9;
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.install-toast.show,
.ios-install-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.install-toast .toast-icon,
.ios-install-toast .toast-icon {
    font-size: 16px;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ios-toast-icon,
.ios-install-toast .toast-icon {
    color: #38bdf8;
    background: rgba(56, 189, 248, 0.15);
}

.android-toast-icon {
    color: #4ade80;
    background: rgba(74, 222, 128, 0.15);
}

.success-toast-icon {
    color: #38bdf8;
    background: rgba(56, 189, 248, 0.15);
}

.install-toast .toast-text-wrap {
    flex: 1;
    min-width: 0;
}

.install-toast .toast-title {
    font-weight: 600;
    font-size: 13px;
    color: #ffffff;
}

.install-toast .toast-subtext {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 2px;
    line-height: 1.35;
}

.install-toast .toast-action-btn {
    background: #2563eb;
    border: none;
    color: #ffffff;
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
    transition: background 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.install-toast .toast-action-btn:hover {
    background: #1d4ed8;
}

.install-toast .toast-close,
.ios-install-toast .toast-close {
    background: none;
    border: none;
    color: #64748b;
    font-size: 14px;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
}
