/* ==========================================================================
   PortalX — Spotify-Inspired Design System
   Dark-first immersive canvas, one resting accent (neon red/pink),
   flat elevated surfaces, bold type hierarchy, restrained motion.
   ========================================================================== */

/* ---- Design Tokens (dark-first, single theme) --------------------------- */
:root {
    color-scheme: dark;

    /* Surfaces & gradients */
    --bg-dark: #121212;                 /* near-black canvas             */
    --bg-gradient-start: #121212;
    --bg-gradient-end: #17171c;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
    --glass-menu: rgba(20, 20, 24, 0.94);
    --surface: #18181d;                 /* elevated surface              */
    --surface-2: rgba(255, 255, 255, 0.05);
    --card: #1d1d23;                    /* flat Spotify-style card       */
    --card-hover: #24242c;
    --hover: rgba(255, 255, 255, 0.08);
    --bar: rgba(18, 18, 22, 0.82);      /* titlebar glass                */

    /* One resting accent — PortalX neon red / pink.
       Legacy --neon-* names are aliased so existing inline styles keep
       working unchanged; the blue/purple aliases are retired to the
       red family. --neon-green stays semantic success. */
    --neon-red: #ff2d55;
    --neon-pink: #ff6b9d;
    --neon-blue: #ff2d55;               /* retired alias -> accent red   */
    --neon-purple: #ff5c8a;             /* retired alias -> pink family  */
    --neon-green: #3ddc97;              /* semantic success              */

    --accent: #ff2d55;
    --accent-strong: #e61a41;           /* pressed / hovers              */
    --accent-2: #ff6b9d;
    --accent-soft: rgba(255, 45, 85, 0.14);
    --ring: rgba(255, 45, 85, 0.45);

    /* Text hierarchy (Spotify: primary / secondary / muted) */
    --text-primary: #f5f5f7;
    --text-secondary: rgba(235, 235, 245, 0.72);
    --text-muted: rgba(235, 235, 245, 0.45);

    /* Spacing & layout */
    --border-radius: 12px;
    --spacing: 24px;
    --container-max: 1400px;
    --titlebar-h: 56px;

    /* Layered shadows — flatter, softer (Spotify) */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5), 0 8px 28px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.6), 0 2px 6px rgba(0, 0, 0, 0.4);

    /* Motion (Spotify: fast, purposeful ease-outs) */
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
    --dur-fast: 150ms;
    --dur-med: 220ms;
}

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

html, body {
    overflow-x: hidden;
    background-color: var(--bg-dark);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

button, input, select, textarea {
    font-family: inherit;
}

/* Ambient background glow effect (accent, subtle) */
body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 30%, rgba(255, 45, 85, 0.06) 0%, transparent 50%),
                radial-gradient(circle at 70% 70%, rgba(255, 45, 85, 0.04) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

a {
    text-decoration: none;
    color: var(--accent);
    font-weight: 600;
    transition: color var(--dur-fast) ease;
}

a:hover {
    color: var(--accent-strong);
}

/* Accessible focus ring (accent) */
:focus-visible {
    outline: 3px solid var(--ring);
    outline-offset: 2px;
}

/* ---- macOS Traffic Lights ---------------------------------------------- */
.mac-dots {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-right: 14px;
    flex-shrink: 0;
}

.mac-dots span {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: block;
    box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.12);
    transition: filter 0.15s ease;
}

