/* ===================================
   iOS 17/18 Style Master Admin
   Clean, Modern, Premium Design
   =================================== */

:root {
    /* iOS System Colors - Light Mode Explicit */
    --system-background: #f5f7fb;
    --secondary-background: #ffffff;
    --tertiary-background: #f8fafc;
    --grouped-background: #ffffff;

    /* Text Colors */
    --label: #0f172a;
    --secondary-label: #475569;
    /* 60% opacity hex */
    --tertiary-label: #3c3c434d;
    /* 30% opacity hex */
    --quaternary-label: #3c3c432e;
    /* 18% opacity hex */

    /* System Accent Colors */
    --system-blue: #1e40af;
    --system-green: #15803d;
    --system-orange: #b45309;
    --system-red: #b91c1c;
    --system-yellow: #ffcc00;
    --system-purple: #af52de;
    --system-pink: #ff2d55;
    --system-teal: #5ac8fa;
    --system-indigo: #5856d6;

    /* Fills & Separators */
    --separator: #d3d9e3;
    --opaque-separator: #d3d9e3;
    --system-fill: rgba(15, 23, 42, 0.08);
    --secondary-fill: rgba(15, 23, 42, 0.06);
    --tertiary-fill: rgba(15, 23, 42, 0.04);
    --quaternary-fill: rgba(15, 23, 42, 0.03);

    /* Materials (Explicit Light) */
    --material-thin: rgba(255, 255, 255, 0.9);
    --material-regular: rgba(255, 255, 255, 0.94);
    --material-thick: rgba(255, 255, 255, 0.98);

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 6px 16px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 16px 28px rgba(15, 23, 42, 0.12);
    --shadow-glow: 0 0 12px rgba(30, 64, 175, 0.15);

    /* Radii */
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Safe Areas */
    --safe-top: max(env(safe-area-inset-top), 20px);
    --safe-bottom: max(env(safe-area-inset-bottom), 20px);
    --safe-left: env(safe-area-inset-left);
    --safe-right: env(safe-area-inset-right);
}

/* Light Mode Forced - Dark Mode Overrides Removed */

/* ===================================
   Base Styles
   =================================== */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    padding: 0;
    background: var(--system-background);
    color: var(--label);
    font-family: var(--font-main, "IBM Plex Sans", "Segoe UI", Arial, sans-serif);
    font-size: 16px;
    line-height: 1.5;
    font-weight: 400;
    letter-spacing: -0.01em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
}

/* ===================================
   Splash Screen
   =================================== */
#splash {
    position: fixed;
    inset: 0;
    background: var(--system-background);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeOut 0.5s ease 0.8s forwards;
}

.splash-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xl);
}

.splash-icon {
    width: 100px;
    height: 100px;
    border-radius: var(--radius-lg);
    background: var(--system-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 42px;
    font-weight: 700;
    box-shadow: var(--shadow-md);
    animation: pulse 1.5s ease-in-out infinite;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--quaternary-fill);
    border-top-color: var(--system-blue);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

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

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.02);
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
    }
}

/* ===================================
   Header Navigation Bar
   =================================== */
.nav-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    padding: var(--safe-top) var(--space-md) var(--space-md);
    background: var(--secondary-background);
    border-bottom: 1px solid var(--separator);
}

.nav-bar-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 600px;
    margin: 0 auto;
}

.nav-title {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-greeting {
    font-size: 13px;
    font-weight: 500;
    color: var(--secondary-label);
    letter-spacing: 0.02em;
}

.nav-main-title {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 0.007em;
    background: linear-gradient(135deg, #fff 0%, rgba(255, 255, 255, 0.8) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-actions {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
}

.nav-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: #ffffff;
    border: 1px solid var(--separator);
    color: var(--system-blue);
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-btn:hover {
    background: var(--tertiary-background);
    transform: translateY(-1px);
}

.nav-btn:active {
    transform: scale(0.95);
}

.nav-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* ===================================
   Main Content
   =================================== */
.main-content {
    max-width: 600px;
    margin: 0 auto;
    padding: var(--space-lg) var(--space-md);
    padding-bottom: calc(var(--safe-bottom) + var(--space-xl));
}

/* ===================================
   Summary Cards (Top Stats)
   =================================== */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.summary-card {
    background: var(--grouped-background);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    position: relative;
    overflow: hidden;
    border: 1px solid var(--separator);
    transition: all 0.2s ease;
}

.summary-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--system-blue);
    opacity: 0.9;
}

