/**
 * ==========================================================================
 * MERIVA DESIGN SYSTEM (MDS) v2.5 - Final Polished Engine
 * ==========================================================================
 * Brand Identity:
 * - Primary: Black / charcoal (#060608 / #0A0A0E)
 * - Accent: Strategic Royal Gold (#D4AF37 / #A88418)
 * - Light Surfaces: Warm cream (#F7F3EC)
 * - Dark Surfaces: Charcoal (#08080A / #0D0D10 / #141418)
 * ==========================================================================
 */

/* ==========================================================================
   1. DESIGN TOKENS (CSS VARIABLES)
   ========================================================================== */
:root {
    /* --- COLOR SYSTEM --- */
    --meriva-primary: #060608;
    --meriva-primary-dark: #030304;
    --meriva-primary-light: #1C1C22;
    --meriva-primary-soft: #2A2A32;
    --meriva-primary-rgb: 6, 6, 8;
    --meriva-navy: #0A0A0E;
    --meriva-night: #060608;
    --meriva-amber: #D4AF37;

    /* Accent: MERİVA gold — CTA / badge / active */
    --meriva-gold: #D4AF37;
    --meriva-gold-light: #E5C45A;
    --meriva-gold-dark: #A88418;
    --meriva-gold-soft: rgba(212, 175, 55, 0.16);
    --meriva-gold-glow: rgba(212, 175, 55, 0.10);
    --meriva-gold-gradient: linear-gradient(135deg, #E5C45A 0%, #D4AF37 55%, #A88418 100%);

    /* Light Theme Surfaces & Backgrounds */
    --meriva-background: #F7F3EC;
    --meriva-surface: #FFFFFF;
    --meriva-surface-2: #F7F3EC;
    --meriva-surface-elevated: #FFFFFF;
    --meriva-surface-subtle: #F1EDE4;
    --meriva-border: #E2E8F0;
    --meriva-border-subtle: #EDF2F7;
    --meriva-text: #0F172A;
    --meriva-text-muted: #64748B;
    --meriva-text-subtle: #94A3B8;
    --meriva-bg: var(--meriva-background);

    /* Dark Theme Surfaces & Backgrounds */
    --meriva-dark-bg: #060608;
    --meriva-dark-surface: #0A0A0E;
    --meriva-dark-surface-elevated: #0D0D10;
    --meriva-dark-surface-card: #1C1C22;
    --meriva-dark-border: rgba(212, 175, 55, 0.12);
    --meriva-dark-border-subtle: rgba(255, 255, 255, 0.04);
    --meriva-dark-text: #F7F3EC;
    --meriva-dark-text-muted: #9A9AAA;
    --meriva-dark-text-subtle: #4A4A5A;

    /* Semantic / Status Colors */
    --meriva-success: #10B981;
    --meriva-success-dark: #059669;
    --meriva-success-soft: rgba(16, 185, 129, 0.12);

    --meriva-warning: #F59E0B;
    --meriva-warning-dark: #D97706;
    --meriva-warning-soft: rgba(245, 158, 11, 0.12);

    --meriva-danger: #F43F5E;
    --meriva-danger-dark: #E11D48;
    --meriva-danger-soft: rgba(244, 63, 94, 0.12);

    --meriva-info: #0EA5E9;
    --meriva-info-dark: #0284C7;
    --meriva-info-soft: rgba(14, 165, 233, 0.12);

    /* --- TYPOGRAPHY TOKENS --- */
    --meriva-font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --meriva-font-mono: 'JetBrains Mono', monospace;

    /* Type Scale */
    --meriva-font-size-display: clamp(2rem, 5.4vw, 3.75rem);
    --meriva-font-size-h1:      clamp(1.45rem, 2.8vw, 2rem);
    --meriva-font-size-h2:      clamp(1.2rem, 2.2vw, 1.6rem);
    --meriva-font-size-h3:      clamp(1.05rem, 1.6vw, 1.25rem);
    --meriva-font-size-h4:      1.0625rem;
    --meriva-font-size-body-lg: 1.0625rem;
    --meriva-font-size-body:    1rem;
    --meriva-font-size-body-sm: 0.875rem;
    --meriva-font-size-caption: 0.8125rem;
    --meriva-font-size-label:   0.75rem;
    --meriva-leading-tight: 1.22;
    --meriva-leading-body: 1.6;

    /* --- SPACING TOKENS (4/8pt Grid) --- */
    --meriva-space-1:  4px;
    --meriva-space-2:  8px;
    --meriva-space-3:  12px;
    --meriva-space-4:  16px;
    --meriva-space-5:  20px;
    --meriva-space-6:  24px;
    --meriva-space-8:  32px;
    --meriva-space-10: 40px;
    --meriva-space-12: 48px;
    --meriva-space-16: 64px;
    --meriva-space-20: 80px;
    --meriva-space-24: 96px;

    /* --- BORDER RADIUS TOKENS --- */
    --meriva-radius-xs:   4px;
    --meriva-radius-sm:   6px;
    --meriva-radius-md:   10px;
    --meriva-radius-lg:   14px;
    --meriva-radius-xl:   20px;
    --meriva-radius-2xl:  28px;
    --meriva-radius-pill: 9999px;
    --meriva-radius-full: 50%;
    --meriva-radius-small: var(--meriva-radius-sm);
    --meriva-radius-medium: var(--meriva-radius-md);
    --meriva-radius-large: var(--meriva-radius-lg);

    --meriva-container: 1320px;
    --meriva-gutter: 16px;

    /* --- SHADOW / ELEVATION TOKENS --- */
    --meriva-shadow-subtle:   0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
    --meriva-shadow-default:  0 4px 12px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.03);
    --meriva-shadow-elevated: 0 10px 25px -3px rgba(0, 0, 0, 0.08), 0 4px 10px -2px rgba(0, 0, 0, 0.04);
    --meriva-shadow-floating: 0 20px 35px -5px rgba(0, 0, 0, 0.12), 0 8px 16px -4px rgba(0, 0, 0, 0.06);
    --meriva-shadow-gold:     0 0 20px rgba(234, 179, 8, 0.25);
    --meriva-shadow-navy:     0 8px 24px rgba(0, 0, 0, 0.45);

    /* --- SHELL DIMENSIONS --- */
    --meriva-sidebar-width: 260px;
    --meriva-sidebar-width-collapsed: 72px;
    --meriva-header-height: 64px;
    --meriva-topbar-height: 0px;
    --meriva-sidebar-motion: 0.38s cubic-bezier(0.16, 1, 0.3, 1);

    /* --- TRANSITIONS --- */
    --meriva-transition-fast:   0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --meriva-transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --meriva-transition-smooth: 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==========================================================================
   2. GLOBAL RESET & BASE
   ========================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    max-width: 100%;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--meriva-font-sans);
    font-size: var(--meriva-font-size-body);
    line-height: var(--meriva-leading-body);
    color: var(--meriva-text);
    background-color: var(--meriva-background);
    margin: 0;
    padding: 0;
    max-width: 100%;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
    -webkit-font-smoothing: antialiased;
}