.mac-dots span:nth-child(1) { background: #ff5f57; }
.mac-dots span:nth-child(2) { background: #febc2e; }
.mac-dots span:nth-child(3) { background: #28c840; }

.mac-dots:hover span { filter: brightness(1.2); }

.mac-dots-modal {
    margin: 0 auto 14px;
    justify-content: center;
}


@media (max-width: 768px) {
    /* Responsive Grid */
    .bento-grid,
    .bento-grid.two-col {
        grid-template-columns: 1fr;
    }

    .bento-grid .bento-card,
    .bento-grid .bento-card.large {
        grid-column: span 1;
        width: 100%;
    }

    /* Responsive Cards */
    .bento-card {
        padding: 20px;
    }

    .bento-card h2 {
        font-size: 1.5rem;
    }

    .bento-image {
        height: 180px;
    }

    /* Responsive Forms */
    .form-group input,
    .form-group textarea,
    .form-group select {
        padding: 12px 14px;
        font-size: 16px; /* Prevent zoom on iOS */
    }

    /* Responsive Container */
    .container {
        padding: 0 16px;
    }

    /* Responsive Buttons */
    .btn,
    .btn-outline {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
}

/* ---- Modal Styles (glass window) ---------------------------------------- */
.modal {
    display: none;
    position: fixed;
    z-index: 200000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    display: flex;
}

.modal-content {
    background-color: var(--glass-menu);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    backdrop-filter: blur(30px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    max-width: 400px;
    width: fit-content;
    animation: modalFadeIn 0.3s ease;
    color: var(--text-primary);
}

/* macOS window chrome for modal dialogs */
.mac-window {
    background: var(--glass-menu);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    backdrop-filter: blur(30px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    color: var(--text-primary);
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.92);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--glass-border);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background-color 0.2s;
}

.modal-close:hover {
    background-color: var(--glass-bg);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}

/* Responsive Modal */
@media (max-width: 480px) {
    .modal-content {
        padding: 20px;
        max-width: 90%;
    }
}

/* Tablet view - 3 columns */
@media (min-width: 769px) and (max-width: 1024px) {
    .bento-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 480px) {
    .bento-card {
        padding: 16px;
    }

    .bento-card h2 {
        font-size: 1.25rem;
    }

    .bento-card h3 {
        font-size: 1rem;
    }

    .bento-image {
        height: 150px;
    }

    .btn,
    .btn-outline {
        padding: 8px 16px;
        font-size: 0.85rem;
    }
}

/* ---- Buttons (primary action: filled accent) ---------------------------- */
.btn {
    display: inline-block;
    padding: 10px 22px;
    background: linear-gradient(180deg, var(--accent), var(--accent-strong));
    color: #fff;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    transition: filter var(--dur-fast) ease, transform var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18), 0 2px 8px var(--ring);
}

.btn:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.18), 0 4px 16px var(--ring);
}

.btn:active {
    transform: translateY(0) scale(0.98);
    filter: brightness(0.97);
}

.btn-outline {
    background: transparent;
    color: var(--accent);
    border: 1.5px solid var(--ring);
    box-shadow: none;
}

.btn-outline:hover {
    background: var(--accent-soft);
    color: var(--accent-strong);
    filter: none;
    box-shadow: none;
}

.btn-ghost {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    box-shadow: none;
}

.btn-ghost:hover {
    background: var(--hover);
    color: var(--text-primary);
    filter: none;
    transform: none;
    box-shadow: none;
}

.btn-danger {
    background: linear-gradient(180deg, #ff5f5a, #ff3b30);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(255, 59, 48, 0.35);
}

.btn-success {
    background: linear-gradient(180deg, #54d977, #28a745);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(40, 167, 69, 0.35);
}

.container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 var(--spacing);
}

.app-main {
    padding-top: 28px;
    padding-bottom: 56px;
}

/* ---- Global type hierarchy (Spotify: bold, confident, tight) ------------ */
h1, h2, h3, h4 {
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

h1 { font-size: clamp(1.8rem, 3vw, 2.6rem); font-weight: 800; }
h2 { font-size: 1.5rem; font-weight: 800; }
h3 { font-size: 1.2rem; font-weight: 700; }
h4 { font-size: 1rem; font-weight: 700; }

/* ---- Page headers -------------------------------------------------------- */
.page-header { margin-bottom: 22px; }

.page-header h1 { margin: 0 0 6px; }

.page-header .page-sub {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin: 0;
}

/* ---- Hover-reveal card action (Spotify card pattern) -------------------- */
.card-cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    align-self: flex-start;
    margin-top: auto;
    padding-top: 14px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent);
    opacity: 0;
    transform: translateY(4px);
    transition: opacity var(--dur-med) ease, transform var(--dur-med) var(--ease);
}

.bento-card:hover .card-cta { opacity: 1; transform: translateY(0); }

@media (hover: none) {
    .card-cta { opacity: 1; transform: none; }
    .bento-card { transition: none; }
}

/* ---- Bento Grid System -------------------------------------------------- */
.bento-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing);
    margin-bottom: var(--spacing);
}

