:root {
    --primary-color: #4e73df;
    --secondary-color: #858796;
    --success-color: #1cc88a;
    --info-color: #36b9cc;
    --warning-color: #f6c23e;
    --danger-color: #e74a3b;
    --light-color: #f8f9fc;
    --dark-color: #5a5c69;
    --body-bg: #f8f9fc;
    --card-bg: #ffffff;
    --text-primary: #5a5c69;
    --border-color: #e3e6f0;
    --bg-gradient: linear-gradient(135deg, #4e73df 10%, #224abe 100%);
    --layout-top-offset: 0px;
}

html,
body {
    overflow-x: hidden;
    max-width: 100%;
}

body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--body-bg) !important;
    color: var(--text-primary);
}

/* Force override common background classes to respect theme */
.bg-light {
    background-color: var(--body-bg) !important;
}

.bg-white {
    background-color: var(--card-bg) !important;
}

#wrapper {
    max-width: 100vw;
    overflow-x: hidden;
    background-color: var(--body-bg);
}

#page-content-wrapper {
    min-width: 0;
    /* Allow flex child to shrink */
    overflow-x: hidden;
    background-color: var(--body-bg);
    min-height: calc(100vh - var(--layout-top-offset));
}

.bg-gradient-primary {
    background: var(--bg-gradient);
    background-size: cover;
}

.card {
    border: none;
    box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15);
    border-radius: 0.35rem;
    background-color: var(--card-bg) !important;
}

.card-header {
    background-color: var(--card-bg) !important;
    border-bottom: 1px solid var(--border-color);
    font-weight: bold;
    color: var(--primary-color);
}

.text-gray-800 {
    color: var(--text-primary) !important;
}

.text-gray-600 {
    color: var(--text-primary);
    opacity: 0.8;
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    filter: brightness(0.9);
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.sidebar {
    min-height: calc(100vh - var(--layout-top-offset));
    background: var(--bg-gradient);
    min-width: 280px;
    max-width: 280px;
    transition: min-width 0.25s ease, max-width 0.25s ease, padding 0.25s ease;
}

@media (min-width: 992px) {
    .sidebar {
        box-shadow: 10px 0 22px rgba(15, 23, 42, 0.16);
    }
}

.sidebar .nav-link {
    color: var(--sidebar-text);
    font-weight: bold;
    box-shadow: inset 0 0 0 1px transparent;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 0.35rem;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

/* Desktop sidebar should stay attached to screen edge */
@media (min-width: 992px) {
    #wrapper {
        padding: 0;
    }

    #sidebar-wrapper.sidebar {
        margin-left: 0;
        min-height: calc(100vh - var(--layout-top-offset));
        border-radius: 0;
        border-left: 0;
    }
}

/* Sidebar Glass Mode (reversible via $enable_glass_sidebar flag in header.php) */
.sidebar.sidebar-glass-mode {
    background:
        radial-gradient(120% 90% at -12% -20%, rgba(96, 165, 250, 0.34) 0%, rgba(96, 165, 250, 0) 55%),
        linear-gradient(170deg, rgba(8, 20, 38, 0.68), rgba(21, 49, 80, 0.58) 68%, rgba(132, 151, 170, 0.34)) !important;
    border-right: 1px solid rgba(255, 255, 255, 0.22) !important;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.18),
        inset -10px 0 22px rgba(255, 255, 255, 0.04),
        8px 0 24px rgba(0, 0, 0, 0.14);
    backdrop-filter: blur(16px) saturate(120%);
    -webkit-backdrop-filter: blur(16px) saturate(120%);
}

.sidebar.sidebar-glass-mode .sidebar-heading {
    border-bottom-color: rgba(255, 255, 255, 0.2) !important;
}

.sidebar.sidebar-glass-mode .list-group {
    border-radius: 1rem;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.04));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.2),
        inset 0 -1px 0 rgba(255, 255, 255, 0.06);
    padding: 0.75rem 0.5rem;
}