body.m-sidebar-open {
    overflow: hidden;
}

[data-bs-theme="dark"] body {
    color: var(--meriva-dark-text);
    background-color: var(--meriva-dark-bg);
}

img, svg, video, canvas {
    max-width: 100%;
    height: auto;
    display: inline-block;
    vertical-align: middle;
}

:focus-visible {
    outline: 2px solid var(--meriva-gold) !important;
    outline-offset: 2px !important;
}

/* ==========================================================================
   3. PANEL SIDEBAR SWITCHER
   ========================================================================== */
.m-panel-switch {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-bottom: var(--meriva-space-3);
    margin-bottom: var(--meriva-space-2);
    border-bottom: 1px solid var(--meriva-dark-border);
}

.m-panel-switch .m-nav-group-heading {
    padding-top: 0;
}

.m-panel-dev-login {
    margin-bottom: var(--meriva-space-2);
}

.m-panel-dev-login-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.m-panel-dev-login-actions .m-btn {
    font-size: 0.65rem;
    padding: 0.2rem 0.45rem;
}

/* ==========================================================================
   4. APP SHELL LAYOUT ARCHITECTURE
   ========================================================================== */
.m-app-shell {
    display: flex;
    min-height: 100vh;
    width: 100%;
    position: relative;
    background-color: var(--meriva-background);
}
[data-bs-theme="dark"] .m-app-shell {
    background-color: var(--meriva-dark-bg);
}

