:root {
    --sidebar-width-expanded: 280px;
    --sidebar-width-collapsed: 80px;
    --sidebar-bg: linear-gradient(145deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
    --sidebar-border: rgba(148, 163, 184, 0.1);
    --sidebar-text-color: #cbd5e1;
    --sidebar-text-hover: #f1f5f9;
    --sidebar-hover-bg: rgba(59, 130, 246, 0.1);
    --sidebar-active-bg: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    --sidebar-active-text: #ffffff;
    --sidebar-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
    --top-navbar-height: 70px;
    --glass-bg: rgba(255, 255, 255, 0.9);
    --glass-border: rgba(255, 255, 255, 0.2);
    --accent-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --success-gradient: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    --danger-gradient: linear-gradient(135deg, #fc466b 0%, #3f5efb 100%);
    --warning-gradient: linear-gradient(135deg, #fdbb2d 0%, #22c1c3 100%);
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --card-shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #f8fafc;
    font-size: 0.9rem;
    font-weight: 400;
    line-height: 1.6;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 20% 80%, rgba(148, 163, 184, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(203, 213, 225, 0.08) 0%, transparent 50%),
        #f8fafc;
    z-index: -1;
}

.top-navbar {
    height: var(--top-navbar-height);
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: none;
    border-bottom: 1px solid var(--glass-border);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    z-index: 1030;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.top-navbar .navbar-brand {
    color: #1e293b !important;
    font-weight: 700;
    font-size: 1.5rem;
    text-decoration: none;
    transition: all 0.3s ease;
}

.top-navbar .navbar-brand:hover {
    transform: scale(1.05);
}

.sidebar-toggler-desktop {
    color: #64748b;
    border: none;
    background: transparent;
    font-size: 1.4rem;
    padding: 12px;
    border-radius: 6px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.sidebar-toggler-desktop::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--accent-gradient);
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: 6px;
}

.sidebar-toggler-desktop:hover {
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.4);
}

.sidebar-toggler-desktop:hover::before {
    opacity: 1;
}

.sidebar-toggler-desktop i {
    position: relative;
    z-index: 1;
}

.content-wrapper {
    padding-top: var(--top-navbar-height);
    min-height: 100vh;
    display: flex;
}

.sidebar {
    background: var(--sidebar-bg);
    color: var(--sidebar-text-color);
    overflow-x: hidden;
    overflow-y: auto;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    width: var(--sidebar-width-expanded);
    flex-shrink: 0;
    border-right: 1px solid var(--sidebar-border);
    box-shadow: var(--sidebar-shadow);
    position: relative;
}

/* Disable sidebar transitions on page load to prevent animation flash */
body.no-sidebar-transitions .sidebar {
    transition: none !important;
}

body.no-sidebar-transitions .sidebar-overlay {
    transition: none !important;
}

.sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 10% 20%, rgba(59, 130, 246, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 90% 80%, rgba(139, 92, 246, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

.sidebar.width-collapsed {
    width: var(--sidebar-width-collapsed) !important;
}

.sidebar.width-expanded {
    width: var(--sidebar-width-expanded) !important;
}

.sidebar.width-expanded .nav {
    flex-direction: column !important;
}

.sidebar-sticky {
    padding: 1.5rem 0;
    height: 100%;
    position: relative;
    z-index: 1;
}

.sidebar-sticky::-webkit-scrollbar {
    width: 6px;
}

.sidebar-sticky::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-sticky::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.3);
    border-radius: 3px;
}

.sidebar-sticky::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.5);
}

.nav-link {
    color: var(--sidebar-text-color);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    border-radius: 8px;
    margin: 0.25rem 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    font-weight: 500;
    position: relative;
    overflow: hidden;
    text-decoration: none;
}

.nav-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.6s ease;
}

.nav-link:hover {
    background: var(--sidebar-hover-bg);
    color: var(--sidebar-text-hover);
    transform: translateX(8px);
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.2);
}

.nav-link:hover::before {
    left: 100%;
}

.nav-link.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    font-weight: 600;
    transform: translateX(8px);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.4);
}

.nav-link .bi {
    font-size: 1.25rem;
    margin-right: 1rem;
    min-width: 24px;
    text-align: center;
    flex-shrink: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-link:hover .bi {
    /* transform: scale(1.1); Now handled by JS for more complex animation */
}

.nav-link .nav-text {
    opacity: 1;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: inherit;
}

.sidebar-heading {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #94a3b8;
    padding: 1rem 1.5rem 0.5rem;
    margin-top: 1.5rem;
    white-space: nowrap;
    font-weight: 600;
    position: relative;
}

.sidebar-heading::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 1.5rem;
    right: 1.5rem;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(148, 163, 184, 0.3), transparent);
}

