/**
 * Modern Dashboard Theme
 * Dynamic theme with animations and modern UI elements
 */

:root {
    --theme-primary: #4e73df;
    --theme-secondary: #7c6d3e;
    --theme-accent: #1cc88a;
    --theme-dark: #1d1701;
    --theme-primary-light: #6c8ce8;
    --theme-primary-dark: #3d5bc7;
    --theme-gradient: linear-gradient(135deg, #4e73df 0%, #1cc88a 100%);
    --animation-speed: 0.3s;
    --animation-ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Smooth Animations */
* {
    transition: background-color var(--animation-speed) var(--animation-ease),
                color var(--animation-speed) var(--animation-ease),
                border-color var(--animation-speed) var(--animation-ease),
                transform var(--animation-speed) var(--animation-ease),
                box-shadow var(--animation-speed) var(--animation-ease);
}

/* Body and Layout */
body {
    background: linear-gradient(135deg, #f5f7fa 0%, #e9ecef 100%);
    position: relative;
}

body.theme-loaded {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Sidebar Modernization */
.sidebar {
    background: linear-gradient(180deg, var(--theme-dark) 0%, #2d2515 100%) !important;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--theme-gradient);
    z-index: 10;
}

.sidebar-brand {
    position: relative;
    padding: 1.5rem 0;
    animation: slideDown 0.6s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.sidebar-brand img {
    transition: transform 0.3s ease;
    filter: drop-shadow(0 2px 8px rgba(255, 255, 255, 0.1));
}

.sidebar-brand:hover img {
    transform: scale(1.05);
}

/* Navigation Items */
.sidebar .nav-item {
    position: relative;
    margin: 0.25rem 0;
    border-radius: 0.5rem;
    overflow: hidden;
}

.sidebar .nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--theme-primary);
    transform: scaleY(0);
    transition: transform 0.3s var(--animation-ease);
}

.sidebar .nav-item.active::before,
.sidebar .nav-item:hover::before {
    transform: scaleY(1);
}

.sidebar .nav-item .nav-link {
    position: relative;
    padding: 1rem 1.25rem;
    border-radius: 0.75rem;
    margin: 0.35rem 0.75rem;
    transition: all 0.3s var(--animation-ease);
    color: rgba(255, 255, 255, 0.9) !important;
    display: flex;
    align-items: center;
    font-size: 15px;
}

.sidebar .nav-item .nav-link:hover {
    background: rgba(255, 255, 255, 0.15) !important;
    color: #fff !important;
    transform: translateX(8px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    padding-left: 1.5rem;
}

.sidebar .nav-item.active .nav-link {
    background: linear-gradient(135deg, var(--theme-primary) 0%, var(--theme-accent) 100%) !important;
    color: #fff !important;
    font-weight: 600;
    box-shadow: 0 6px 25px rgba(78, 115, 223, 0.5);
    transform: translateX(5px);
}

.sidebar .nav-item.active {
    background-color: transparent !important;
}

.sidebar .nav-item .nav-link i {
    margin-right: 1rem;
    width: 28px;
    min-width: 28px;
    height: 28px;
    text-align: center;
    transition: all 0.3s var(--animation-ease);
    font-size: 22px !important;
    color: #ffffff !important;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border-radius: 0.65rem;
    background: rgba(255, 255, 255, 0.15) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    font-weight: 600;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.sidebar .nav-item .nav-link:hover i {
    transform: scale(1.2) translateX(3px);
    background: rgba(255, 255, 255, 0.25) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    color: #ffffff !important;
}

.sidebar .nav-item.active .nav-link i {
    background: rgba(255, 255, 255, 0.3) !important;
    transform: scale(1.15);
    box-shadow: 0 4px 15px rgba(255, 255, 255, 0.4), 0 2px 8px rgba(0, 0, 0, 0.4);
    color: #ffffff !important;
    animation: iconPulse 2s ease-in-out infinite;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

@keyframes iconPulse {
    0%, 100% {
        box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
    }
    50% {
        box-shadow: 0 3px 15px rgba(255, 255, 255, 0.4);
    }
}

/* Collapse Items */
.sidebar .collapse-inner {
    background: rgba(255, 255, 255, 0.95) !important;
    border-radius: 0.75rem;
    padding: 0.5rem;
    margin: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    animation: slideDown 0.3s ease-out;
}

.sidebar .collapse-item {
    padding: 0.6rem 1rem;
    border-radius: 0.5rem;
    margin: 0.25rem 0;
    transition: all 0.3s var(--animation-ease);
    color: #5a5c69;
    font-weight: 500;
    position: relative;
    overflow: hidden;
}

.sidebar .collapse-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--theme-primary);
    transform: scaleY(0);
    transition: transform 0.3s var(--animation-ease);
}

.sidebar .collapse-item:hover::before,
.sidebar .collapse-item.active::before {
    transform: scaleY(1);
}

.sidebar .collapse-item:hover {
    background: linear-gradient(90deg, rgba(78, 115, 223, 0.1) 0%, transparent 100%);
    color: var(--theme-primary);
    transform: translateX(5px);
    padding-left: 1.5rem;
}

.sidebar .collapse-item.active {
    background: linear-gradient(90deg, var(--theme-primary) 0%, var(--theme-accent) 100%);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(78, 115, 223, 0.3);
}

/* Topbar */
.topbar {
    background: #fff !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    border-bottom: 3px solid transparent;
    border-image: var(--theme-gradient) 1;
    animation: slideDown 0.4s ease-out;
}

.topbar .navbar-nav .nav-link {
    transition: all 0.3s ease;
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
    margin: 0 0.25rem;
}

.topbar .navbar-nav .nav-link:hover {
    background: rgba(78, 115, 223, 0.1);
    transform: translateY(-2px);
}

.topbar .img-profile {
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.topbar .img-profile:hover {
    border-color: var(--theme-primary);
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(78, 115, 223, 0.3);
}

/* Cards */
.card {
    border: none;
    border-radius: 1rem;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.08);
    transition: all 0.3s var(--animation-ease);
    overflow: hidden;
    background: #fff;
    animation: fadeInUp 0.5s ease-out;
    animation-fill-mode: both;
}

.card:nth-child(1) { animation-delay: 0.1s; }
.card:nth-child(2) { animation-delay: 0.2s; }
.card:nth-child(3) { animation-delay: 0.3s; }
.card:nth-child(4) { animation-delay: 0.4s; }

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
}

.card-header {
    background: linear-gradient(135deg, #f8f9fc 0%, #fff 100%);
    border-bottom: 2px solid #e9ecef;
    padding: 1.25rem 1.5rem;
    font-weight: 600;
    color: #5a5c69;
}

.card-body {
    padding: 1.5rem;
}

/* Buttons */
.btn {
    border-radius: 0.5rem;
    font-weight: 600;
    padding: 0.6rem 1.5rem;
    transition: all 0.3s var(--animation-ease);
    position: relative;
    overflow: hidden;
    border: none;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: var(--theme-gradient);
    color: #fff;
    box-shadow: 0 4px 15px rgba(78, 115, 223, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(78, 115, 223, 0.5);
}

.btn-success {
    background: linear-gradient(135deg, #1cc88a 0%, #17a673 100%);
    box-shadow: 0 4px 15px rgba(28, 200, 138, 0.4);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(28, 200, 138, 0.5);
}

.btn-warning {
    background: linear-gradient(135deg, #f6c23e 0%, #dda20a 100%);
    color: #fff;
}

.btn-danger {
    background: linear-gradient(135deg, #e74a3b 0%, #c0392b 100%);
}

/* Tables */
.table {
    background: #fff;
    border-radius: 0.75rem;
    overflow: hidden;
}

.table thead {
    background: linear-gradient(135deg, #f8f9fc 0%, #e9ecef 100%);
}

.table thead th {
    border: none;
    padding: 1rem;
    font-weight: 600;
    color: #5a5c69;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

.table tbody tr {
    transition: all 0.3s ease;
}

.table tbody tr:hover {
    background: rgba(78, 115, 223, 0.05);
    transform: scale(1.01);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.table tbody td {
    padding: 1rem;
    border-top: 1px solid #e9ecef;
    vertical-align: middle;
}

/* Forms */
.form-control {
    border-radius: 0.5rem;
    border: 2px solid #e9ecef;
    padding: 0.75rem 1rem;
    transition: all 0.3s ease;
}

.form-control:focus {
    border-color: var(--theme-primary);
    box-shadow: 0 0 0 0.2rem rgba(78, 115, 223, 0.15);
    transform: translateY(-2px);
}

/* Badges */
.badge {
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    font-weight: 600;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
}

.badge-info {
    background: linear-gradient(135deg, #36b9cc 0%, #2a96a5 100%);
}

/* Scroll to Top */
.scroll-to-top {
    position: absolute !important;
    background: var(--theme-gradient);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(78, 115, 223, 0.4);
    transition: all 0.3s ease;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.scroll-to-top:hover {
    transform: translateY(-5px) scale(1.1);
    box-shadow: 0 6px 20px rgba(78, 115, 223, 0.5);
}

/* Sidebar Toggler */
#sidebarToggle {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
    transition: all 0.3s ease;
    width: 40px;
    height: 40px;
}

#sidebarToggle:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    transform: rotate(180deg);
}

/* Dropdown */
.dropdown-menu {
    border: none;
    border-radius: 0.75rem;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    padding: 0.5rem;
    animation: slideDown 0.3s ease-out;
}

.dropdown-item {
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    transition: all 0.3s ease;
    margin: 0.25rem 0;
}

.dropdown-item:hover {
    background: linear-gradient(90deg, rgba(78, 115, 223, 0.1) 0%, transparent 100%);
    transform: translateX(5px);
    color: var(--theme-primary);
}

/* Loading States */
.loading {
    position: relative;
    overflow: hidden;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .card {
        margin-bottom: 1rem;
    }
}

/* Additional Icon Visibility Enhancements */
.sidebar .nav-item .nav-link i.fa-home,
.sidebar .nav-item .nav-link i.fa-caret-square-right,
.sidebar .nav-item .nav-link i.fas,
.sidebar .nav-item .nav-link i.far {
    opacity: 1 !important;
    font-weight: 500;
}

/* Make icons stand out more on dark background */
.sidebar-dark .nav-item:not(.active) .nav-link i {
    background: rgba(255, 255, 255, 0.15) !important;
    padding: 0.5rem;
    border-radius: 0.65rem;
    backdrop-filter: blur(5px);
    color: #ffffff !important;
    font-size: 22px !important;
}

.sidebar-dark .nav-item:not(.active) .nav-link:hover i {
    background: rgba(255, 255, 255, 0.25) !important;
}

/* Override for consistency - ensure icons are always visible */
.sidebar .nav-item .nav-link i {
    opacity: 1 !important;
    visibility: visible !important;
}

/* RTL Support */
[dir="rtl"] .sidebar .nav-item .nav-link:hover {
    transform: translateX(-8px);
}

[dir="rtl"] .sidebar .nav-item.active .nav-link {
    transform: translateX(-5px);
}

[dir="rtl"] .sidebar .collapse-item:hover {
    transform: translateX(-5px);
    padding-right: 1.5rem;
    padding-left: 1rem;
}

[dir="rtl"] .dropdown-item:hover {
    transform: translateX(-5px);
}