/* --- SIDEBAR --- */
.m-app-sidebar {
    width: var(--meriva-sidebar-width);
    min-width: var(--meriva-sidebar-width);
    background-color: var(--meriva-dark-surface);
    border-right: 1px solid var(--meriva-dark-border);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100vh;
    position: sticky;
    top: 0;
    z-index: 1050;
    padding: var(--meriva-space-4);
    overflow-x: hidden;
    overflow-y: auto;
    flex: 0 0 var(--meriva-sidebar-width);
    transition:
        width var(--meriva-sidebar-motion),
        min-width var(--meriva-sidebar-motion),
        flex-basis var(--meriva-sidebar-motion),
        padding var(--meriva-sidebar-motion),
        transform var(--meriva-sidebar-motion);
}

.m-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: var(--meriva-space-3);
    margin-bottom: var(--meriva-space-2);
    border-bottom: 1px solid var(--meriva-dark-border);
}

.m-sidebar-brand {
    display: flex;
    align-items: center;
    gap: var(--meriva-space-2);
    text-decoration: none;
}

.m-sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
    overflow-x: hidden;
    flex-grow: 1;
    padding-right: 2px;
}

.m-sidebar-nav::-webkit-scrollbar {
    width: 4px;
}
.m-sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.m-nav-group-heading {
    font-size: var(--meriva-font-size-label);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--meriva-dark-text-subtle);
    padding: 12px 12px 4px;
}

.m-nav-item {
    color: var(--meriva-dark-text-muted);
    font-size: var(--meriva-font-size-body-sm);
    font-weight: 600;
    padding: 8px 12px;
    min-height: 40px;
    border-radius: var(--meriva-radius-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-decoration: none;
    transition: var(--meriva-transition-fast);
    border-left: 3px solid transparent;
    white-space: nowrap;
}

.m-nav-item span {
    display: inline-flex;
    align-items: center;
    min-width: 0;
    white-space: nowrap;
}

.m-nav-item:hover {
    color: #FFFFFF;
    background-color: var(--meriva-dark-surface-elevated);
}

.m-nav-item.active {
    background-color: var(--meriva-dark-surface-card);
    color: var(--meriva-gold);
    border-left-color: var(--meriva-gold);
    font-weight: 700;
}

.m-nav-item-icon {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
    margin-right: 8px;
    display: inline-block;
    vertical-align: middle;
}

.m-sidebar-footer {
    padding-top: var(--meriva-space-3);
    margin-top: var(--meriva-space-2);
    border-top: 1px solid var(--meriva-dark-border);
}

.m-sidebar-user-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    background-color: var(--meriva-dark-surface-elevated);
    border: 1px solid var(--meriva-dark-border);
    border-radius: var(--meriva-radius-md);
    text-decoration: none;
    color: var(--meriva-dark-text);
    transition: var(--meriva-transition-fast);
}
.m-sidebar-user-card:hover {
    background-color: var(--meriva-dark-surface-card);
    color: #FFFFFF;
    border-color: rgba(234, 179, 8, 0.3);
}

/* --- MAIN CONTAINER & HEADER --- */
.m-app-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background-color: var(--meriva-background);
    transition: transform var(--meriva-sidebar-motion);
}
[data-bs-theme="dark"] .m-app-container {
    background-color: var(--meriva-dark-bg);
}

