/* ==========================================================================
   MetaGlass Studio — iOS Glassmorphism Design System (Light & Dark Themes)
   ========================================================================== */

:root,
html[data-theme="light"] {
    --bg-base: #eef2f9;
    --bg-mesh-1: rgba(99, 102, 241, 0.22);
    --bg-mesh-2: rgba(56, 189, 248, 0.24);
    --bg-mesh-3: rgba(236, 72, 153, 0.14);
    --bg-mesh-4: rgba(16, 185, 129, 0.16);

    --glass-bg: rgba(255, 255, 255, 0.66);
    --glass-bg-strong: rgba(255, 255, 255, 0.84);
    --glass-bg-subtle: rgba(255, 255, 255, 0.45);
    --glass-bg-hover: rgba(255, 255, 255, 0.88);
    --glass-border: rgba(255, 255, 255, 0.72);
    --glass-border-outer: rgba(15, 23, 42, 0.08);
    --glass-inner-glow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
    --glass-shadow: 0 12px 36px -8px rgba(15, 23, 42, 0.10), 0 2px 8px rgba(15, 23, 42, 0.04);
    --glass-shadow-lg: 0 24px 60px -12px rgba(15, 23, 42, 0.18), 0 4px 16px rgba(15, 23, 42, 0.06);

    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --text-inverse: #ffffff;

    --input-bg: rgba(255, 255, 255, 0.78);
    --input-border: rgba(15, 23, 42, 0.14);
    --input-focus: #007aff;

    --accent-blue: #007aff;
    --accent-indigo: #5856d6;
    --accent-cyan: #06b6d4;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-rose: #f43f5e;

    --pill-bg: rgba(15, 23, 42, 0.06);
    --pill-active-bg: rgba(0, 122, 255, 0.14);
    --pill-active-text: #0062cc;
    --divider: rgba(15, 23, 42, 0.08);
    --backdrop-dim: rgba(15, 23, 42, 0.36);
}

html[data-theme="dark"] {
    --bg-base: #070b14;
    --bg-mesh-1: rgba(59, 130, 246, 0.22);
    --bg-mesh-2: rgba(139, 92, 246, 0.20);
    --bg-mesh-3: rgba(16, 185, 129, 0.14);
    --bg-mesh-4: rgba(236, 72, 153, 0.12);

    --glass-bg: rgba(17, 24, 39, 0.62);
    --glass-bg-strong: rgba(15, 23, 42, 0.84);
    --glass-bg-subtle: rgba(30, 41, 59, 0.42);
    --glass-bg-hover: rgba(30, 41, 59, 0.72);
    --glass-border: rgba(255, 255, 255, 0.13);
    --glass-border-outer: rgba(255, 255, 255, 0.07);
    --glass-inner-glow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
    --glass-shadow: 0 14px 40px -8px rgba(0, 0, 0, 0.55), 0 2px 10px rgba(0, 0, 0, 0.35);
    --glass-shadow-lg: 0 28px 70px -12px rgba(0, 0, 0, 0.72), 0 6px 20px rgba(0, 0, 0, 0.45);

    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --text-inverse: #0f172a;

    --input-bg: rgba(15, 23, 42, 0.68);
    --input-border: rgba(255, 255, 255, 0.15);
    --input-focus: #38bdf8;

    --accent-blue: #0a84ff;
    --accent-indigo: #7c7aff;
    --accent-cyan: #22d3ee;
    --accent-emerald: #34d399;
    --accent-amber: #fbbf24;
    --accent-rose: #fb7185;

    --pill-bg: rgba(255, 255, 255, 0.07);
    --pill-active-bg: rgba(10, 132, 255, 0.24);
    --pill-active-text: #60a5fa;
    --divider: rgba(255, 255, 255, 0.09);
    --backdrop-dim: rgba(2, 6, 23, 0.68);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.35s ease, color 0.25s ease;
    overflow-x: hidden;
}

/* Ambient luminous iOS mesh wallpaper */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(circle at 12% 14%, var(--bg-mesh-1) 0%, transparent 42%),
        radial-gradient(circle at 86% 12%, var(--bg-mesh-2) 0%, transparent 44%),
        radial-gradient(circle at 82% 84%, var(--bg-mesh-3) 0%, transparent 45%),
        radial-gradient(circle at 18% 82%, var(--bg-mesh-4) 0%, transparent 42%);
    filter: saturate(118%);
}