.sidebar-heading .nav-text {
    opacity: 1;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Collapsed sidebar styles */
.sidebar.sidebar-visual-collapsed .nav-text {
    opacity: 0;
    transform: translateX(-10px);
}

.sidebar.sidebar-visual-collapsed .nav-link .bi {
    margin-right: 0;
}

.sidebar.sidebar-visual-collapsed .nav-link {
    justify-content: center;
    padding: 1rem;
    margin: 0.25rem 0.5rem;
}

.sidebar.sidebar-visual-collapsed .sidebar-heading .nav-text {
    opacity: 0;
    pointer-events: none;
}

.sidebar.sidebar-visual-collapsed .sidebar-heading {
    text-align: center;
    padding: 1rem 0.5rem 0.5rem;
}

.sidebar.sidebar-visual-collapsed .sidebar-heading::after {
    left: 0.5rem;
    right: 0.5rem;
}

.main-content {
    padding: 2rem;
    overflow-x: auto;
    flex-grow: 1;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 0;
    margin: 0;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05);
    position: relative;
}

.main-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 0;
    z-index: -1;
}

/* Enhanced alert styles */
.alert {
    border: none;
    border-radius: 8px;
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    font-weight: 500;
}

.alert-primary {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(29, 78, 216, 0.1) 100%);
    color: #1e40af;
    border-left: 4px solid #3b82f6;
}

.alert-success {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(5, 150, 105, 0.1) 100%);
    color: #059669;
    border-left: 4px solid #10b981;
}

.alert-danger {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1) 0%, rgba(220, 38, 38, 0.1) 100%);
    color: #dc2626;
    border-left: 4px solid #ef4444;
}

.alert-warning {
    background: linear-gradient(135deg, rgba(245, 171, 24, 0.1) 0%, rgba(217, 119, 6, 0.1) 100%);
    color: #d97706;
    border-left: 4px solid #f5ab18;
}

/* Enhanced user dropdown */
.navbar-nav .nav-link {
    color: #64748b !important;
    font-weight: 500;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    margin-right: 1rem;
}

.navbar-nav .nav-link:hover {
    background: var(--danger-gradient);
    color: white !important;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(239, 68, 68, 0.3);
}

/* Mobile responsive improvements */
@media (max-width: 768px) {
    .content-wrapper {
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        left: calc(-1 * var(--sidebar-width-expanded));
        top: 0;
        height: 100vh;
        z-index: 1040;
        padding-top: var(--top-navbar-height);
        transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        width: var(--sidebar-width-expanded) !important;
    }

    body.sidebar-mobile-visible .sidebar {
        left: 0;
        box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    }

    .sidebar-toggler-desktop {
        display: none;
    }

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(5px);
        -webkit-backdrop-filter: blur(5px);
        z-index: 1035;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }

    body.sidebar-mobile-visible .sidebar-overlay {
        opacity: 1;
        visibility: visible;
    }

    .main-content {
        width: 100%;
        margin: 0;
        border-radius: 0;
        padding: 1.5rem;
    }

    .main-content::before {
        border-radius: 0;
    }

    .navbar-toggler {
        border: none;
        padding: 0.5rem;
        background: rgba(255, 255, 255, 0.1);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        border-radius: 6px;
        transition: all 0.3s ease;
    }

    .navbar-toggler:hover {
        background: var(--accent-gradient);
        transform: scale(1.05);
    }

    .navbar-toggler-icon {
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%2833, 37, 41, 0.75%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
    }
}

/* Smooth loading animation */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.main-content > * {
    animation: fadeInUp 0.6s ease-out;
}

/* Enhanced focus states */
.nav-link:focus,
.sidebar-toggler-desktop:focus,
.navbar-toggler:focus {
    outline: 2px solid rgba(59, 130, 246, 0.5);
    outline-offset: 2px;
}

/* Pulse animation for active elements */
@keyframes pulse {
    0%, 100% {
        box-shadow: 0 8px 25px rgba(59, 130, 246, 0.4);
    }
    50% {
        box-shadow: 0 8px 25px rgba(59, 130, 246, 0.6);
    }
}

.nav-link.active {
    animation: pulse 2s infinite;
}

/* Scrollbar styling for main content */
.main-content::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.main-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
}

.main-content::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #94a3b8, #64748b);
    border-radius: 4px;
}

.main-content::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #64748b, #475569);
}

/* Spinner animation for nav links */
@keyframes spin {
    0% { transform: translateY(-50%) rotate(0deg); }
    100% { transform: translateY(-50%) rotate(360deg); }
}

/* Language switcher styles */
.language-switcher {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #64748b !important;
    text-decoration: none;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.2s ease;
    background: transparent;
    border: none;
    width: 32px;
    height: 32px;
}

.language-switcher:hover {
    color: #3b82f6 !important;
    background: rgba(59, 130, 246, 0.1);
    text-decoration: none;
}

.language-switcher .flag-icon {
    transition: transform 0.2s ease;
}

.language-switcher:hover .flag-icon {
    transform: scale(1.05);
}