/* Desktop: icon rail that expands on hover; main column tracks the width. */
@media (min-width: 992px) {
    .m-app-sidebar {
        width: var(--meriva-sidebar-width-collapsed);
        min-width: var(--meriva-sidebar-width-collapsed);
        flex: 0 0 var(--meriva-sidebar-width-collapsed);
        padding: var(--meriva-space-4) 10px;
        transition-delay: 0.12s;
    }

    .m-app-sidebar:hover,
    .m-app-sidebar:focus-within,
    .m-app-sidebar.is-hover-open {
        width: var(--meriva-sidebar-width);
        min-width: var(--meriva-sidebar-width);
        flex-basis: var(--meriva-sidebar-width);
        padding: var(--meriva-space-4);
        transition-delay: 0s;
    }

    .m-app-sidebar:not(:hover):not(:focus-within):not(.is-hover-open) .m-sidebar-header {
        justify-content: center;
        border-bottom-color: transparent;
    }

    .m-app-sidebar:not(:hover):not(:focus-within):not(.is-hover-open) .m-sidebar-brand {
        justify-content: center;
        gap: 0;
        width: 100%;
    }

    .m-app-sidebar:not(:hover):not(:focus-within):not(.is-hover-open) .m-sidebar-brand > div,
    .m-app-sidebar:not(:hover):not(:focus-within):not(.is-hover-open) .m-nav-group-heading,
    .m-app-sidebar:not(:hover):not(:focus-within):not(.is-hover-open) .m-sidebar-user-card .fw-bold,
    .m-app-sidebar:not(:hover):not(:focus-within):not(.is-hover-open) .m-sidebar-user-card .text-secondary,
    .m-app-sidebar:not(:hover):not(:focus-within):not(.is-hover-open) .m-sidebar-user-card .bi-chevron-right,
    .m-app-sidebar:not(:hover):not(:focus-within):not(.is-hover-open) .m-sidebar-footer form {
        opacity: 0;
        width: 0;
        height: 0;
        overflow: hidden;
        margin: 0;
        padding: 0;
        pointer-events: none;
        white-space: nowrap;
    }

    .m-app-sidebar:not(:hover):not(:focus-within):not(.is-hover-open) .m-nav-item {
        justify-content: center;
        padding-left: 0;
        padding-right: 0;
        border-left-width: 0;
    }

    .m-app-sidebar:not(:hover):not(:focus-within):not(.is-hover-open) .m-nav-item span {
        font-size: 0;
        letter-spacing: 0;
        gap: 0;
    }

    .m-app-sidebar:not(:hover):not(:focus-within):not(.is-hover-open) .m-nav-item-icon {
        font-size: 1.15rem;
        margin-right: 0;
        width: 24px;
    }

    .m-app-sidebar:not(:hover):not(:focus-within):not(.is-hover-open) .m-sidebar-user-card {
        justify-content: center;
        margin-right: 0 !important;
        padding: 8px 6px;
    }

    .m-app-sidebar:not(:hover):not(:focus-within):not(.is-hover-open) .m-sidebar-footer > .d-flex {
        justify-content: center;
    }
}

.m-app-header {
    min-height: var(--meriva-header-height);
    height: auto;
    background-color: var(--meriva-surface);
    border-bottom: 1px solid var(--meriva-border);
    padding: 8px var(--meriva-space-6);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1040;
    backdrop-filter: blur(12px);
}
[data-bs-theme="dark"] .m-app-header {
    background-color: var(--meriva-dark-surface);
    border-bottom-color: var(--meriva-dark-border);
}

.m-app-main {
    flex-grow: 1;
    padding: var(--meriva-space-6);
    max-width: var(--meriva-container);
    width: 100%;
    margin: 0 auto;
}

/* ==========================================================================
   5. BUTTON SYSTEM
   ========================================================================== */
.m-btn {
    font-family: var(--meriva-font-sans);
    font-weight: 600;
    font-size: var(--meriva-font-size-body-sm);
    padding: 8px 16px;
    min-height: 38px;
    border-radius: var(--meriva-radius-md);
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    cursor: pointer;
    transition: var(--meriva-transition-fast);
    line-height: 1.3;
    white-space: normal;
    user-select: none;
    max-width: 100%;
    box-sizing: border-box;
}

.m-btn:disabled, .m-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.m-btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}
.m-btn-loading::after {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    top: 50%;
    left: 50%;
    margin-top: -9px;
    margin-left: -9px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: currentColor;
    animation: mSpin 0.7s infinite linear;
}
@keyframes mSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.m-btn-sm { padding: 5px 12px; font-size: var(--meriva-font-size-caption); border-radius: var(--meriva-radius-sm); min-height: 32px; }
.m-btn-md { padding: 8px 16px; font-size: var(--meriva-font-size-body-sm); min-height: 40px; }
.m-btn-lg { padding: 12px 24px; font-size: var(--meriva-font-size-body-lg); border-radius: var(--meriva-radius-lg); min-height: 48px; }
.m-btn-pill { border-radius: var(--meriva-radius-pill); }

.m-btn-primary {
    background-color: var(--meriva-primary);
    color: #FFFFFF;
    border-color: var(--meriva-primary-light);
}
.m-btn-primary:hover {
    background-color: var(--meriva-primary-light);
    color: #FFFFFF;
    border-color: var(--meriva-primary-soft);
}

.m-btn-secondary {
    background-color: var(--meriva-surface-subtle);
    color: var(--meriva-text);
    border-color: var(--meriva-border);
}
.m-btn-secondary:hover {
    background-color: var(--meriva-border);
    color: var(--meriva-text);
}
[data-bs-theme="dark"] .m-btn-secondary {
    background-color: var(--meriva-dark-surface-elevated);
    color: var(--meriva-dark-text);
    border-color: var(--meriva-dark-border);
}
[data-bs-theme="dark"] .m-btn-secondary:hover {
    background-color: var(--meriva-dark-surface-card);
}

