/* =====================================================
   PVZPANEL — Основные стили
   Dark theme, Bootstrap 5 override
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ===== CSS ПЕРЕМЕННЫЕ ===== */
:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-card: #1e2130;
    --bg-hover: #252836;
    --bg-active: #2d3148;
    --accent: #6366f1;
    --accent-hover: #5254cc;
    --accent-soft: rgba(99, 102, 241, 0.15);
    --text-primary: #e8eaf6;
    --text-secondary: #9094b5;
    --text-muted: #5c607d;
    --border: rgba(255, 255, 255, 0.07);
    --border-accent: rgba(99, 102, 241, 0.4);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --sidebar-width: 240px;
    --topbar-h: 60px;
    --bottom-nav-h: 64px;
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.2s ease;
}

/* ===== СБРОС И БАЗА ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
    overflow: hidden;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    touch-action: pan-y;
}

/* ===== СКРОЛЛБАР ===== */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
}

/* ===== MODAL SCROLLBAR ===== */
.modal-body {
    scrollbar-width: thin;
    scrollbar-color: var(--text-muted) transparent;
}

.modal-body::-webkit-scrollbar {
    width: 4px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: var(--text-muted);
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100%;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 200;
    transition: transform var(--transition);
}

.sidebar-header {
    padding: 12px 16px 0px;
    border-bottom: 1px solid var(--border);
    height: var(--topbar-h);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 700;
    color: var(--accent);
}

.sidebar-logo i {
    font-size: 22px;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: all var(--transition);
    margin-bottom: 2px;
}

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

.sidebar-link.active {
    background: var(--accent-soft);
    color: var(--accent);
}

.sidebar-link i {
    font-size: 17px;
    min-width: 20px;
}

.sidebar-link[aria-expanded="true"] .bi-chevron-down {
    transform: rotate(180deg);
}

.sidebar-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 12px;
}

.sidebar-heading {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    text-transform: uppercase;
    padding: 4px 12px;
    margin-top: 4px;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
}

.sidebar-user:hover {
    background: var(--bg-hover);
}

.sidebar-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.sidebar-user-name {
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 10px;
    color: var(--text-muted);
}

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-left: var(--sidebar-width);
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ===== TOPBAR ===== */
.topbar {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 100;
}

.topbar-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 22px;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--transition);
}

.topbar-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.topbar-title {
    font-weight: 600;
    font-size: 15px;
    flex: 1;
}

.topbar-actions {
    display: flex;
    gap: 4px;
}

.topbar-btn {
    position: relative;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition);
}

.topbar-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.topbar-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    background: #ef4444;
    color: white;
    font-size: 9px;
    font-weight: 700;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
}

/* ===== PAGE CONTENT ===== */
.page-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

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

/* ===== LOADING & CSS TRANSITIONS (SPA) ===== */
.loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
}

/* Скелетон загрузчик */
.skeleton {
    background: linear-gradient(-90deg, var(--bg-hover) 0%, var(--bg-active) 50%, var(--bg-hover) 100%);
    background-size: 400% 400%;
    animation: skeletonGlow 1.2s ease-in-out infinite;
    border-radius: var(--radius-sm);
    color: transparent !important;
    border: none !important;
    pointer-events: none;
    box-shadow: none !important;
}

.skeleton *,
.skeleton::before,
.skeleton::after {
    visibility: hidden;
}

@keyframes skeletonGlow {
    0% {
        background-position: 0% 0%;
    }

    100% {
        background-position: -135% 0%;
    }
}

/* Классы переходов для SPA (Fade in/out) */
.page-enter {
    animation: pageEnter 0.25s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.page-exit {
    animation: pageExit 0.15s ease-out forwards;
}

@keyframes pageEnter {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

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

@keyframes pageExit {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(8px);
    }
}

/* Индикатор загрузки на кнопке */
.btn.loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 1rem;
    height: 1rem;
    top: calc(50% - 0.5rem);
    left: calc(50% - 0.5rem);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spinButton 0.6s linear infinite;
}

@keyframes spinButton {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Прогресс-бар вверху */
#progressBar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: var(--accent);
    z-index: 9999;
    transition: width 0.3s ease, opacity 0.3s ease;
    width: 0;
    opacity: 0;
}

/* ===== CARDS ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: 16px 20px;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

/* Stat card */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all var(--transition);
}