.bento-grid.two-col {
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* Cards — flat elevated surface, gentle lift + accent bloom on hover */
.bento-card {
    background: var(--card);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    padding: var(--spacing);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    transition: background var(--dur-med) ease, border-color var(--dur-med) ease, box-shadow var(--dur-med) ease, transform var(--dur-med) var(--ease);
}

.bento-card:hover {
    background: var(--card-hover);
    border-color: rgba(255, 45, 85, 0.35);
    box-shadow: var(--shadow-md);
    transform: translateY(-3px);
}

.bento-card.large {
    grid-column: span 2;
}

.bento-card.xlarge {
    grid-column: span 3;
}

@media (max-width: 1100px) {
    .bento-grid.two-col {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .bento-grid {
        grid-template-columns: 1fr;
    }

    .bento-card,
    .bento-card.large,
    .bento-card.xlarge {
        grid-column: span 1;
        width: 100%;
    }
}

@media (max-width: 740px) {
    .bento-grid {
        gap: 15px;
    }

    .bento-card {
        padding: 20px;
        width: 100%;
        min-width: 0;
    }

    .bento-card img {
        max-width: 100%;
        height: auto;
    }
}

/* ---- Dropdown Menu (glass) ---------------------------------------------- */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-toggle {
    cursor: pointer;
    padding: 8px 16px;
    background: var(--surface-2);
    border: 1px solid var(--glass-border);
    border-radius: 9px;
    color: var(--text-primary);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.dropdown-toggle:hover {
    background: var(--hover);
    border-color: var(--ring);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: var(--glass-menu);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    min-width: 180px;
    box-shadow: var(--shadow-lg);
    z-index: 100;
    display: none;
    flex-direction: column;
    padding: 8px 0;
    animation: modalFadeIn 0.15s ease;
}

.dropdown-menu.active {
    display: flex;
}

.dropdown-item {
    padding: 10px 16px;
    color: var(--text-primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.2s ease;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-size: 0.9rem;
}

.dropdown-item:hover {
    background: var(--hover);
}

.dropdown-item.danger {
    color: var(--neon-red);
}

.dropdown-item.danger:hover {
    background: var(--accent-soft);
}

.dropdown-divider {
    height: 1px;
    background: var(--glass-border);
    margin: 8px 0;
}

/* ---- Card Typography ---------------------------------------------------- */
/* Card typography — bold, confident, tight (Spotify) */
.bento-card h2 {
    margin-bottom: 12px;
    font-size: 1.7rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.bento-card h3 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.bento-card p {
    color: var(--text-secondary);
    margin-bottom: 16px;
    font-size: 1rem;
}

.bento-image {
    width: 100%;
    height: 220px;
    object-fit: cover;
    object-position: top;
    border-radius: 12px;
    margin-bottom: 16px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}

.image-expand-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
    z-index: 10;
    font-size: 20px;
}

.image-expand-btn:hover {
    opacity: 1;
}

.bento-card large > div:hover .image-expand-btn,
.bento-card > div:hover .image-expand-btn {
    opacity: 1;
}

/* ---- Forms (clean inputs + accent focus ring) ------------------------- */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 14px;
    background: var(--surface-2);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    color: var(--text-primary);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
    transition: all 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}

.form-group select option {
    background: var(--surface);
    color: var(--text-primary);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--ring), inset 0 1px 2px rgba(0, 0, 0, 0.04);
    background: var(--surface);
}

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

.form-group input[type="file"] {
    padding: 10px;
}

/* Dynamic field builder */
.custom-field-row {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 12px;
    transition: all 0.3s ease;
}

.custom-field-row:hover {
    border-color: var(--ring);
}

.remove-field-btn,
.remove-plus-one {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    border: none;
    color: white;
}

.remove-btn:hover,
.remove-field-btn:hover,
.remove-plus-one:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.4);
}

/* ---- Modern Toggle Switch -------------------------------------------- */
.toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
    margin-bottom: 20px;
}