.m-btn-gold {
    background: var(--meriva-gold-gradient);
    color: var(--meriva-primary-dark);
    font-weight: 700;
}
.m-btn-gold:hover {
    background: linear-gradient(135deg, #FACC15 0%, #EAB308 100%);
    color: var(--meriva-primary-dark);
    box-shadow: var(--meriva-shadow-gold);
}

.m-btn-outline-gold {
    background: transparent;
    border-color: var(--meriva-gold);
    color: var(--meriva-gold);
}
.m-btn-outline-gold:hover {
    background: var(--meriva-gold-glow);
    color: var(--meriva-gold-light);
    border-color: var(--meriva-gold-light);
}

.m-btn-danger, .m-btn-rose {
    background-color: var(--meriva-danger-soft);
    color: var(--meriva-danger);
    border-color: rgba(244, 63, 94, 0.25);
}
.m-btn-danger:hover, .m-btn-rose:hover {
    background-color: var(--meriva-danger);
    color: #FFFFFF;
}

.m-btn-success {
    background-color: var(--meriva-success-soft);
    color: var(--meriva-success);
    border-color: rgba(16, 185, 129, 0.25);
}
.m-btn-success:hover {
    background-color: var(--meriva-success);
    color: #FFFFFF;
}

.m-btn-icon {
    width: 38px;
    height: 38px;
    min-height: 38px;
    padding: 0;
    border-radius: var(--meriva-radius-md);
    flex-shrink: 0;
    white-space: nowrap;
}
.m-btn-icon.m-btn-sm { width: 32px; height: 32px; min-height: 32px; }
.m-btn-icon.m-btn-lg { width: 44px; height: 44px; min-height: 44px; }

/* ==========================================================================
   6. CARD SYSTEM
   ========================================================================== */
.m-card {
    background-color: var(--meriva-surface);
    border: 1px solid var(--meriva-border);
    border-radius: var(--meriva-radius-lg);
    box-shadow: var(--meriva-shadow-subtle);
    transition: var(--meriva-transition-normal);
    position: relative;
    overflow-wrap: break-word;
    word-break: break-word;
}

[data-bs-theme="dark"] .m-card,
.m-card-dark {
    background-color: var(--meriva-dark-surface);
    border-color: var(--meriva-dark-border);
    color: var(--meriva-dark-text);
    box-shadow: var(--meriva-shadow-navy);
}

.m-card-standard { padding: var(--meriva-space-5); }

.m-card-stat {
    padding: var(--meriva-space-4);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 110px;
}
.m-card-stat:hover {
    border-color: var(--meriva-text-muted);
    transform: translateY(-2px);
    box-shadow: var(--meriva-shadow-default);
}
[data-bs-theme="dark"] .m-card-stat:hover {
    border-color: rgba(234, 179, 8, 0.3);
}

/* Dark Theme Specific Cards */
.m-hero-card-dark {
    background: radial-gradient(circle at 85% 50%, #1C1C22 0%, #0A0A0E 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--meriva-radius-xl);
    padding: var(--meriva-space-6);
    position: relative;
    overflow: hidden;
}

.m-stat-card-dark {
    background-color: var(--meriva-dark-surface-elevated);
    border: 1px solid var(--meriva-dark-border);
    border-radius: var(--meriva-radius-lg);
    box-shadow: var(--meriva-shadow-navy);
}

/* ==========================================================================
   7. INPUT & FORM SYSTEM
   ========================================================================== */
.m-form-group { margin-bottom: var(--meriva-space-4); }

.m-form-label, .form-label {
    display: block;
    font-size: var(--meriva-font-size-body-sm);
    font-weight: 600;
    margin-bottom: var(--meriva-space-2);
    color: var(--meriva-text);
}
[data-bs-theme="dark"] .m-form-label,
[data-bs-theme="dark"] .form-label { color: var(--meriva-dark-text); }

.m-input, .m-select, .m-textarea,
.form-control, .form-select {
    width: 100%;
    font-family: var(--meriva-font-sans);
    font-size: var(--meriva-font-size-body-sm);
    padding: 9px 14px;
    min-height: 42px;
    border-radius: var(--meriva-radius-md);
    border: 1px solid var(--meriva-border);
    background-color: var(--meriva-surface);
    color: var(--meriva-text);
    transition: var(--meriva-transition-fast);
}

.m-input:focus, .m-select:focus, .m-textarea:focus,
.form-control:focus, .form-select:focus {
    outline: none;
    border-color: var(--meriva-primary);
    box-shadow: 0 0 0 3px rgba(10, 18, 36, 0.12);
}

[data-bs-theme="dark"] .m-input,
[data-bs-theme="dark"] .m-select,
[data-bs-theme="dark"] .m-textarea,
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background-color: var(--meriva-primary-dark);
    border-color: var(--meriva-dark-border);
    color: var(--meriva-dark-text);
}
[data-bs-theme="dark"] .m-input:focus,
[data-bs-theme="dark"] .m-select:focus,
[data-bs-theme="dark"] .m-textarea:focus,
[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
    border-color: var(--meriva-gold);
    box-shadow: 0 0 0 3px var(--meriva-gold-glow);
}

/* ==========================================================================
   8. BADGE SYSTEM
   ========================================================================== */
.m-badge {
    font-family: var(--meriva-font-sans);
    font-size: var(--meriva-font-size-caption);
    font-weight: 700;
    padding: 3px 10px;
    border-radius: var(--meriva-radius-pill);
    display: inline-flex;
    align-items: center;
    gap: 5px;
    line-height: 1.25;
    white-space: nowrap;
}

.m-badge-success, .m-badge-emerald { background-color: var(--meriva-success-soft); color: var(--meriva-success); border: 1px solid rgba(16, 185, 129, 0.25); }
.m-badge-warning { background-color: var(--meriva-warning-soft); color: var(--meriva-warning-dark); border: 1px solid rgba(245, 158, 11, 0.25); }
.m-badge-danger, .m-badge-rose { background-color: var(--meriva-danger-soft); color: var(--meriva-danger); border: 1px solid rgba(244, 63, 94, 0.25); }
.m-badge-info { background-color: var(--meriva-info-soft); color: var(--meriva-info-dark); border: 1px solid rgba(14, 165, 233, 0.25); }
.m-badge-neutral, .m-badge-slate { background-color: var(--meriva-surface-subtle); color: var(--meriva-text-muted); border: 1px solid var(--meriva-border); }
[data-bs-theme="dark"] .m-badge-neutral,
[data-bs-theme="dark"] .m-badge-slate { background-color: var(--meriva-dark-surface-card); color: var(--meriva-dark-text-muted); border-color: var(--meriva-dark-border); }

.m-badge-premium, .m-badge-gold {
    background-color: var(--meriva-gold-glow);
    color: var(--meriva-gold-dark);
    border: 1px solid rgba(234, 179, 8, 0.4);
    font-weight: 800;
}
[data-bs-theme="dark"] .m-badge-premium,
[data-bs-theme="dark"] .m-badge-gold { color: var(--meriva-gold-light); }

/* ==========================================================================
   9. AVATAR SYSTEM
   ========================================================================== */
.m-avatar {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--meriva-radius-full);
    object-fit: cover;
    flex-shrink: 0;
    background-color: var(--meriva-surface-subtle);
    font-weight: 700;
    color: var(--meriva-text);
}