.stat-card:hover {
    border-color: var(--border-accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    background: var(--accent-soft);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ===== ТАБЛИЦЫ ===== */
.table {
    color: var(--text-primary);
    border-color: var(--border);
}

.table> :not(caption)>*>* {
    background: transparent;
    border-color: var(--border);
    padding: 12px 16px;
}

.table thead th {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.table tbody tr:hover td {
    background: var(--bg-hover) !important;
}

/* ===== КНОПКИ (override Bootstrap) ===== */
.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    font-weight: 500;
}

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

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

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

/* ===== ФОРМЫ ===== */
.form-control,
.form-select {
    background: var(--bg-secondary);
    border-color: var(--border);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    transition: all var(--transition);
}

.form-control:focus,
.form-select:focus {
    background: var(--bg-secondary);
    border-color: var(--accent);
    color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

/* ===== TOAST УВЕДОМЛЕНИЯ ===== */
.pvz-toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    box-shadow: var(--shadow);
    min-width: 280px;
}

.pvz-toast .toast-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.pvz-toast.toast-success {
    border-left: 3px solid #22c55e;
}

.pvz-toast.toast-error {
    border-left: 3px solid #ef4444;
}

.pvz-toast.toast-warning {
    border-left: 3px solid #f59e0b;
}

.pvz-toast.toast-info {
    border-left: 3px solid var(--accent);
}

/* ===== МОДАЛКИ ===== */
.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
}

.modal-header {
    border-bottom: 1px solid var(--border);
    padding: 16px 20px;
}

.modal-footer {
    border-top: 1px solid var(--border);
    padding: 12px 20px;
}

.btn-close {
    filter: invert(1) opacity(0.5);
}

.btn-close:hover {
    filter: invert(1) opacity(1);
}

/* ===== НИЖНЕЕ МЕНЮ (мобильное) ===== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-h);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 300;
    padding: 0 12px;
    padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 8px;
    font-weight: 500;
    transition: all var(--transition);
}

.bottom-nav-item i {
    font-size: 22px;
}

.bottom-nav-item:hover {
    color: var(--text-primary);
}

.bottom-nav-item.active {
    color: var(--accent);
}

/* ===== СТРАНИЦА ВХОДА ===== */
.login-wrapper {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    padding: 20px;
    overflow-y: auto;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) * 1.5);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow);
}

.login-logo {
    text-align: center;
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 8px;
}

.login-logo i {
    font-size: 36px;
    display: block;
    margin-bottom: 8px;
}

.login-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 32px;
}

/* OTP input (код) */
.otp-code {
    text-align: center;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 12px;
    padding: 16px;
}

/* ===== АВАТАР-ЗАГРУЗЧИК ===== */
.avatar-upload {
    position: relative;
    display: inline-block;
}

.avatar-upload-img {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--border-accent);
}

.avatar-upload-btn {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 28px;
    height: 28px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 13px;
    color: white;
    transition: background var(--transition);
}

.avatar-upload-btn:hover {
    background: var(--accent-hover);
}

/* ===== БЕЙДЖИ ===== */
.badge-role-superadmin {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.15) 0%, rgba(236, 72, 153, 0.15) 100%);
    color: #ec4899;
    border: 1px solid rgba(236, 72, 153, 0.2);
}

.badge-role-admin {
    background: var(--accent-soft);
    color: var(--accent);
}

.badge-role-manager {
    background: rgba(234, 179, 8, 0.15);
    color: #eab308;
}

.badge-role-employee {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

/* ===== PAGE HEADER ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h1 {
    font-size: 20px;
    font-weight: 700;
    margin: 0;
}

/* ===== АДАПТИВНОСТЬ ===== */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 0 0 0 100vw rgba(0, 0, 0, 0.5);
    }

    .main-content {
        margin-left: 0;
    }

    .page-content {
        padding: 16px;
        padding-bottom: calc(var(--bottom-nav-h) + 16px);
    }
}

@media (max-width: 575.98px) {
    .page-content {
        padding: 12px;
        padding-bottom: calc(var(--bottom-nav-h) + 12px);
    }

    .stat-value {
        font-size: 20px;
    }

    .login-card {
        padding: 28px 20px;
    }
}

.border-dashed {
    border-bottom: 1px dashed var(--text-muted);
}

/* Animations */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.spinning {
    display: inline-block !important;
    animation: spin 1s linear infinite !important;
}

.bi-arrow-clockwise {
    display: inline-block;
}

/* ===== NAV TABS UNIFIED STYLE ===== */
.nav-tabs {
    border-bottom: 1px solid var(--border) !important;
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    gap: 4px !important;
    padding-bottom: 0 !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    /* Firefox */
}

.nav-tabs::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari, Edge */
}

.nav-tabs .nav-item {
    margin-bottom: -1px !important;
    white-space: nowrap !important;
}

.nav-tabs .nav-link {
    border: none !important;
    color: var(--text-secondary) !important;
    padding: 14px 24px !important;
    font-weight: 500 !important;
    font-size: 15px !important;
    border-radius: 0 !important;
    transition: all var(--transition) !important;
    position: relative !important;
    background: transparent !important;
    display: flex !important;
    align-items: center !important;
}

.nav-tabs .nav-link i {
    margin-right: 10px !important;
    font-size: 18px !important;
}

.nav-tabs .nav-link:hover {
    color: var(--text-primary) !important;
    background: var(--accent-soft) !important;
    border-radius: var(--radius-sm) !important;
}

.nav-tabs .nav-link.active {
    color: var(--accent) !important;
    background: transparent !important;
    font-weight: 600 !important;
}

.nav-tabs .nav-link.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent);
    box-shadow: 0 -2px 10px var(--accent);
}

@media (max-width: 767.98px) {
    .nav-tabs .nav-link {
        padding: 12px 18px !important;
        font-size: 14px !important;
    }

    .nav-tabs .nav-link i {
        margin-right: 8px !important;
        font-size: 17px !important;
    }
}