.toggle-wrapper input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-track {
    position: relative;
    width: 52px;
    height: 28px;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid var(--glass-border);
    border-radius: 28px;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.toggle-knob {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 22px;
    height: 22px;
    background: #fff;
    border-radius: 50%;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-sm);
}

.toggle-wrapper input:checked ~ .toggle-track {
    background: linear-gradient(180deg, var(--accent), var(--accent-strong));
    border-color: transparent;
}

.toggle-wrapper input:checked ~ .toggle-track .toggle-knob {
    transform: translateX(24px);
    background: white;
    box-shadow: 0 2px 10px var(--ring);
}

.toggle-text {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

/* ---- Progress Bar -------------------------------------------------------- */
.progress-bar-container {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    height: 12px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
}

.progress-bar-fill {
    height: 100%;
    border-radius: 10px;
    transition: width 0.3s ease;
    box-shadow: 0 0 12px currentColor;
}

/* ---- Status Messages (semantic, theme-aware) ---------------------------- */
.status-success {
    background: rgba(48, 209, 88, 0.16);
    border: 1px solid rgba(48, 209, 88, 0.35);
    color: #6ee7a0;
    padding: 16px;
    border-radius: 12px;
    text-align: center;
    font-weight: 600;
}

.status-error {
    background: rgba(255, 69, 58, 0.16);
    border: 1px solid rgba(255, 69, 58, 0.35);
    color: #ff6961;
    padding: 16px;
    border-radius: 12px;
    text-align: center;
    font-weight: 600;
}

.status-warning {
    background: rgba(255, 159, 10, 0.16);
    border: 1px solid rgba(255, 159, 10, 0.35);
    color: #ffd60a;
    padding: 16px;
    border-radius: 12px;
    text-align: center;
    font-weight: 600;
}

/* ---- Scrollbar (neutral) ---------------------------------------------- */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

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

::-webkit-scrollbar-thumb {
    background: rgba(120, 120, 128, 0.45);
    border-radius: 6px;
    border: 2px solid var(--bg-dark);
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(120, 120, 128, 0.65);
}

/* ---- Quill Editor ------------------------------------------------------- */
.form-group > .ql-toolbar.ql-snow {
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: 10px 10px 0 0;
    margin-bottom: 0;
}

.form-group > .ql-container.ql-snow {
    border: 1px solid var(--glass-border);
    border-top: 0;
    border-radius: 0 0 10px 10px;
    background: var(--surface);
    font-size: 1rem;
}

.ql-editor,
.rich-content {
    color: var(--text-primary);
    word-wrap: break-word;
    max-width: 100%;
    width: 100%;
    display: block;
}

.ql-editor ul,
.ql-editor ol,
.rich-content ul,
.rich-content ol {
    padding-left: 20px;
    margin: 10px 0;
}

.ql-editor li,
.rich-content li {
    margin: 5px 0;
    line-height: 1.6;
}

.ql-editor ul,
.rich-content ul {
    list-style-type: disc;
}

.ql-editor ol,
.rich-content ol {
    list-style-type: decimal;
}

.ql-editor ul li::marker,
.rich-content ul li::marker {
    color: var(--accent);
}

.ql-editor ol li::marker,
.rich-content ol li::marker {
    color: var(--accent);
}

.ql-editor p,
.rich-content p {
    margin: 10px 0;
    line-height: 1.6;
}

.ql-editor h1,
.ql-editor h2,
.ql-editor h3,
.rich-content h1,
.rich-content h2,
.rich-content h3 {
    margin: 15px 0 10px 0;
    color: var(--text-primary);
}

.ql-editor h1,
.rich-content h1 {
    font-size: 2rem;
}

.ql-editor h2,
.rich-content h2 {
    font-size: 1.5rem;
}

.ql-editor h3,
.rich-content h3 {
    font-size: 1.25rem;
}

.ql-editor a,
.rich-content a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.3s ease;
}

.ql-editor a:hover,
.rich-content a:hover {
    color: var(--accent-strong);
}

.ql-editor img,
.rich-content img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    margin: 10px 0;
}