.m-avatar-sm { width: 32px; height: 32px; font-size: var(--meriva-font-size-caption); }
.m-avatar-md { width: 42px; height: 42px; font-size: var(--meriva-font-size-body-sm); }
.m-avatar-lg { width: 56px; height: 56px; font-size: var(--meriva-font-size-h3); }
.m-avatar-xl { width: 72px; height: 72px; font-size: var(--meriva-font-size-h2); }

/* ==========================================================================
   10. TABLE SYSTEM
   ========================================================================== */
.m-table-container {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--meriva-border);
    border-radius: var(--meriva-radius-lg);
    background-color: var(--meriva-surface);
    -webkit-overflow-scrolling: touch;
}
[data-bs-theme="dark"] .m-table-container {
    border-color: var(--meriva-dark-border);
    background-color: var(--meriva-dark-surface);
}

.m-table {
    width: 100%;
    min-width: 540px;
    margin-bottom: 0;
    border-collapse: collapse;
    font-size: var(--meriva-font-size-body-sm);
}

.m-table th {
    padding: 12px 16px;
    font-weight: 700;
    font-size: var(--meriva-font-size-caption);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--meriva-text-muted);
    background-color: var(--meriva-surface-subtle);
    border-bottom: 1px solid var(--meriva-border);
}
[data-bs-theme="dark"] .m-table th {
    background-color: var(--meriva-dark-surface-elevated);
    border-bottom-color: var(--meriva-dark-border);
    color: var(--meriva-dark-text-muted);
}