.summary-card:nth-child(2)::before {
    background: linear-gradient(90deg, var(--system-green), var(--system-teal));
}

.summary-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.summary-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    background: var(--tertiary-fill);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-md);
    font-size: 22px;
}

.summary-value {
    font-size: 34px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.1;
    margin-bottom: var(--space-xs);
}

.summary-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--secondary-label);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ===================================
   Section Headers
   =================================== */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: var(--space-xl) 0 var(--space-md) 0;
}

.section-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--label);
    letter-spacing: 0.01em;
}

.section-action {
    font-size: 15px;
    font-weight: 500;
    color: var(--system-blue);
    text-decoration: none;
    transition: opacity 0.2s;
}

.section-action:hover {
    opacity: 0.7;
}

/* ===================================
   Top Clickouts - Podium Style
   =================================== */
.top-sites-container {
    background: var(--grouped-background);
    border-radius: var(--radius-xl);
    padding: var(--space-lg);
    border: 1px solid var(--separator);
    margin-bottom: var(--space-md);
}

.top-site-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) 0;
    border-bottom: 1px solid var(--separator);
}

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

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

.rank-medal {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    flex-shrink: 0;
}

.rank-medal.gold {
    background: linear-gradient(145deg, #FFD700, #FFA500);
    color: #000;
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.3);
}

.rank-medal.silver {
    background: linear-gradient(145deg, #C0C0C0, #A0A0A0);
    color: #000;
    box-shadow: 0 4px 12px rgba(192, 192, 192, 0.3);
}

.rank-medal.bronze {
    background: linear-gradient(145deg, #CD7F32, #B87333);
    color: #fff;
    box-shadow: 0 4px 12px rgba(205, 127, 50, 0.3);
}

.top-site-info {
    flex: 1;
    min-width: 0;
}

.top-site-domain {
    font-size: 17px;
    font-weight: 600;
    color: var(--label);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.top-site-period {
    font-size: 13px;
    color: var(--secondary-label);
    margin-top: 2px;
}

.top-site-clicks {
    font-size: 20px;
    font-weight: 700;
    color: var(--system-blue);
    font-variant-numeric: tabular-nums;
}

/* ===================================
   Status Alert Card
   =================================== */
.status-alert {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    background: var(--grouped-background);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    border: 1px solid var(--separator);
    margin-bottom: var(--space-md);
    position: relative;
    overflow: hidden;
}

.status-alert::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
}

.status-alert.success::before {
    background: var(--system-green);
}

.status-alert.warning::before {
    background: var(--system-orange);
}

.status-alert.danger::before {
    background: var(--system-red);
}

.status-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.status-alert.success .status-icon {
    background: rgba(48, 209, 88, 0.15);
}

.status-alert.warning .status-icon {
    background: rgba(255, 159, 10, 0.15);
}

.status-alert.danger .status-icon {
    background: rgba(255, 69, 58, 0.15);
}

.status-content {
    flex: 1;
}

.status-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--label);
    margin-bottom: 2px;
}

.status-subtitle {
    font-size: 15px;
    color: var(--secondary-label);
}

.status-badge {
    min-width: 32px;
    height: 32px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
    padding: 0 12px;
}

.status-alert.success .status-badge {
    background: rgba(48, 209, 88, 0.2);
    color: var(--system-green);
}

.status-alert.warning .status-badge {
    background: rgba(255, 159, 10, 0.2);
    color: var(--system-orange);
}

.status-alert.danger .status-badge {
    background: rgba(255, 69, 58, 0.2);
    color: var(--system-red);
}

/* ===================================
   Website List
   =================================== */
.website-list {
    background: var(--grouped-background);
    border-radius: var(--radius-xl);
    overflow: hidden;
    border: 1px solid var(--separator);
}