.ql-editor blockquote,
.rich-content blockquote {
    border-left: 4px solid var(--accent);
    padding-left: 15px;
    margin: 15px 0;
    color: var(--text-secondary);
    font-style: italic;
}

.ql-editor strong,
.rich-content strong {
    color: var(--text-primary);
    font-weight: 700;
}

.ql-editor em,
.rich-content em {
    color: var(--text-secondary);
}

/* ---- File Upload -------------------------------------------------------- */
.file-upload-wrapper {
    position: relative;
    width: 100%;
}

.file-upload-input {
    display: none;
}

.file-upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 20px;
    border: 2px dashed var(--glass-border);
    border-radius: 12px;
    background: var(--surface-2);
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.file-upload-label:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.file-upload-label.dragover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.file-upload-icon {
    font-size: 2.5rem;
    color: var(--text-muted);
    margin-bottom: 12px;
    transition: color 0.3s ease;
}

.file-upload-label:hover .file-upload-icon {
    color: var(--accent);
}

.file-upload-label.dragover .file-upload-icon {
    color: var(--accent);
}

.file-upload-text {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.file-upload-subtext {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.file-upload-preview {
    margin-top: 15px;
    position: relative;
    display: none;
}

.file-upload-preview.active {
    display: block;
}

.file-upload-preview img {
    width: 100%;
    max-height: 300px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.file-upload-remove {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
}

.file-upload-remove:hover {
    background: var(--neon-red);
}

.container-full {
    max-width: none;
    padding: 0;
    margin: 0;
    height: 100vh;
}

/* Adjust sidebar and button positions for fixed nav */
.locator-mode .locator-toggle,
.locator-mode #locator-sidebar {
    top: 135px;
    left: 25px;
}

.locator-mode #locator-sidebar {
    max-height: calc(100% - 250px);
}

@media (max-width: 768px) {
    .locator-mode #locator-sidebar {
        top: auto;
        left: 50%;
        right: 50%;
    }
    .locator-mode .locator-toggle {
        top: 125px;
        left: 25px;
    }
}

/* ---- Locator Page ------------------------------------------------------- */
/* Dark basemap: standard OSM tiles rendered night-mode via an invert filter,
   keeping the map on a working source while matching the dark-first canvas. */
.leaflet-tile-pane {
    filter: invert(1) hue-rotate(180deg) brightness(0.92) contrast(0.9) saturate(0.35);
}

.leaflet-control-attribution {
    background: rgba(18, 18, 22, 0.85) !important;
    color: #9a9aa2 !important;
    font-size: 10px !important;
}

.leaflet-control-attribution a {
    color: #ff6b9d !important;
}

.locator-btn {
    border-color: var(--neon-blue) !important;
    color: var(--neon-blue) !important;
}

.locator-btn:hover {
    background: var(--neon-blue) !important;
    color: white !important;
    box-shadow: 0 4px 20px var(--ring) !important;
}

.locator-page {
    position: relative;
    width: 100%;
    height: 100%;
}

#locator-map {
    width: 100%;
    height: 100%;
}

#locator-sidebar {
    position: absolute;
    top: 16px;
    left: 16px;
    width: 320px;
    max-height: calc(100% - 32px);
    background: var(--glass-menu);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    padding: 20px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: var(--glass-shadow);
}

#locator-sidebar h3 {
    font-size: 1.1rem;
    margin: 0;
    color: var(--text-primary);
}

.locator-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.locator-close {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
}

.locator-toggle {
    display: none;
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 1001;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--glass-menu);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    font-size: 1.1rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: var(--glass-shadow);
}

.locator-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.locator-filter {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    background: var(--surface-2);
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.locator-filter.active {
    background: var(--hover);
    border-color: var(--ring);
    color: var(--text-primary);
}

.locator-filter:not(.active) {
    opacity: 0.4;
}

.locator-filter:hover {
    opacity: 0.8;
}

.locator-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

#locator-list {
    margin-top: 12px;
}