.m-table td {
    padding: 14px 16px;
    vertical-align: middle;
    border-bottom: 1px solid var(--meriva-border-subtle);
    color: var(--meriva-text);
}
[data-bs-theme="dark"] .m-table td {
    border-bottom-color: var(--meriva-dark-border-subtle);
    color: var(--meriva-dark-text);
}

.m-table tbody tr:hover { background-color: var(--meriva-surface-subtle); }
[data-bs-theme="dark"] .m-table tbody tr:hover { background-color: var(--meriva-dark-surface-card); }

/* ==========================================================================
   11. EMPTY STATE & ALERTS
   ========================================================================== */
.m-empty-state {
    padding: var(--meriva-space-12) var(--meriva-space-6);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.m-empty-icon { font-size: 3rem; color: var(--meriva-text-subtle); margin-bottom: var(--meriva-space-3); }
.m-empty-title { font-size: var(--meriva-font-size-h3); font-weight: 700; color: var(--meriva-text); margin-bottom: var(--meriva-space-2); }
[data-bs-theme="dark"] .m-empty-title { color: var(--meriva-dark-text); }
.m-empty-desc { font-size: var(--meriva-font-size-body-sm); color: var(--meriva-text-muted); max-width: 420px; margin-bottom: var(--meriva-space-5); }

.m-alert {
    padding: var(--meriva-space-4);
    border-radius: var(--meriva-radius-md);
    border: 1px solid transparent;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: var(--meriva-font-size-body-sm);
    margin-bottom: var(--meriva-space-4);
}
.m-alert-success { background-color: var(--meriva-success-soft); border-color: rgba(16, 185, 129, 0.3); color: var(--meriva-success-dark); }
.m-alert-warning { background-color: var(--meriva-warning-soft); border-color: rgba(245, 158, 11, 0.3); color: var(--meriva-warning-dark); }
.m-alert-danger  { background-color: var(--meriva-danger-soft);  border-color: rgba(244, 63, 94, 0.3);  color: var(--meriva-danger-dark); }
.m-alert-info    { background-color: var(--meriva-info-soft);    border-color: rgba(14, 165, 233, 0.3); color: var(--meriva-info-dark); }

/* ==========================================================================
   12. MOBILE FLOATING DOCK
   ========================================================================== */
.m-mobile-dock {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    min-height: 62px;
    height: auto;
    padding-bottom: env(safe-area-inset-bottom);
    background-color: var(--meriva-surface);
    border-top: 1px solid var(--meriva-border);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 1040;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
}
[data-bs-theme="dark"] .m-mobile-dock {
    background-color: var(--meriva-dark-surface);
    border-top-color: var(--meriva-dark-border);
}
.m-dock-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--meriva-text-muted);
    text-decoration: none;
    font-size: 0.65rem;
    font-weight: 600;
    gap: 2px;
    flex: 1;
    height: 100%;
    min-height: 48px;
}
.m-dock-link.active {
    color: var(--meriva-primary);
    font-weight: 800;
}
[data-bs-theme="dark"] .m-dock-link.active {
    color: var(--meriva-gold);
}
.m-dock-fab {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--meriva-gold-gradient);
    color: var(--meriva-primary-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    box-shadow: var(--meriva-shadow-gold);
    text-decoration: none;
    margin-top: -20px;
    border: 3px solid var(--meriva-surface);
    flex-shrink: 0;
}

/* ==========================================================================
   13. RESPONSIVE DRAWER & BREAKPOINT RULES
   ========================================================================== */
.m-sidebar-overlay {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(4, 7, 17, 0.7);
    backdrop-filter: blur(4px);
    z-index: 1045;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--meriva-transition-normal), visibility var(--meriva-transition-normal);
}
.m-sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
}

