/* Custom Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.nav-item.active {
    background-color: rgb(249, 115, 22);
    color: white;
}

.nav-item.active i {
    color: white;
}

/* Smooth transitions */
.transition {
    transition: all 0.3s ease;
}

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

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Loading animation */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* Sidebar scrollable */
#sidebar {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#sidebar > div:first-child {
    flex-shrink: 0;
}

#sidebar nav,
#sidebarNav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Custom scrollbar for sidebar */
#sidebar nav::-webkit-scrollbar,
#sidebarNav::-webkit-scrollbar {
    width: 6px;
}

#sidebar nav::-webkit-scrollbar-track,
#sidebarNav::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

#sidebar nav::-webkit-scrollbar-thumb,
#sidebarNav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

#sidebar nav::-webkit-scrollbar-thumb:hover,
#sidebarNav::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Sidebar overlay backdrop for mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 40;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* Mobile responsive - Tablet and below */
@media (max-width: 1024px) {
    /* Sidebar - hidden by default on mobile, overlay when shown */
    #sidebar {
        transform: translateX(-100%) !important;
        transition: transform 0.3s ease-in-out;
        z-index: 50;
    }
    
    #sidebar.show,
    #sidebar:not(.-translate-x-full) {
        transform: translateX(0) !important;
    }
    
    /* Ensure sidebar has translate class on mobile */
    #sidebar.-translate-x-full {
        transform: translateX(-100%) !important;
    }
    
    /* Remove left margin on mobile */
    .ml-64 {
        margin-left: 0 !important;
    }
    
    /* Header adjustments - Mobile 3-column layout */
    header {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    header > div {
        display: grid;
        grid-template-columns: auto 1fr auto;
        align-items: center;
        gap: 0.75rem;
        width: 100%;
        position: relative;
    }
    
    /* Left: Hamburger only */
    header > div > div:first-child {
        display: flex;
        justify-content: flex-start;
        align-items: center;
        position: relative;
        z-index: 1;
        min-width: 0;
    }
    
    /* Title centered - positioned in middle column of grid */
    header > div > div:first-child h2 {
        position: absolute;
        left: 0;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
        margin: 0;
        font-size: 1.125rem;
        font-weight: 700;
        color: #1f2937;
        white-space: nowrap;
        pointer-events: none;
        z-index: 0;
        text-align: center;
        overflow: hidden;
        text-overflow: ellipsis;
        padding: 0 4rem;
    }
    
    /* Ensure hamburger button stays on left and is visible */
    header > div > div:first-child button {
        position: relative;
        z-index: 2;
        flex-shrink: 0;
        display: flex !important;
    }
    
    /* Make sure hamburger is visible on mobile even if it has lg:hidden class */
    header button#sidebarToggle {
        display: flex !important;
    }
    
    /* Hide search and user icons on mobile */
    header > div > div:last-child {
        display: none !important;
    }
    
    /* Adjust grid to 2 columns when right column is hidden */
    header > div {
        grid-template-columns: auto 1fr;
    }
    
    /* Adjust title padding since right column is hidden */
    header > div > div:first-child h2 {
        padding: 0 3rem;
    }
    
    /* Main content padding */
    main {
        padding: 1rem !important;
    }
    
    /* Tables - make scrollable */
    .overflow-x-auto {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Cards and containers */
    .bg-white.rounded-xl,
    .bg-white.rounded-lg {
        margin-left: 0;
        margin-right: 0;
    }
    
    /* Form inputs full width on mobile */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="url"],
    select,
    textarea {
        width: 100%;
    }
    
    /* Modal adjustments */
    .fixed.inset-0 .bg-white.rounded-xl {
        margin: 1rem;
        max-width: calc(100% - 2rem);
        max-height: calc(100vh - 2rem);
        overflow-y: auto;
    }
    
    /* Button groups stack on mobile - but preserve horizontal for action buttons */
    .flex.space-x-3:not(.actions),
    .flex.space-x-4:not(.actions) {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .flex.space-x-3:not(.actions) > *,
    .flex.space-x-4:not(.actions) > * {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    /* Keep action buttons horizontal but smaller */
    .flex.space-x-2.actions,
    .flex.space-x-3.actions {
        flex-direction: row;
        gap: 0.5rem;
    }
    
    /* Stats cards stack on mobile */
    .grid.grid-cols-1.md\:grid-cols-2.lg\:grid-cols-4 {
        grid-template-columns: 1fr;
    }
}

/* Mobile responsive - Small screens */
@media (max-width: 768px) {
    /* Smaller text sizes */
    h2 {
        font-size: 1.25rem;
    }
    
    h3 {
        font-size: 1.125rem;
    }
    
    /* Compact table cells */
    table td,
    table th {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
    
    /* Stack filter/search controls */
    .flex.items-center.justify-between {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    .flex.items-center.space-x-4 {
        flex-direction: column;
        width: 100%;
        gap: 0.75rem;
    }
    
    /* Full width buttons on mobile */
    button {
        width: 100%;
    }
    
    /* Pagination adjustments */
    .hidden.sm\:flex {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* Mobile responsive - Extra small screens */
@media (max-width: 640px) {
    /* Hide search on very small screens */
    header .relative input[type="text"] {
        display: none;
    }
    
    /* Compact header info on mobile */
    header .text-right {
        display: none;
    }
    
    /* Sidebar full width on very small screens */
    #sidebar {
        width: 100%;
        max-width: 280px;
    }
    
    /* Even more compact spacing */
    .p-6 {
        padding: 1rem;
    }
    
    .px-6 {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .py-4 {
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
    }
    
    /* Hide less important columns in tables */
    table th:nth-child(n+4),
    table td:nth-child(n+4) {
        display: none;
    }
    
    /* Show important columns */
    table th:first-child,
    table td:first-child,
    table th:last-child,
    table td:last-child {
        display: table-cell;
    }
}

/* Fade in animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* Revenue card amount wrapping */
#statRevenue {
    word-break: break-word;
    overflow-wrap: anywhere;
    hyphens: auto;
    max-width: 100%;
    line-height: 1.2;
}

/* Responsive font size for large amounts on smaller screens */
@media (max-width: 768px) {
    #statRevenue {
        font-size: 1.5rem;
    }
}

/* Ensure revenue card layout doesn't break */
.bg-white.rounded-xl .flex.items-center.justify-between {
    flex-wrap: nowrap;
    align-items: flex-start;
}

.bg-white.rounded-xl .flex.items-center.justify-between > div:first-child {
    min-width: 0;
    flex: 1 1 auto;
}

.bg-white.rounded-xl .flex.items-center.justify-between > div:last-child {
    flex-shrink: 0;
    min-width: fit-content;
}