.locator-card {
    padding: 12px;
    border-radius: 10px;
    background: var(--surface-2);
    border: 1px solid var(--glass-border);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.locator-card:hover {
    background: var(--hover);
    border-color: var(--accent);
    transform: translateX(4px);
}

.locator-card-distance {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
    padding: 2px 10px;
    border-radius: 12px;
    margin-bottom: 6px;
    letter-spacing: 0.3px;
    background: var(--accent);
}

.locator-card-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.locator-card-location {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.locator-card-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.locator-card-body {
    display: flex;
    align-items: center;
    gap: 10px;
}

.locator-card-img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
}

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

.locator-marker {
    background: none !important;
    border: none !important;
    pointer-events: none;
}

.locator-pin {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.85rem;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.4);
    border: 2px solid white;
    pointer-events: auto;
    cursor: pointer;
}

.locator-pin i {
    font-size: 0.75rem;
}

.leaflet-popup-content-wrapper {
    border-radius: 12px !important;
    background: var(--glass-menu) !important;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border) !important;
    color: var(--text-primary) !important;
}

.leaflet-popup-tip {
    background: var(--glass-menu) !important;
    border: 1px solid var(--glass-border) !important;
}

@media (max-width: 768px) {
    .locator-toggle {
        display: flex;
    }

    .locator-close {
        display: block;
    }

    #locator-sidebar {
        width: calc(100% - 32px);
        max-height: 50%;
        top: auto;
        bottom: 16px;
        left: 50%;
        transform: translateX(-50%);
        transition: transform 0.3s ease;
    }

    #locator-sidebar.open {
        transform: translateX(-50%) translateY(calc(100% + 32px));
    }
}

.user-location-marker,
.user-location-marker * {
    background: none !important;
    border: none !important;
    pointer-events: none !important;
}

.user-dot {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 14px;
    height: 14px;
    background: var(--accent);
    border: 3px solid white;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 12px var(--ring);
    z-index: 1;
}

.user-dot-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 32px;
    height: 32px;
    border: 3px solid var(--ring);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: user-locate-pulse 2s ease-out infinite;
}

@keyframes user-locate-pulse {
    0% { transform: translate(-50%, -50%) scale(0.6); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1.8); opacity: 0; }
}

.leaflet-control-zoom {
    border: 1px solid var(--glass-border) !important;
    border-radius: 10px !important;
    overflow: hidden;
    box-shadow: var(--shadow-md) !important;
}

.leaflet-control-zoom a {
    background: var(--glass-menu) !important;
    color: var(--text-primary) !important;
    border-bottom: 1px solid var(--glass-border) !important;
    width: 40px !important;
    height: 40px !important;
    line-height: 40px !important;
    font-size: 1.1rem !important;
    transition: background 0.2s ease;
}

.leaflet-control-zoom a:hover {
    background: var(--hover) !important;
}

.leaflet-control-zoom a.leaflet-disabled {
    color: var(--text-muted) !important;
}

.locate-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--accent) !important;
    font-size: 1rem !important;
}

.locate-btn:hover {
    color: white !important;
    background: var(--accent-soft) !important;
}

@media (max-width: 480px) {
    #locator-sidebar {
        left: 50%;
        transform: translateX(-50%);
        width: calc(100% - 20px);
        max-height: 45%;
        bottom: 8px;
        padding: 14px;
    }

    #locator-sidebar.open {
        transform: translateX(-50%) translateY(calc(100% + 32px));
    }
}

/* ---- Coordinate Picker Map ---------------------------------------------- */
#coordinate-picker-map {
    width: 100%;
    z-index: 1;
}

#coordinate-picker-map .leaflet-container {
    border-radius: 12px;
}

.copy-contact-btn {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    color: var(--text-primary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.copy-contact-btn:hover {
    color: var(--accent);
}

.copy-contact-btn:hover i {
    opacity: 1;
}

.copy-contact-btn i {
    font-size: 0.75rem;
    opacity: 0.55;
    transition: opacity 0.2s;
}

.copy-contact-msg {
    color: #22c55e;
    font-size: 0.75rem;
    margin-left: 6px;
    white-space: nowrap;
}

.name-dup {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 2px var(--ring) !important;
}

.name-dup-note {
    color: #ff6961;
    font-size: 0.78rem;
    line-height: 1.3;
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    right: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (prefers-reduced-motion: reduce) {
    * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