@media (max-width: 991.98px) {
    .m-app-sidebar {
        position: fixed;
        top: 0;
        left: calc(-1 * var(--meriva-sidebar-width));
        width: var(--meriva-sidebar-width);
        min-width: var(--meriva-sidebar-width);
        max-width: min(var(--meriva-sidebar-width), 100%);
        flex: none;
        height: 100dvh;
        z-index: 1055;
        box-shadow: var(--meriva-shadow-floating);
        padding: var(--meriva-space-4);
        padding-top: calc(var(--meriva-space-4) + env(safe-area-inset-top, 0px));
        transition-delay: 0s;
    }
    .m-app-sidebar.show-mobile {
        transform: translateX(var(--meriva-sidebar-width));
    }
    .m-app-shell {
        overflow-x: clip;
    }
    .m-app-container {
        transform: translateX(0);
    }
    body.m-sidebar-open .m-app-container {
        transform: translateX(var(--meriva-sidebar-width));
        will-change: transform;
    }
    .m-app-header {
        position: relative;
        padding: 8px var(--meriva-space-4);
    }
    .m-app-main {
        padding: var(--meriva-space-4);
    }
    body:has(.m-mobile-dock) .m-app-main {
        padding-bottom: calc(88px + env(safe-area-inset-bottom));
    }
    .display-3 {
        font-size: 2rem !important;
        line-height: 1.15 !important;
    }
    .topluluk-wrapper {
        height: auto !important;
        min-height: 0 !important;
        border-radius: 1rem !important;
    }
    .topluluk-wrapper > .row {
        height: auto !important;
    }
    .topluluk-sidebar {
        max-height: 280px;
        border-right: none !important;
        border-bottom: 1px solid rgba(212, 175, 55, 0.18);
    }
    .topluluk-feed {
        min-height: 52vh;
    }
}

@media (max-width: 767.98px) {
    .m-app-main {
        padding: 12px 12px 12px 12px;
    }
    body:has(.m-mobile-dock) .m-app-main {
        padding-bottom: calc(88px + env(safe-area-inset-bottom));
    }

    .m-card {
        padding: 16px !important;
        border-radius: var(--meriva-radius-md);
    }

    .m-input, .m-select, .m-textarea,
    .form-control, .form-select {
        font-size: 16px !important;
    }

    .m-page-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 12px;
        margin-bottom: var(--meriva-space-4);
    }
    .m-page-header > div,
    .m-page-header > a {
        width: 100%;
    }
    .m-explore-panel {
        min-height: 0 !important;
    }
}

/* ==========================================================================
   14. REDUCED MOTION SUPPORT (ACCESSIBILITY)
   ========================================================================== */
.m-explore-panel { min-height: 640px; }
.m-h1 { font-size: var(--meriva-font-size-h1); font-weight: 700; letter-spacing: -0.03em; line-height: var(--meriva-leading-tight); }
.m-h2 { font-size: var(--meriva-font-size-h2); font-weight: 700; letter-spacing: -0.02em; line-height: var(--meriva-leading-tight); }
.m-h3 { font-size: var(--meriva-font-size-h3); font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; }
.m-caption { font-size: var(--meriva-font-size-caption); line-height: 1.5; color: var(--meriva-text-muted); }
.m-display { font-size: var(--meriva-font-size-display); line-height: var(--meriva-leading-tight); letter-spacing: -0.04em; font-weight: 700; }
.m-font-mono { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }
.fw-extrabold { font-weight: 800 !important; }
.fw-black { font-weight: 900 !important; }
.m-search-box { position: relative; }
.m-search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); }
.m-avatar-status { position: absolute; bottom: 0; right: 0; width: 10px; height: 10px; border-radius: 50%; border: 2px solid #0A0A0E; background: #22c55e; }
.m-card-action { display: flex; gap: 8px; align-items: center; }
input.m-check { width: 1.05rem; height: 1.05rem; accent-color: var(--meriva-gold); }
.m-btn-ghost { background: transparent; border: 1px solid transparent; color: inherit; }
.m-btn-ghost:hover { background: rgba(255,255,255,0.06); }
.m-validation-feedback { color: #ef4444; font-size: 0.8rem; margin-top: 0.25rem; }
.text-truncate-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hover-bg-light:hover { background: rgba(255,255,255,0.04); }
.m-breadcrumb { display: flex; flex-wrap: wrap; gap: 6px; font-size: 0.8rem; }
.m-explore-hero {
    background: linear-gradient(145deg, #111114 0%, #0A0A0E 55%, #1A1408 100%);
    border: 1px solid rgba(201, 162, 39, 0.35);
    border-radius: 1.25rem;
    padding: 1.35rem 1.5rem;
}
.m-city-leaflet {
    height: 420px;
    width: 100%;
    max-width: 100%;
}
.m-turkey-map-wrapper {
    overflow: hidden;
    max-width: 100%;
}

@media (max-width: 768px) {
    .m-city-leaflet { height: 260px; }
    .m-tr-map { max-height: 180px !important; }
}

.m-alert-info { background: rgba(56, 189, 248, 0.12); border: 1px solid rgba(56, 189, 248, 0.35); color: inherit; padding: 0.85rem 1rem; border-radius: 0.85rem; }

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