/* Theme variables imported from theme.css */
@import url('theme.css');

/* ==================== RESET & BASE ==================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--font-sans);
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Custom Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border) var(--background);
}

/* Remove default button styles */
button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    padding: 0;
}

/* Remove default link styles */
a {
    color: inherit;
    text-decoration: none;
}

/* Remove default list styles */
ul, ol {
    list-style: none;
}

/* Remove default input styles */
input, textarea, select {
    font-family: inherit;
    font-size: inherit;
    border: none;
    outline: none;
}

/* ==================== LAYOUT ==================== */
#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 100vw;
    overflow-x: clip; /* Prevents horizontal scroll without breaking sticky */
}

.app-header {
    position: sticky;
    position: -webkit-sticky; /* Safari support */
    top: 0;
    z-index: var(--z-sticky);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    width: 100%;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-sm) var(--spacing-md);
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.logo-icon {
    width: 80px;
    height: 36px;
    flex-shrink: 0;
}

.logo-primary {
    fill: var(--logo-primary);
}

.logo-secondary {
    fill: var(--logo-secondary);
}

.logo-accent {
    fill: var(--logo-accent);
}

.logo-text {
    font-weight: 700;
    color: var(--text-primary);
}

/* Hide logo text on very small screens */
@media (max-width: 360px) {
    .logo-text {
        display: none;
    }
}

/* Hide logo text earlier when Admin badge is visible (needs more space) */
body.admin-logged-in .logo-text {
    @media (max-width: 420px) {
        display: none;
    }
}

/* Shift header buttons left when admin badge is visible to avoid overlap */
body.admin-logged-in .header-content > div:last-of-type {
    margin-right: 70px;
}

/* ==================== NOTIFICATION STATUS INDICATORS ==================== */
/* Unavailable: crossed out bell */
#notifications-btn.notifications-unavailable svg {
    opacity: 0.5;
}

#notifications-btn.notifications-unavailable::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 2px;
    background: var(--error);
    transform: translate(-50%, -50%) rotate(-45deg);
    border-radius: 1px;
}

/* Partial: warning dot */
#notifications-btn.notifications-partial::before {
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    background: #f59e0b;
    border-radius: 50%;
    border: 2px solid var(--surface);
}

.main-content {
    flex: 1;
    padding: var(--spacing-md);
    padding-bottom: calc(var(--spacing-xl) + 60px); /* Account for bottom nav */
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

@media (max-width: 640px) {
    .main-content {
        padding: var(--spacing-sm);
        padding-bottom: calc(var(--spacing-lg) + 60px);
    }
}

/* ==================== BOTTOM NAVIGATION ==================== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: var(--z-fixed);
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 12px rgba(11, 45, 77, 0.04);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    padding: var(--spacing-sm) 0;
    padding-bottom: calc(var(--spacing-sm) + env(safe-area-inset-bottom));
}

/* iOS: Prevent keyboard from pushing nav up */
@supports (-webkit-touch-callout: none) {
    .bottom-nav {
        position: fixed;
        bottom: 0;
        /* Use visual viewport on iOS to keep nav at actual bottom */
        bottom: env(safe-area-inset-bottom);
    }

    /* Alternative: Hide nav when keyboard is open */
    @media (max-height: 500px) {
        .bottom-nav {
            transform: translateY(100%);
            transition: transform 0.3s ease;
        }
    }
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: var(--spacing-sm);
    color: var(--text-tertiary);
    transition: color var(--transition-fast);
    position: relative;
}

.nav-item svg {
    width: 24px;
    height: 24px;
    stroke-width: 2;
}

.nav-item span {
    font-size: 0.75rem;
    font-weight: 500;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 3px;
    background: var(--primary);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

/* Pro Badge in bottom nav - positioned relative to center */
.pro-badge-nav {
    position: absolute;
    top: 2px;
    left: 50%;
    transform: translateX(16px);
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #000;
    font-size: 0.5rem;
    font-weight: 700;
    padding: 2px 4px;
    border-radius: 3px;
    line-height: 1;
    box-shadow: 0 1px 3px rgba(255, 215, 0, 0.4);
    white-space: nowrap;
    pointer-events: none;
}

@media (max-width: 380px) {
    .pro-badge-nav {
        font-size: 0.45rem;
        padding: 1px 3px;
        transform: translateX(14px);
    }
}

/* Scroll to Top Button */
.scroll-to-top-btn {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 48px;
    height: 48px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0, 174, 239, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transform: scale(0.8);
    transition: all 0.3s ease;
    pointer-events: none;
}

.scroll-to-top-btn.visible {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
    pointer-events: auto;
}

.scroll-to-top-btn:hover {
    background: #0096cc;
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 174, 239, 0.4);
}

.scroll-to-top-btn:active {
    transform: scale(0.95);
}

.scroll-to-top-btn svg {
    width: 24px;
    height: 24px;
}

@media (max-width: 768px) {
    .scroll-to-top-btn {
        width: 44px;
        height: 44px;
        bottom: 75px;
        right: 16px;
    }

    .scroll-to-top-btn svg {
        width: 22px;
        height: 22px;
    }
}

/* ==================== BUTTONS ==================== */
.btn-primary {
    background: var(--primary);
    color: var(--text-inverse);
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.9375rem;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-secondary);
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.9375rem;
    border: 1px solid var(--border);
    transition: all var(--transition-fast);
}

.btn-secondary:hover {
    background: var(--background);
    border-color: var(--text-tertiary);
}

.icon-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.icon-btn svg {
    width: 20px;
    height: 20px;
}

.icon-btn:hover {
    background: var(--background);
    color: var(--text-primary);
}

/* Back Button - consistent style across the app */
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    margin-bottom: 12px;
}

.back-btn:hover {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary);
}

.back-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* ==================== INSTALL PROMPT ==================== */
.install-prompt {
    position: fixed;
    bottom: calc(60px + var(--spacing-md));
    left: var(--spacing-md);
    right: var(--spacing-md);
    z-index: var(--z-toast);
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: var(--spacing-lg);
    border: 1px solid var(--border);
    animation: slideUp var(--transition-base);
}

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

.install-content p {
    margin-bottom: var(--spacing-md);
    font-size: 0.9375rem;
    color: var(--text-primary);
}

.install-actions {
    display: flex;
    gap: var(--spacing-sm);
}

.install-actions button {
    flex: 1;
}

/* ==================== LOADING OVERLAY ==================== */
.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    background: rgba(11, 45, 77, 0.3);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--surface);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ==================== RESPONSIVE ==================== */
@media (min-width: 768px) {
    .bottom-nav {
        max-width: 600px;
        left: 50%;
        transform: translateX(-50%);
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }

    .install-prompt {
        max-width: 400px;
        left: 50%;
        transform: translateX(-50%);
    }
}

/* ==================== ADMIN BADGE ==================== */
#admin-mode-badge:hover {
    background: #d97706 !important;
}

/* ==================== UTILITIES ==================== */
.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}