.website-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--separator);
    transition: background 0.2s ease;
}

.website-item:last-child {
    border-bottom: none;
}

.website-item:active {
    background: var(--tertiary-fill);
}

.website-favicon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--tertiary-fill);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--secondary-label);
    flex-shrink: 0;
    font-weight: 600;
}

.website-info {
    flex: 1;
    min-width: 0;
}

.website-domain {
    font-size: 17px;
    font-weight: 500;
    color: var(--label);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.website-stats {
    font-size: 13px;
    color: var(--secondary-label);
    margin-top: 2px;
}

.website-clicks {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.website-clicks-value {
    font-size: 17px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.website-clicks-value.high {
    color: var(--system-green);
}

.website-clicks-value.medium {
    color: var(--system-orange);
}

.website-clicks-value.low {
    color: var(--tertiary-label);
}

.website-clicks-label {
    font-size: 11px;
    color: var(--tertiary-label);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.website-chevron {
    color: var(--tertiary-label);
    font-size: 14px;
}

/* ===================================
   Empty State
   =================================== */
.empty-state {
    text-align: center;
    padding: var(--space-2xl) var(--space-lg);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: var(--space-md);
    opacity: 0.5;
}

.empty-state-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--label);
    margin-bottom: var(--space-sm);
}

.empty-state-text {
    font-size: 15px;
    color: var(--secondary-label);
}

/* ===================================
   Logout Button
   =================================== */
.logout-section {
    margin-top: var(--space-2xl);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--separator);
}

.logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    width: 100%;
    padding: var(--space-md);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    color: var(--system-red);
    font-size: 17px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
}

.logout-btn:hover {
    background: rgba(185, 28, 28, 0.08);
    border-color: rgba(185, 28, 28, 0.2);
}

.logout-btn:active {
    background: rgba(255, 69, 58, 0.15);
    transform: scale(0.98);
}

/* ===================================
   Pull to Refresh Indicator
   =================================== */
.pull-indicator {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%) translateY(-100%);
    background: var(--material-regular);
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-lg);
    font-size: 13px;
    color: var(--secondary-label);
    z-index: 200;
    transition: transform 0.3s ease;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.pull-indicator.visible {
    transform: translateX(-50%) translateY(calc(var(--safe-top) + 10px));
}

/* ===================================
   Utility Classes
   =================================== */
.text-success {
    color: var(--system-green) !important;
}

.text-warning {
    color: var(--system-orange) !important;
}

.text-danger {
    color: var(--system-red) !important;
}

.text-accent {
    color: var(--system-blue) !important;
}

.text-muted {
    color: var(--secondary-label) !important;
}

/* ===================================
   Animations
   =================================== */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.summary-card,
.top-sites-container,
.status-alert,
.website-list {
    animation: slideUp 0.4s ease-out backwards;
}

.summary-card:nth-child(1) {
    animation-delay: 0.05s;
}

.summary-card:nth-child(2) {
    animation-delay: 0.1s;
}

.top-sites-container {
    animation-delay: 0.15s;
}

.status-alert {
    animation-delay: 0.2s;
}

.website-list {
    animation-delay: 0.25s;
}

/* ===================================
   Responsive Adjustments
   =================================== */
@media (max-width: 380px) {
    .summary-grid {
        gap: var(--space-sm);
    }

    .summary-card {
        padding: var(--space-md);
    }

    .summary-value {
        font-size: 28px;
    }

    .nav-main-title {
        font-size: 24px;
    }
}

@media (min-width: 600px) {
    .main-content {
        padding: var(--space-xl) var(--space-lg);
    }
}

/* ===================================
   Scrollbar (Desktop)
   =================================== */
@media (hover: hover) {
    ::-webkit-scrollbar {
        width: 8px;
    }

    ::-webkit-scrollbar-track {
        background: transparent;
    }

    ::-webkit-scrollbar-thumb {
        background: rgba(15, 23, 42, 0.12);
        border-radius: 4px;
    }

    ::-webkit-scrollbar-thumb:hover {
        background: rgba(15, 23, 42, 0.2);
    }
}
