/* Admin Dashboard Custom Styles */

/* =====================================================
   SIDEBAR STYLES - Collapsible & Responsive
   ===================================================== */

/* Sidebar base - expanded state (default) */
#sidebar {
    width: 16rem; /* 256px = w-64 */
}

/* Sidebar collapsed state - desktop only */
@media (min-width: 1024px) {
    #sidebar.sidebar-collapsed {
        width: 4.5rem; /* 72px - enough for icons + padding */
    }

    /* Hide text elements when collapsed */
    #sidebar.sidebar-collapsed .sidebar-text {
        display: none !important;
    }

    /* Center icons when collapsed */
    #sidebar.sidebar-collapsed .sidebar-link {
        justify-content: center;
        padding-left: 0;
        padding-right: 0;
    }

    #sidebar.sidebar-collapsed .sidebar-icon {
        margin: 0;
    }

    /* Hide active dot in collapsed mode (icon highlight suffices) */
    #sidebar.sidebar-collapsed .sidebar-active-dot {
        display: none;
    }

    /* Adjust header padding when collapsed */
    #sidebar.sidebar-collapsed .sidebar-header {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
        justify-content: center;
    }

    /* Hide brand text, center logo */
    #sidebar.sidebar-collapsed .sidebar-brand {
        justify-content: center;
    }

    /* Hide collapse arrow icon and button */
    #sidebar.sidebar-collapsed #sidebar-collapse-btn {
        display: none !important;
    }

    /* Hide submenu content when collapsed */
    #sidebar.sidebar-collapsed .sidebar-submenu {
        display: none !important;
    }

    /* Hide submenu arrow when collapsed */
    #sidebar.sidebar-collapsed .sidebar-submenu-arrow {
        display: none !important;
    }

    /* Footer adjustments when collapsed */
    #sidebar.sidebar-collapsed .sidebar-footer {
        padding: 0.75rem;
    }

    #sidebar.sidebar-collapsed .sidebar-footer > div {
        justify-content: center;
    }

    /* Main content margin adjustment when sidebar is collapsed */
    .main-content.sidebar-collapsed {
        margin-left: 4.5rem;
    }
}

/* Tooltip for collapsed sidebar (icons only) */
@media (min-width: 1024px) {
    #sidebar.sidebar-collapsed .sidebar-link {
        position: relative;
    }

    #sidebar.sidebar-collapsed .sidebar-link::after {
        content: attr(title);
        position: absolute;
        left: 100%;
        top: 50%;
        transform: translateY(-50%);
        margin-left: 0.75rem;
        padding: 0.5rem 0.75rem;
        background: #1e293b;
        color: white;
        font-size: 0.875rem;
        white-space: nowrap;
        border-radius: 0.375rem;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.15s, visibility 0.15s;
        z-index: 100;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    }

    #sidebar.sidebar-collapsed .sidebar-link:hover::after {
        opacity: 1;
        visibility: visible;
    }
}

/* Submenu expand animation */
.sidebar-submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.2s ease-out, opacity 0.2s ease-out;
    opacity: 0;
}

.sidebar-submenu.expanded {
    max-height: 500px;
    opacity: 1;
}

/* Submenu arrow rotation */
.sidebar-submenu-toggle[aria-expanded="true"] .sidebar-submenu-arrow {
    transform: rotate(180deg);
}

/* Active indicator for collapsed sidebar with active submenu */
#sidebar.sidebar-collapsed .sidebar-submenu-container[data-has-active="true"] .sidebar-submenu-toggle::before {
    content: '';
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 0.375rem;
    height: 0.375rem;
    background: rgb(var(--color-primary-400));
    border-radius: 50%;
}

/* =====================================================
   END SIDEBAR STYLES
   ===================================================== */

/* Smooth transitions */
* {
    transition-property: background-color, border-color, color, fill, stroke;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

.dark ::-webkit-scrollbar-thumb {
    background: #475569;
}

.dark ::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* Flash message animations */
.flash-message {
    animation: slideInRight 0.3s ease-out;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Fade in animation */
.fade-in {
    animation: fadeIn 0.3s ease-out;
}

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

/* Loading shimmer */
.shimmer {
    background: linear-gradient(90deg, #f1f5f9 0%, #e2e8f0 50%, #f1f5f9 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.dark .shimmer {
    background: linear-gradient(90deg, #334155 0%, #475569 50%, #334155 100%);
    background-size: 200% 100%;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Pulse animation for notifications */
.pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

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

/* Card hover effect */
.card-hover {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

/* Staggered card fade-in */
.card-stagger {
    opacity: 0;
    transform: translateY(12px);
    animation: cardFadeIn 0.4s ease-out forwards;
}

.card-stagger:nth-child(1) { animation-delay: 0s; }
.card-stagger:nth-child(2) { animation-delay: 0.08s; }
.card-stagger:nth-child(3) { animation-delay: 0.16s; }
.card-stagger:nth-child(4) { animation-delay: 0.24s; }
.card-stagger:nth-child(5) { animation-delay: 0.32s; }
.card-stagger:nth-child(6) { animation-delay: 0.40s; }

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

/* Button press effect */
button:active {
    transform: scale(0.98);
}

/* Input focus styles */
input:focus, select:focus, textarea:focus {
    outline: none;
}

/* Table row hover */
tbody tr {
    transition: background-color 0.15s ease;
}

/* Modal backdrop blur */
.modal-backdrop {
    backdrop-filter: blur(4px);
}

/* Sidebar transition */
#sidebar {
    transition: transform 0.3s ease-in-out, width 0.3s ease-in-out;
}

/* Sidebar text transition for collapse animation */
.sidebar-text {
    transition: opacity 0.2s ease, width 0.2s ease, margin 0.2s ease;
}

/* Dropdown animation */
.dropdown-menu {
    animation: dropdownFadeIn 0.15s ease-out;
}

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

/* Chart container */
.chart-container {
    position: relative;
    height: 200px;
}

/* Status badge animations */
.badge-pulse {
    position: relative;
}

.badge-pulse::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 9999px;
    animation: badge-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes badge-pulse {
    0%, 100% {
        opacity: 0;
        transform: scale(1);
    }
    50% {
        opacity: 0.3;
        transform: scale(1.5);
    }
}

/* Responsive table wrapper */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Form validation states */
.input-error {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) !important;
}

.input-success {
    border-color: #22c55e !important;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1) !important;
}

/* Print styles */
@media print {
    .no-print {
        display: none !important;
    }

    #sidebar {
        display: none !important;
    }

    main {
        margin-left: 0 !important;
    }
}

/* Mobile optimizations */
@media (max-width: 640px) {
    .mobile-full {
        width: 100% !important;
    }

    .mobile-stack {
        flex-direction: column !important;
    }

    .mobile-hide {
        display: none !important;
    }
}