.sidebar.sidebar-glass-mode .nav-link {
    border-radius: 0.85rem;
    margin-bottom: 0.45rem !important;
    padding: 0.75rem 0.9rem !important;
    color: rgba(238, 247, 255, 0.9);
    transition: all 0.2s ease;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.sidebar.sidebar-glass-mode .nav-link:hover {
    color: #ffffff;
    background: linear-gradient(90deg, rgba(44, 176, 255, 0.22), rgba(44, 176, 255, 0.08));
    box-shadow:
        inset 0 0 0 1px rgba(132, 221, 255, 0.32),
        0 6px 14px rgba(0, 0, 0, 0.2);
    transform: translateX(4px);
}

.sidebar.sidebar-glass-mode .nav-link.active {
    color: #ffffff;
    background: linear-gradient(90deg, rgba(30, 179, 255, 0.95), rgba(21, 147, 255, 0.88));
    box-shadow:
        inset 0 0 0 1px rgba(178, 237, 255, 0.45),
        0 8px 18px rgba(9, 112, 181, 0.45);
    transform: translateX(6px);
}

.sidebar.sidebar-glass-mode .nav-link.text-danger {
    color: #ffd1d1 !important;
    background: rgba(220, 53, 69, 0.1);
    box-shadow: inset 0 0 0 1px rgba(255, 161, 170, 0.28);
}

.sidebar-logo {
    display: block;
    margin: 0 auto;
    height: auto;
    transition: opacity 0.25s ease, transform 0.25s ease, max-width 0.25s ease;
}

.sidebar-logo-full {
    max-width: 180px;
    opacity: 1;
    transform: scale(1);
}

.sidebar-logo-compact {
    max-width: 44px;
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.8);
    margin-top: -6px;
    position: absolute;
    left: 50%;
    top: 50%;
}

.sidebar-control-slot {
    position: relative;
    justify-content: flex-end;
    padding: 0 0.1rem 0.35rem;
}

@media (min-width: 992px) {
    #wrapper:not(.sidebar-icon-only) #sidebar-wrapper .sidebar-control-slot {
        height: 0;
        padding: 0;
        margin: 0;
    }

    #wrapper:not(.sidebar-icon-only) #sidebar-wrapper .sidebar-control-slot .sidebar-collapse-toggle {
        position: absolute;
        right: 0.15rem;
        top: -8px;
        width: 24px;
        height: 24px;
        border-radius: 8px;
    }
}

.sidebar-collapse-toggle {
    position: relative;
    width: 28px;
    height: 28px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.14);
    color: #eef6ff;
    align-items: center;
    justify-content: center;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.2),
        0 6px 14px rgba(15, 23, 42, 0.22);
    z-index: 3;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.sidebar-collapse-toggle:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.22);
}

#sidebar-wrapper .sidebar-heading {
    min-height: 56px;
}

@media (min-width: 992px) {
    #wrapper.sidebar-icon-only #sidebar-wrapper.sidebar {
        min-width: 86px;
        max-width: 86px;
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }

    #wrapper.sidebar-icon-only #sidebar-wrapper .sidebar-heading {
        padding-bottom: 0.75rem !important;
        margin-bottom: 0.9rem !important;
    }

    #wrapper.sidebar-icon-only #sidebar-wrapper .sidebar-logo-full {
        opacity: 0;
        transform: scale(0.86);
        max-width: 44px;
    }

    #wrapper.sidebar-icon-only #sidebar-wrapper .sidebar-logo-compact {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }

    #wrapper.sidebar-icon-only #sidebar-wrapper .sidebar-control-slot {
        justify-content: center;
        padding: 0 0 0.45rem;
    }

    #wrapper.sidebar-icon-only #sidebar-wrapper .sidebar-control-slot .sidebar-collapse-toggle {
        position: relative;
        right: auto;
        top: auto;
        width: 28px;
        height: 28px;
        border-radius: 10px;
    }

    #wrapper.sidebar-icon-only #sidebar-wrapper .sidebar-collapse-toggle i {
        transform: rotate(180deg);
    }

    #wrapper.sidebar-icon-only #sidebar-wrapper .list-group {
        padding: 0.45rem 0.25rem;
    }

    #wrapper.sidebar-icon-only #sidebar-wrapper .sidebar-control-slot + .nav-link {
        margin-top: 0.2rem;
    }

    #wrapper.sidebar-icon-only #sidebar-wrapper .nav-link {
        font-size: 0 !important;
        text-align: center;
        padding: 0.72rem 0.35rem !important;
        margin-bottom: 0.35rem !important;
        transform: none !important;
    }

    #wrapper.sidebar-icon-only #sidebar-wrapper .nav-link i {
        font-size: 1.1rem !important;
        margin-right: 0 !important;
    }

    #wrapper.sidebar-icon-only #sidebar-wrapper .nav-link .badge,
    #wrapper.sidebar-icon-only #sidebar-wrapper .nav-link .fa-chevron-down {
        display: none !important;
    }

    #sidebar-wrapper.sidebar {
        overflow: hidden;
    }
}