/* Core Frosted Glass Surfaces */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(24px) saturate(185%);
    -webkit-backdrop-filter: blur(24px) saturate(185%);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-inner-glow), var(--glass-shadow);
    transition: background-color 0.25s ease, border-color 0.25s ease, transform 0.22s ease, box-shadow 0.25s ease;
}

.glass-panel-strong {
    background: var(--glass-bg-strong);
    backdrop-filter: blur(30px) saturate(200%);
    -webkit-backdrop-filter: blur(30px) saturate(200%);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-inner-glow), var(--glass-shadow-lg);
}

.glass-subtle {
    background: var(--glass-bg-subtle);
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    border: 1px solid var(--glass-border-outer);
}

.glass-card-hover:hover {
    transform: translateY(-2px);
    background: var(--glass-bg-hover);
    box-shadow: var(--glass-inner-glow), var(--glass-shadow-lg);
}

/* Text theme utilities */
.text-theme-primary { color: var(--text-primary); }
.text-theme-secondary { color: var(--text-secondary); }
.text-theme-muted { color: var(--text-muted); }
.border-theme { border-color: var(--divider); }

/* Sidebar Layout */
.ios-sidebar {
    width: 272px;
    transition: width 0.28s cubic-bezier(0.22, 1, 0.36, 1), transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.ios-sidebar.collapsed {
    width: 82px;
}

.ios-sidebar.collapsed .sidebar-label,
.ios-sidebar.collapsed .sidebar-section-title,
.ios-sidebar.collapsed .sidebar-brand-text,
.ios-sidebar.collapsed .sidebar-badge-full,
.ios-sidebar.collapsed .sidebar-footer-card {
    display: none;
}

.ios-sidebar.collapsed .sidebar-item {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.9rem;
    border-radius: 14px;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
    text-decoration: none;
    transition: all 0.2s ease;
    position: relative;
}

.sidebar-item:hover {
    background: var(--pill-bg);
    color: var(--text-primary);
}

.sidebar-item.active {
    background: var(--pill-active-bg);
    color: var(--pill-active-text);
    font-weight: 600;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.sidebar-item .icon-box {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.92rem;
    background: var(--pill-bg);
    transition: all 0.2s ease;
}

.sidebar-item.active .icon-box {
    background: linear-gradient(135deg, #007aff, #5856d6);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.35);
}

/* Segmented Menu Bar */
.ios-menubar-item {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.95rem;
    border-radius: 12px;
    font-size: 0.84rem;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    text-decoration: none;
    transition: all 0.2s ease;
}

.ios-menubar-item:hover {
    background: var(--pill-bg);
    color: var(--text-primary);
}

.ios-menubar-item.active {
    background: linear-gradient(135deg, #007aff, #5856d6);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 6px 16px -4px rgba(0, 122, 255, 0.45);
}

/* Badges */
.glass-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 0.16rem 0.56rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.25;
}

.badge-blue { background: rgba(0, 122, 255, 0.16); color: #007aff; }
html[data-theme="dark"] .badge-blue { background: rgba(10, 132, 255, 0.24); color: #60a5fa; }

.badge-emerald { background: rgba(16, 185, 129, 0.16); color: #059669; }
html[data-theme="dark"] .badge-emerald { background: rgba(52, 211, 153, 0.20); color: #34d399; }

.badge-amber { background: rgba(245, 158, 11, 0.18); color: #d97706; }
html[data-theme="dark"] .badge-amber { background: rgba(251, 191, 36, 0.20); color: #fbbf24; }

.badge-rose { background: rgba(244, 63, 94, 0.16); color: #e11d48; }
html[data-theme="dark"] .badge-rose { background: rgba(251, 113, 133, 0.22); color: #fb7185; }

.badge-indigo { background: rgba(99, 102, 241, 0.16); color: #4f46e5; }
html[data-theme="dark"] .badge-indigo { background: rgba(129, 140, 248, 0.22); color: #a5b4fc; }

.badge-neutral { background: var(--pill-bg); color: var(--text-secondary); }

.notif-count-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    background: linear-gradient(135deg, #ff3b30, #ff2d55);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 10px rgba(255, 59, 48, 0.45);
    border: 2px solid var(--bg-base);
    animation: badgePop 0.35s ease;
}

@keyframes badgePop {
    0% { transform: scale(0.6); }
    70% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* Inputs & Controls */
.glass-input,
.glass-select,
.glass-textarea {
    width: 100%;
    background: var(--input-bg);
    color: var(--text-primary);
    border: 1px solid var(--input-border);
    border-radius: 13px;
    padding: 0.62rem 0.88rem;
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.glass-input::placeholder,
.glass-textarea::placeholder {
    color: var(--text-muted);
}

.glass-input:focus,
.glass-select:focus,
.glass-textarea:focus {
    border-color: var(--input-focus);
    box-shadow: 0 0 0 3.5px rgba(0, 122, 255, 0.18);
}

/* iOS Toggle Switch */
.ios-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.ios-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.ios-switch-track {
    width: 44px;
    height: 26px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.45);
    transition: background 0.22s ease;
    position: relative;
    flex-shrink: 0;
}

.ios-switch-track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22);
    transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.ios-switch input:checked + .ios-switch-track {
    background: linear-gradient(135deg, #34c759, #10b981);
}

.ios-switch input:checked + .ios-switch-track::after {
    transform: translateX(18px);
}

/* iOS Range Slider */
input[type="range"].ios-range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: var(--pill-bg);
    outline: none;
}

input[type="range"].ios-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, #007aff, #5856d6);
    border: 2px solid #ffffff;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.45);
    cursor: pointer;
}

/* Buttons */
.btn-ios-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.68rem 1.25rem;
    border-radius: 14px;
    font-weight: 600;
    font-size: 0.88rem;
    color: #ffffff;
    background: linear-gradient(135deg, #007aff 0%, #5856d6 100%);
    border: 1px solid rgba(255, 255, 255, 0.22);
    box-shadow: 0 8px 22px -6px rgba(0, 122, 255, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.35);
    cursor: pointer;
    transition: transform 0.16s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.btn-ios-primary:hover {
    transform: translateY(-1px);
    filter: brightness(1.06);
    box-shadow: 0 12px 26px -6px rgba(0, 122, 255, 0.65);
}

.btn-ios-primary:active {
    transform: scale(0.98);
}

.btn-ios-primary:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.btn-ios-glass {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.48rem;
    padding: 0.6rem 1.05rem;
    border-radius: 13px;
    font-weight: 500;
    font-size: 0.86rem;
    color: var(--text-primary);
    background: var(--glass-bg-subtle);
    border: 1px solid var(--glass-border-outer);
    backdrop-filter: blur(12px);
    cursor: pointer;
    transition: all 0.18s ease;
}

.btn-ios-glass:hover {
    background: var(--glass-bg-hover);
    border-color: var(--glass-border);
}

.btn-ios-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.6rem 1.05rem;
    border-radius: 13px;
    font-weight: 600;
    font-size: 0.86rem;
    color: #ffffff;
    background: linear-gradient(135deg, #ff3b30, #e11d48);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 6px 18px -5px rgba(225, 29, 72, 0.55);
    cursor: pointer;
    transition: all 0.18s ease;
}

.btn-ios-danger:hover {
    filter: brightness(1.07);
    transform: translateY(-1px);
}

/* Dropzone */
.glass-dropzone {
    border: 2px dashed var(--input-border);
    border-radius: 20px;
    background: var(--glass-bg-subtle);
    transition: all 0.22s ease;
    cursor: pointer;
}

.glass-dropzone:hover,
.glass-dropzone.dragover {
    border-color: var(--accent-blue);
    background: var(--pill-active-bg);
    transform: scale(1.005);
}

/* Modal Popup Overlay */
.glass-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 90;
    background: var(--backdrop-dim);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    transition: opacity 0.22s ease;
}

.glass-modal-backdrop.show {
    display: flex;
    opacity: 1;
}

.glass-modal-box {
    width: 100%;
    max-width: 460px;
    border-radius: 26px;
    transform: scale(0.92) translateY(10px);
    transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.glass-modal-backdrop.show .glass-modal-box {
    transform: scale(1) translateY(0);
}

.glass-modal-box.modal-xl {
    max-width: 880px;
    max-height: 90vh;
    overflow-y: auto;
}

/* Custom sleek scrollbars */
::-webkit-scrollbar {
    width: 7px;
    height: 7px;
}

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

::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.35);
    border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.55);
}

/* Mobile Sidebar Overlay */
@media (max-width: 1023px) {
    .ios-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 70;
        transform: translateX(-105%);
    }
    .ios-sidebar.mobile-open {
        transform: translateX(0);
    }
}