/* Flag icons */
.flag-icon {
    display: inline-block;
    width: 18px;
    height: 12px;
    border-radius: 2px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    vertical-align: middle;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
}

.flag-icon-us {
    background: linear-gradient(to bottom, 
        #b22234 0%, #b22234 7.7%, #fff 7.7%, #fff 15.4%,
        #b22234 15.4%, #b22234 23.1%, #fff 23.1%, #fff 30.8%,
        #b22234 30.8%, #b22234 38.5%, #fff 38.5%, #fff 46.2%,
        #b22234 46.2%, #b22234 53.9%, #fff 53.9%, #fff 61.6%,
        #b22234 61.6%, #b22234 69.3%, #fff 69.3%, #fff 77%,
        #b22234 77%, #b22234 84.7%, #fff 84.7%, #fff 92.4%,
        #b22234 92.4%, #b22234 100%);
    position: relative;
}

.flag-icon-us::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 40%;
    height: 54%;
    background: #3c3b6e;
}

.flag-icon-pl {
    background: linear-gradient(to bottom, #fff 0%, #fff 50%, #dc143c 50%, #dc143c 100%);
}

/* Language dropdown customization */
.navbar-nav .dropdown-menu {
    position: absolute !important;
    top: 100% !important;
    right: 0 !important;
    left: auto !important;
    z-index: 1050 !important;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    background: white;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 0.25rem 0;
    margin-top: 0.25rem !important;
    min-width: 140px;
    transform: none !important;
}

.navbar-nav .dropdown-item {
    padding: 0.5rem 1rem;
    color: #64748b;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    font-size: 0.875rem;
    white-space: nowrap;
}

.navbar-nav .dropdown-item:hover {
    background: #f8fafc;
    color: #3b82f6;
}

.navbar-nav .dropdown-item.active {
    background: #eff6ff;
    color: #1e40af;
    font-weight: 600;
}

.navbar-nav .dropdown-item .flag-icon {
    margin-right: 0.5rem;
}

/* Ensure dropdown container has proper positioning */
.navbar-nav .dropdown {
    position: relative;
}

/* APK Download Button - Distinctive Styling */
.apk-download-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 2px solid rgba(163, 230, 53, 0.2);
}

.apk-download-link {
    background: linear-gradient(135deg, #a4c639 0%, #78a922 100%) !important;
    color: #ffffff !important;
    font-weight: 600 !important;
    box-shadow: 0 8px 25px rgba(164, 198, 57, 0.3) !important;
    position: relative;
    overflow: hidden;
}

.apk-download-link::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 1rem;
    width: 6px;
    height: 6px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    animation: pulse-apk 2s infinite;
}

.apk-download-link:hover {
    background: linear-gradient(135deg, #78a922 0%, #5a8319 100%) !important;
    color: #ffffff !important;
    transform: translateX(8px) scale(1.02);
    box-shadow: 0 12px 35px rgba(164, 198, 57, 0.5) !important;
}

.apk-download-link .bi-android2 {
    font-size: 1.5rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

/* Collapsed sidebar APK button */
.sidebar.sidebar-visual-collapsed .apk-download-section {
    border-top-color: rgba(163, 230, 53, 0.3);
}

.sidebar.sidebar-visual-collapsed .apk-download-link {
    justify-content: center;
}

/* Pulse animation for APK download indicator */
@keyframes pulse-apk {
    0%, 100% {
        opacity: 0.6;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.3);
    }
}

/* Mobile adjustments for APK button */
@media (max-width: 768px) {
    .apk-download-section {
        margin-top: 1rem;
        padding-top: 1rem;
    }
}

/* Deleted Records Toggle Button */
.deleted-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.8rem;
    font-weight: 500;
    color: #64748b;
}

.deleted-toggle:hover {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(148, 163, 184, 0.4);
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.deleted-toggle-track {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.deleted-toggle-thumb {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: #64748b;
    transition: all 0.3s ease;
}

.deleted-toggle-thumb .bi {
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.deleted-toggle-label {
    color: #64748b;
    transition: all 0.3s ease;
    white-space: nowrap;
}

/* Active state - when showing deleted records */
.deleted-toggle.active {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(217, 119, 6, 0.1) 100%);
    border-color: rgba(245, 158, 11, 0.4);
}

.deleted-toggle.active .deleted-toggle-track {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.4);
}

.deleted-toggle.active .deleted-toggle-thumb {
    color: #ffffff;
}

.deleted-toggle.active .deleted-toggle-label {
    color: #d97706;
    font-weight: 600;
}

.deleted-toggle.active:hover {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.25) 0%, rgba(217, 119, 6, 0.2) 100%);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.3);
}

/* Focus state */
.deleted-toggle:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

/* Mobile adjustments */
@media (max-width: 991px) {
    .deleted-toggle {
        padding: 0.35rem 0.5rem;
    }

    .deleted-toggle-track {
        width: 26px;
        height: 26px;
    }
}