.login-container {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    width: 100%;
    max-width: 400px;
}

/* Module Switcher Buttons */
.btn-group .btn {
    transition: all 0.3s ease;
    border-radius: 0.35rem !important;
    margin: 0 0.15rem;
    padding: 0.5rem 1rem;
    font-weight: 600;
}

.btn-group .btn:first-child {
    margin-left: 0;
}

.btn-group .btn:last-child {
    margin-right: 0;
}

.btn-group .btn i.fa-lg {
    font-size: 1.3rem;
}

.btn-group .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(78, 115, 223, 0.3);
}

.btn-group .btn-group .btn-primary:hover {
    filter: brightness(0.9);
}

.btn-group .btn-outline-primary:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

/* Active module badge */
.btn-group .btn .badge {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* MOBILE RESPONSIVE STYLES */
@media (max-width: 991px) {

    /* Sidebar mobile toggle */
    .sidebar {
        position: fixed !important;
        top: var(--layout-top-offset);
        left: -280px;
        bottom: 0;
        min-height: calc(100vh - var(--layout-top-offset));
        z-index: 1040;
        transition: left 0.3s ease;
    }

    #wrapper.toggled .sidebar {
        left: 0;
    }

    #page-content-wrapper {
        width: 100% !important;
    }
}

@media (max-width: 768px) {
    .btn-group .btn {
        padding: 0.5rem 0.75rem;
    }

    .container-fluid {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    h1,
    .h1 {
        font-size: 1.75rem;
    }

    h3,
    .h3 {
        font-size: 1.25rem;
    }

    .table-responsive {
        font-size: 0.875rem;
    }

    table th,
    table td {
        padding: 0.5rem !important;
        font-size: 0.85rem;
    }

    .card-body {
        padding: 1rem;
    }

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

    .modal-dialog {
        margin: 0.5rem;
    }

    .d-lg-inline {
        display: none !important;
    }
}

@media (max-width: 576px) {

    h1,
    .h1 {
        font-size: 1.5rem;
    }

    .card-body {
        padding: 0.75rem;
    }

    .badge {
        font-size: 0.7rem;
    }

    .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }

    .btn-sm {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }

    .row>div {
        margin-bottom: 0.75rem;
    }
}

/* Theme Switcher Protrusion (Çıkıntı) */
.theme-switcher-tab {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: var(--primary-color);
    color: white;
    width: 40px;
    height: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 10px 0 0 10px;
    z-index: 10001;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    gap: 10px;
}

.theme-switcher-tab:hover {
    width: 50px;
    background: var(--bg-gradient);
}

.theme-switcher-tab.pushed {
    right: 300px;
}

.theme-switcher-tab i {
    font-size: 1.2rem;
}

.theme-switcher-tab span {
    writing-mode: vertical-rl;
    text-transform: uppercase;
    font-size: 0.7rem;
    font-weight: bold;
    letter-spacing: 1px;
}

[data-theme="dark"] .theme-switcher-tab {
    background: #2d3748;
    border-left: 2px solid #4a5568;
}

/* Theme Settings Drawer */
.theme-settings-drawer {
    position: fixed;
    right: -300px;
    top: 0;
    width: 300px;
    height: 100vh;
    background: var(--card-bg);
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
    z-index: 10000;
    transition: right 0.3s ease;
    padding: 20px;
    border-left: 1px solid var(--border-color);
    overflow-y: auto;
}

.theme-settings-drawer.open {
    right: 0;
}

.theme-settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.theme-settings-header h5 {
    margin: 0;
    font-weight: 700;
    font-size: 1.1rem;
}

.theme-settings-section {
    margin-bottom: 25px;
}

.theme-settings-label {
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--text-secondary);
    margin-bottom: 12px;
    display: block;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.color-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    padding: 10px;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.color-option label {
    font-size: 0.9rem;
    cursor: pointer;
}

.color-input-wrapper {
    position: relative;
    width: 35px;
    height: 35px;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid var(--border-color);
}

.color-input {
    position: absolute;
    top: -10px;
    left: -10px;
    width: 60px;
    height: 60px;
    border: none;
    cursor: pointer;
    background: none;
}

/* Touch optimizations */
@media (hover: none) and (pointer: coarse) {

    .btn,
    a.nav-link,
    .list-group-item {
        min-height: 44px;
    }
}
