/* APDes Platform Custom Styles - Modern Design */

/* Base responsive scaling */
html {
    font-size: 14px;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

@media (min-width: 768px) {
    html {
        font-size: 15px;
    }
}

@media (min-width: 1024px) {
    html {
        font-size: 16px;
    }
}

@media (min-width: 1440px) {
    html {
        font-size: 17px;
    }
}

@media (min-width: 1920px) {
    html {
        font-size: 18px;
    }
}

/* Modern body background */
body {
    background-color: #f9fafb;
    color: #111827;
}

/* App Layout Container with Hover-controlled Grid */
.app-layout {
    display: grid;
    grid-template-columns: 80px 1fr;
    grid-template-areas: "sidebar main";
    min-height: 100vh;
    transition: grid-template-columns 0.3s ease;
    width: 100%;
    max-width: 100vw;
    gap: 0;
    overflow-x: hidden;
}

/* Expanded state for app layout */
.app-layout.expanded {
    grid-template-columns: 240px 1fr;
}

/* Large Desktop Layout Adjustments */
@media (min-width: 1440px) {
    .app-layout {
        grid-template-columns: 100px 1fr;
    }
    
    .app-layout.expanded {
        grid-template-columns: 280px 1fr;
    }
}

/* Ultra Wide Desktop Layout Adjustments */
@media (min-width: 1920px) {
    .app-layout {
        grid-template-columns: 120px 1fr;
    }
    
    .app-layout.expanded {
        grid-template-columns: 320px 1fr;
    }
}

/* Ensure main content area adjusts to sidebar changes */
.app-layout .main-content {
    grid-area: main;
    width: 100%;
    max-width: 100%;
    transition: all 0.3s ease;
    overflow-x: hidden;
    min-width: 0;
}

/* Modern Clean Sidebar Styles */
.sidebar {
    grid-area: sidebar;
    background-color: #ffffff;
    border-right: 1px solid #f3f4f6;
    height: 100vh;
    padding-top: 5rem;
    overflow-y: auto;
    overflow-x: hidden;
    position: fixed;
    left: 0;
    top: 0;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
    white-space: nowrap;
    transition: all 0.3s ease-in-out;
    z-index: 30;
    width: 80px;
    margin-right: 0;
}

/* Large Desktop Sidebar Adjustments */
@media (min-width: 1440px) {
    .sidebar {
        width: 100px;
        padding-top: 5.5rem;
    }
}

/* Ultra Wide Desktop Sidebar Adjustments */
@media (min-width: 1920px) {
    .sidebar {
        width: 120px;
        padding-top: 6rem;
    }
}

/* Hover expanded sidebar */
.app-layout.expanded .sidebar,
.sidebar:hover {
    width: 240px;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.08);
}

/* Large Desktop Expanded Sidebar */
@media (min-width: 1440px) {
    .app-layout.expanded .sidebar,
    .sidebar:hover {
        width: 280px;
    }
}

/* Ultra Wide Desktop Expanded Sidebar */
@media (min-width: 1920px) {
    .app-layout.expanded .sidebar,
    .sidebar:hover {
        width: 320px;
    }
}

/* Ensure header doesn't overlap content */
nav.fixed {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 40 !important;
    background-color: white !important;
    border-bottom: 1px solid #e5e7eb !important;
}

/* Page header spacing */
.page-header {
    margin-top: 1rem !important;
    padding-top: 0.5rem !important;
}

/* Ensure page titles are not covered */
h1, h2, h3, h4, h5, h6 {
    margin-top: 1rem !important;
    padding-top: 0.5rem !important;
}

/* Additional spacing for main content area */
.main-content .content-wrapper > div {
    padding-top: 1.5rem !important;
}

/* Specific spacing for dashboard content */
.content-wrapper > div:first-child {
    padding-top: 2rem !important;
    margin-left: 0 !important;
}

/* Dashboard page header specific spacing */
.content-wrapper h1:first-of-type {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

/* Dashboard Header Layout Fix */
.dashboard-header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    min-width: 0;
    white-space: normal;
}

@media (min-width: 768px) {
    .dashboard-header {
        flex-direction: row;
        align-items: flex-start;
        justify-content: space-between;
        min-width: 0;
        white-space: normal;
    }
}

/* Title and subtitle section */
.dashboard-title-section {
    min-width: 0;
    flex: 1;
    flex-shrink: 1;
    max-width: calc(100% - 200px);
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
}

/* Button section */
.dashboard-actions {
    flex-shrink: 0;
    min-width: fit-content;
    max-width: 200px;
    white-space: normal;
}

/* Fix text wrapping issues */
.dashboard-header h1 {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.dashboard-header p {
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.4;
    max-width: 100%;
    margin: 0;
}

/* Dashboard Action Buttons */
.dashboard-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    max-width: 200px;
    box-sizing: border-box;
    min-width: 0;
    padding: 0;
    margin: 0;
    flex-shrink: 0;
    white-space: normal;
}

@media (min-width: 768px) {
    .dashboard-actions {
        justify-content: flex-end;
        flex-wrap: nowrap;
        min-width: auto;
        padding-right: 0;
        margin-right: 0;
        gap: 0.75rem;
        max-width: 200px;
    }
}

/* Dashboard Button Styling */
.dashboard-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    text-decoration: none;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: fit-content;
    max-width: 100%;
    box-sizing: border-box;
}

@media (min-width: 768px) {
    .dashboard-btn {
        padding: 0.5rem 1rem;
    }
}

@media (max-width: 767px) {
    .dashboard-actions {
        padding-right: 0;
        gap: 0.5rem;
        justify-content: flex-end;
        max-width: 100%;
    }
    
    .dashboard-actions a {
        flex: 0 0 auto;
        min-width: fit-content;
        max-width: calc(50% - 0.25rem);
    }
}

@media (max-width: 480px) {
    .dashboard-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
        padding-right: 0;
        max-width: 100%;
    }
    
    .dashboard-actions a {
        flex: none;
        max-width: 100%;
        width: 100%;
    }
}

/* Statistics Cards Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    min-width: 0;
    white-space: normal;
}

@media (min-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
}

@media (min-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 1rem;
    }
}

/* Individual stat cards */
.stats-grid > div {
    min-width: 0;
    overflow: hidden;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Ensure all content fits within container */
.content-wrapper * {
    box-sizing: border-box;
}

/* Logo styling */
.logo-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.2s ease;
}

.logo-container img:hover {
    transform: scale(1.05);
}

/* Prevent horizontal overflow */
.content-wrapper {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Sidebar hover expanded state */
.sidebar:hover {
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
}

/* Main Content Area - Auto-expanding */
.main-content {
    width: 100%;
    min-height: 100vh;
    overflow-x: hidden;
    background-color: #f9fafb;
}

/* Main content with sidebar (authenticated pages) */
.main-content.with-sidebar {
    display: grid;
    grid-template-columns: 80px 1fr;
    grid-template-areas: "sidebar main";
    transition: grid-template-columns 0.3s ease-in-out;
    position: relative;
    width: 100%;
    min-height: 100vh;
    gap: 0;
}

.main-content.with-sidebar.expanded {
    grid-template-columns: 240px 1fr;
}

/* Content wrapper responsive behavior */
.main-content.with-sidebar .content-wrapper {
    grid-area: main;
    width: 100%;
    max-width: calc(100vw - 100px);
    transition: all 0.3s ease-in-out;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* Modern Content Wrapper */
.content-wrapper {
    width: 100%;
    max-width: 100%;
    min-height: calc(100vh - 4rem);
    padding: 6rem 20px 2rem 20px;
    overflow-x: hidden;
    position: relative;
    z-index: 1;
    margin-left: 0;
    transition: all 0.3s ease-in-out;
    box-sizing: border-box;
    white-space: normal;
}

/* Content wrapper adjusts automatically with grid layout */
.app-layout.expanded .content-wrapper {
    margin-left: 0;
}

@media (min-width: 1024px) {
    .content-wrapper {
        padding: 6.5rem 20px 2rem 20px;
        max-width: 100%;
    }
}

/* Large Desktop (1440px+) */
@media (min-width: 1440px) {
    .content-wrapper {
        padding: 7rem 40px 2rem 40px;
        max-width: 100%;
    }
    
    .dashboard-header {
        gap: 1.5rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 2rem;
    }
    
    .dashboard-actions {
        gap: 1rem;
    }
}

/* Ultra Wide Desktop (1920px+) */
@media (min-width: 1920px) {
    .content-wrapper {
        padding: 7.5rem 60px 2rem 60px;
        max-width: 100%;
    }
    
    .dashboard-header {
        gap: 2rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 2.5rem;
    }
    
    .dashboard-actions {
        gap: 1.25rem;
    }
    
    .dashboard-title-section h1 {
        font-size: 2.5rem;
    }
    
    .dashboard-title-section p {
        font-size: 1.125rem;
    }
}

/* Modern Mobile Responsive Design */
@media (max-width: 767px) {
    .app-layout {
        display: block !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .sidebar {
        display: none !important;
    }

    .main-content {
        display: block !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Content wrapper for both authenticated and unauthenticated pages */
    .content-wrapper {
        padding: 0.25rem 15px 1rem 15px !important;
        margin-top: 4rem !important; /* Optimized spacing for mobile */
        margin-left: 0 !important;
        margin-right: 0 !important;
        margin-bottom: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden;
        height: auto !important;
        min-height: calc(100vh - 4.5rem) !important;
        white-space: normal !important;
    }
    
    /* Content wrapper inside app-layout for authenticated pages */
    .app-layout .content-wrapper {
        padding: 0.25rem 15px 1rem 15px !important;
        margin-top: 4rem !important; /* Optimized spacing for mobile */
        margin-left: 0 !important;
        margin-right: 0 !important;
        margin-bottom: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden;
        height: auto !important;
        min-height: calc(100vh - 4.5rem) !important;
        white-space: normal !important;
    }
    
    /* Remove extra spacing on first child */
    .app-layout .content-wrapper > div:first-child,
    .app-layout .content-wrapper > *:first-child {
        margin-top: 0 !important;
        padding-top: 0 !important;
    }
    
    /* Ensure dashboard content starts immediately */
    .app-layout .content-wrapper .dashboard-header {
        margin-top: 0 !important;
        padding-top: 0 !important;
    }
    
    /* Remove any extra spacing from max-w-screen-xl container */
    .app-layout .content-wrapper .max-w-screen-xl {
        padding-top: 0 !important;
        margin-top: 0 !important;
    }
    
    /* Mobile hamburger menu */
    .mobile-menu-button {
        display: block !important;
    }
    
    /* Mobile menu dropdown */
    .mobile-menu-dropdown {
        position: fixed !important;
        top: 4rem !important;
        left: 0 !important;
        right: 0 !important;
        background: white !important;
        border-bottom: 1px solid #e5e7eb !important;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1) !important;
        z-index: 50 !important;
        transform: translateY(-100%) !important;
        transition: transform 0.3s ease !important;
        opacity: 0 !important;
        visibility: hidden !important;
    }
    
    .mobile-menu-dropdown.show {
        transform: translateY(0) !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    .mobile-menu-item {
        display: flex !important;
        align-items: center !important;
        padding: 1rem 1.5rem !important;
        color: #374151 !important;
        text-decoration: none !important;
        border-bottom: 1px solid #f3f4f6 !important;
        transition: background-color 0.2s ease !important;
    }
    
    .mobile-menu-item:hover {
        background-color: #f9fafb !important;
    }
    
    .mobile-menu-item.active {
        background-color: #eff6ff !important;
        color: #2563eb !important;
    }
    
    .mobile-menu-icon {
        margin-right: 0.75rem !important;
        font-size: 1.125rem !important;
    }
    
    /* Fix mobile dropdown positioning */
    #user-dropdown, #notification-dropdown {
        position: fixed !important;
        z-index: 9999 !important;
        max-width: calc(100vw - 20px) !important;
        right: 10px !important;
        left: auto !important;
        transform: none !important;
    }
    
    /* Remove extra spacing on first child */
    .content-wrapper > div:first-child,
    .content-wrapper > *:first-child {
        margin-top: 0 !important;
        padding-top: 0 !important;
    }
    
    /* Ensure dashboard content starts immediately */
    .content-wrapper .dashboard-header {
        margin-top: 0 !important;
        padding-top: 0 !important;
    }
    
    /* Remove any extra spacing from max-w-screen-xl container */
    .content-wrapper .max-w-screen-xl {
        padding-top: 0 !important;
        margin-top: 0 !important;
    }
    
    /* Reduce heading spacing in mobile */
    h1, h2, h3, h4, h5, h6 {
        margin-top: 0.25rem !important;
        padding-top: 0 !important;
        margin-bottom: 0.5rem !important;
    }

    .app-layout {
        display: block !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Mobile grid adjustments */
    .grid {
        gap: 0.75rem !important;
    }

    /* Stack cards vertically on mobile */
    .lg\:col-span-2,
    .lg\:col-span-3 {
        grid-column: span 1 !important;
    }
    
    /* Optimize spacing for mobile */
    .space-y-6 > * + * {
        margin-top: 0.75rem !important;
    }
    
    .space-y-4 > * + * {
        margin-top: 0.5rem !important;
    }
    
    .space-y-3 > * + * {
        margin-top: 0.5rem !important;
    }
    
    /* Fix gap spacing that causes issues */
    .gap-3, .gap-4 {
        gap: 0.5rem !important;
    }
    
    /* Ensure readable text size */
    .text-xs {
        font-size: 0.75rem !important;
    }
    
    .text-sm {
        font-size: 0.875rem !important;
    }
    
    .text-base {
        font-size: 1rem !important;
    }
    
    /* Compact card layouts */
    .rounded-lg {
        border-radius: 0.5rem;
    }
    
    /* Text sizing for mobile */
    .text-responsive-2xl {
        font-size: 1.25rem !important;
    }
    
    /* Better mobile button sizing */
    .px-4 {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
    
    .py-2 {
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }
    
    /* Fix flash message positioning */
    .fixed.top-20 {
        top: 4rem !important;
    }
    
    /* Simple mobile block layout */
    .mobile-block-layout {
        display: block !important;
        width: 100% !important;
    }
    
    /* Ensure scrollable content */
    html, body {
        overflow-y: auto !important;
        overflow-x: hidden !important;
        height: 100% !important;
        width: 100% !important;
        position: relative !important;
    }
    
    /* Make sure content can scroll */
    .main-content {
        height: auto !important;
        min-height: 100vh !important;
        overflow-y: visible !important;
        overflow-x: hidden !important;
        padding-bottom: 0 !important;
    }
    

    /* Unauthenticated layout (landing) - reduce default py-12 */
    .main-content:not(.with-sidebar) .content-wrapper {
        padding-top: 1rem !important;
        padding-bottom: 4rem !important;
    }
}

/* Hide mobile menu on desktop */
@media (min-width: 768px) {
    .mobile-menu-button {
        display: none !important;
    }
    
    .mobile-menu-dropdown {
        display: none !important;
    }
}

/* Modern Menu Item Structure */
.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin: 2px 8px;
    transition: all 0.2s ease;
    text-decoration: none;
    color: #6b7280;
    border-radius: 10px;
    position: relative;
    font-weight: 500;
    font-size: 14px;
}

.menu-item:hover {
    background-color: #f3f4f6;
    color: #111827;
    transform: translateX(2px);
}

.menu-item.active {
    background-color: #eff6ff;
    color: #2563eb;
}

.menu-item.active .menu-icon {
    color: #2563eb;
}

/* Modern Menu Icon Styling */
.menu-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #9ca3af;
    transition: all 0.2s ease;
    font-size: 18px;
}

.menu-item:hover .menu-icon {
    color: #2563eb;
    transform: scale(1.1);
}

/* Modern Menu Label Transitions */
.menu-label {
    opacity: 0;
    visibility: hidden;
    max-width: 0;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

/* Show menu labels on sidebar hover/expand */
.sidebar:hover .menu-label,
.app-layout.expanded .menu-label {
    opacity: 1;
    visibility: visible;
    max-width: 200px;
    transition-delay: 0.1s;
}

/* User info transitions */
.user-info .menu-label {
    opacity: 0;
    visibility: hidden;
    max-width: 0;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar:hover .user-info .menu-label,
.app-layout.expanded .user-info .menu-label {
    opacity: 1;
    visibility: visible;
    max-width: 150px;
    transition-delay: 0.1s;
}

/* User info section transitions */
.sidebar .user-info {
    transition: all 0.3s ease;
    padding: 0.5rem;
}

.app-layout.expanded .user-info {
    padding: 1rem;
    justify-content: flex-start;
}

/* Expand menu items on hover */
.app-layout.expanded .menu-item {
    justify-content: flex-start;
}

/* Subtle hover effect for menu items */
.menu-item:hover {
    transform: translateX(2px);
}

/* Mobile menu toggle button */
#mobile-menu-toggle {
    transition: all 0.3s ease;
}

#mobile-menu-toggle:hover {
    background-color: #f3f4f6;
}

/* Ensure smooth transitions for all layout elements */
.sidebar {
    transition: box-shadow 0.3s ease-in-out;
}

.main-content.with-sidebar {
    transition: grid-template-columns 0.3s ease-in-out;
}

.content-wrapper {
    transition: all 0.3s ease-in-out;
}

/* Mobile backdrop for sidebar overlay */
@media (max-width: 767px) {
    .mobile-backdrop {
        position: fixed;
        inset: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 30;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }

    .sidebar.mobile-open + .mobile-backdrop {
        opacity: 1;
        visibility: visible;
    }
}

/* Sidebar Toggle Button Styles */
.sidebar-toggle {
    transition: all 0.2s ease-in-out;
    z-index: 100;
}

.sidebar-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* Modern Tooltip Styles for Collapsed Sidebar */
.menu-item, .user-info {
    position: relative;
}

.menu-item:hover::after,
.user-info:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%) translateX(0);
    background-color: #111827;
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.813rem;
    font-weight: 500;
    white-space: nowrap;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.menu-item:hover::before,
.user-info:hover::before {
    content: "";
    position: absolute;
    left: calc(100% + 6px);
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-right-color: #111827;
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

/* Show tooltips only when sidebar is collapsed */
.sidebar:not(:hover) .menu-item:hover::after,
.sidebar:not(:hover) .menu-item:hover::before,
.sidebar:not(:hover) .user-info:hover::after,
.sidebar:not(:hover) .user-info:hover::before {
    opacity: 1;
    visibility: visible;
    transition-delay: 0.3s;
}

/* Hide tooltips when sidebar is expanded */
.sidebar:hover .menu-item::after,
.sidebar:hover .menu-item::before,
.sidebar:hover .user-info::after,
.sidebar:hover .user-info::before {
    display: none;
}

/* Menu Item Enhancements */
.menu-item::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(59, 130, 246, 0.1),
        transparent
    );
    transition: left 0.5s ease-in-out;
}

.menu-item:hover::before {
    left: 100%;
}

/* Active Menu Item */
.menu-item.active {
    background-color: #e5e7eb;
    border-right: 4px solid #3b82f6;
}

.menu-item.active .menu-icon {
    color: #3b82f6;
}

.menu-item.active .menu-label {
    color: #1e40af;
    font-weight: 600;
}

/* Transition and Animation Classes */
.sidebar-transition {
    transition: all 0.3s ease-in-out;
}

.gradient-bg {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.card-hover:hover {
    transform: translateY(-4px);
    transition: all 0.3s ease-in-out;
}

/* Active menu item highlighting */
.menu-item-active {
    background-color: #e5e7eb;
    border-right: 4px solid #3b82f6;
}

/* Container improvements */
.main-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Compact spacing */
.space-compact > * + * {
    margin-top: 1rem;
}

.space-compact-sm > * + * {
    margin-top: 0.75rem;
}

/* CAT interface specific styles */
.cat-sidebar {
    width: 300px;
    min-height: calc(100vh - 64px);
}

.cat-content {
    min-height: calc(100vh - 64px);
}

/* Responsive text scaling */
.text-responsive-lg {
    font-size: 1.125rem;
}

.text-responsive-xl {
    font-size: 1.25rem;
}

.text-responsive-2xl {
    font-size: 1.5rem;
}

@media (min-width: 1024px) {
    .text-responsive-lg {
        font-size: 1.25rem;
    }

    .text-responsive-xl {
        font-size: 1.5rem;
    }

    .text-responsive-2xl {
        font-size: 1.875rem;
    }
}

/* Toggle Button Positioning */
.sidebar-toggle {
    position: absolute;
    right: -12px;
    top: 80px;
    z-index: 60;
    transition: all 0.3s ease-in-out;
}

@media (max-width: 1023px) {
    .sidebar-toggle {
        display: none !important;
    }
}

/* Smooth transitions for all layout elements */
.sidebar,
.main-content,
.content-wrapper {
    transition: all 0.3s ease-in-out;
}

/* Enhanced responsive behavior for sidebar and content */
.app-layout:hover .main-content {
    transition: all 0.3s ease-in-out;
}

.app-layout:hover .content-wrapper {
    transition: all 0.3s ease-in-out;
}

/* Ensure content area adjusts smoothly */
.main-content.with-sidebar .content-wrapper {
    transition: width 0.3s ease-in-out, max-width 0.3s ease-in-out;
}

/* Collapsed state - content takes more space */
.app-layout:not(.expanded) .main-content .content-wrapper {
    width: 100%;
    max-width: calc(100vw - 100px);
}

/* Expanded state - content takes less space */
.app-layout.expanded .main-content .content-wrapper {
    width: 100%;
    max-width: calc(100vw - 260px);
}

/* Remove any fixed margins or paddings that interfere with grid */
.main-content {
    margin-left: 0 !important;
}

/* Ensure content takes full available width */
.app-layout .main-content {
    width: 100%;
    max-width: calc(100vw - 80px);
}


/* Enhanced scrollbar for sidebar */
.sidebar {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f1f5f9;
}

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

.sidebar::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
    transition: background-color 0.2s ease;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.sidebar-scroll {
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f1f5f9;
}

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

.sidebar-scroll::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
    transition: background-color 0.2s ease;
}

.sidebar-scroll::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Sidebar Responsive Behavior */
@media (max-width: 1023px) {
    .main-content.with-sidebar {
        grid-template-columns: 1fr;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .content-wrapper {
        margin-left: 0 !important;
    }
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 30;
    opacity: 0;
    visibility: hidden;
    transition:
        opacity 0.3s ease,
        visibility 0.3s ease;
}

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

/* Loading spinner styles */
.loading-spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Form enhancements */
.form-input {
    transition:
        border-color 0.15s ease-in-out,
        box-shadow 0.15s ease-in-out;
}

.form-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Button hover effects */
.btn-primary {
    transition: all 0.2s ease-in-out;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* Card styles */
.card {
    transition: all 0.3s ease-in-out;
}

.card:hover {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

/* Status indicator styles */
.status-active {
    background-color: #10b981;
    color: white;
}

.status-inactive {
    background-color: #6b7280;
    color: white;
}

.status-pending {
    background-color: #f59e0b;
    color: white;
}

.status-error {
    background-color: #ef4444;
    color: white;
}

/* Progress bar styles */
.progress-bar {
    transition: width 0.6s ease;
}

/* Custom badge styles */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1;
}

.badge-blue {
    background-color: #dbeafe;
    color: #1e40af;
}

.badge-green {
    background-color: #d1fae5;
    color: #047857;
}

.badge-yellow {
    background-color: #fef3c7;
    color: #92400e;
}

.badge-red {
    background-color: #fee2e2;
    color: #dc2626;
}

.badge-purple {
    background-color: #ede9fe;
    color: #7c3aed;
}

/* Table styles */
.table-hover tbody tr:hover {
    background-color: #f9fafb;
}

/* Alert styles */
.alert {
    padding: 1rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    border-radius: 0.375rem;
}

.alert-success {
    color: #065f46;
    background-color: #d1fae5;
    border-color: #a7f3d0;
}

.alert-warning {
    color: #92400e;
    background-color: #fef3c7;
    border-color: #fde68a;
}

.alert-error {
    color: #991b1b;
    background-color: #fee2e2;
    border-color: #fecaca;
}

.alert-info {
    color: #1e40af;
    background-color: #dbeafe;
    border-color: #bfdbfe;
}

/* Navigation enhancements */
.nav-link {
    transition: all 0.2s ease-in-out;
    position: relative;
}

.nav-link:hover {
    color: #3b82f6;
}

.nav-link.active::after {
    content: "";
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background-color: #3b82f6;
}

/* Enhanced Mobile Responsive Utilities */
@media (max-width: 640px) {
    .main-container {
        padding: 0 0.5rem;
    }

    .space-compact > * + * {
        margin-top: 0.75rem;
    }

    .cat-sidebar {
        width: 250px;
    }

    /* Mobile sidebar adjustments */
    .sidebar {
        width: 280px !important;
    }

    .sidebar-toggle {
        display: none;
    }

    /* Adjust tooltips for mobile */
    .tooltip-content {
        display: none;
    }
}

@media (max-width: 768px) {
    /* Tablet responsive adjustments */
    .main-content.with-sidebar {
        grid-template-columns: 1fr;
    }

    .sidebar {
        width: 280px;
    }

    .content-wrapper {
        margin-left: 0 !important;
        padding: 1rem !important;
    }
}

/* Desktop specific enhancements */
@media (min-width: 1024px) {
    .sidebar.collapsed + .main-content {
        margin-left: 4rem;
    }

    .sidebar.expanded + .main-content {
        margin-left: 16rem;
    }
}

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

    body {
        background: white !important;
    }

    .card {
        box-shadow: none;
        border: 1px solid #e5e7eb;
    }
}

/* Accessibility improvements */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus styles for better accessibility */
.focus-visible:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Custom utility classes */
.text-shadow {
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.backdrop-blur {
    backdrop-filter: blur(10px);
}

/* Dark mode utilities (if needed in future) */
@media (prefers-color-scheme: dark) {
    .dark-mode-auto {
        background-color: #1f2937;
        color: #f9fafb;
    }
}

/* Additional utility classes for better UX */
.transition-all {
    transition: all 0.3s ease;
}

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

.hover-lift:hover {
    transform: translateY(-2px);
}

/* Enhanced button styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
}

.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
}



/* Improved modal styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.modal-content {
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-width: 90vw;
    max-height: 90vh;
    overflow: auto;
}

/* Enhanced form styles */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #374151;
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 1rem;
    transition:
        border-color 0.15s ease-in-out,
        box-shadow 0.15s ease-in-out;
}

.form-control:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-error {
    color: #dc2626;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Improved table responsiveness */
@media (max-width: 768px) {
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table-responsive table {
        min-width: 600px;
    }
}

/* Enhanced loading states */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

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

/* Sidebar Animation Enhancements */
@keyframes slideIn {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

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

.sidebar.mobile-entering {
    animation: slideIn 0.3s ease-out forwards;
}

.sidebar.mobile-leaving {
    animation: slideOut 0.3s ease-out forwards;
}

/* Enhanced Focus States for Accessibility */
.sidebar .menu-item:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    border-radius: 0.5rem;
}

.sidebar-toggle:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Smooth transitions for all sidebar elements */
.sidebar * {
    transition: all 0.2s ease-in-out;
}

/* Prevent text selection on sidebar toggle */
.sidebar-toggle {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
}

/* Improved notification styles */
.notification {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 50;
    min-width: 300px;
    max-width: 500px;
    padding: 1rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    animation: slideInRight 0.3s ease;
}

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

/* Enhanced pagination styles */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.pagination-item {
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    color: #374151;
    text-decoration: none;
    transition: all 0.2s ease;
}

.pagination-item:hover {
    background-color: #f3f4f6;
}

.pagination-item.active {
    background-color: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

/* Improved tooltip styles */
.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip .tooltip-text {
    visibility: hidden;
    width: 200px;
    background-color: #1f2937;
    color: white;
    text-align: center;
    border-radius: 0.375rem;
    padding: 0.5rem;
    font-size: 0.875rem;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -100px;
    opacity: 0;
    transition: opacity 0.3s;
}

.tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* Modern Card Grid Layouts */
.card-grid {
    display: grid;
    gap: 1.5rem;
}

.card-grid-1 {
    grid-template-columns: 1fr;
}

.card-grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.card-grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.card-grid-4 {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

/* Modern Card Styles */
.modern-card {
    background: white;
    border-radius: 12px;
    border: 1px solid #f3f4f6;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.modern-card:hover {
    box-shadow: 0 4px 12px 0 rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

/* Page Header Icon Styling */
.page-title-icon {
    font-size: 1.5rem;
    margin-right: 0.75rem;
    color: #2563eb;
}

/* Subtitle with icon offset */
.subtitle-with-icon {
    margin-left: 2.25rem; /* Same as icon + margin width */
}

/* Custom Scrollbar Styles */
.scrollbar-thin {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.scrollbar-thin::-webkit-scrollbar {
    height: 6px;
    width: 6px;
}

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

.scrollbar-thin::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 3px;
}

.scrollbar-thin::-webkit-scrollbar-thumb:hover {
    background-color: #94a3b8;
}

@media (max-width: 640px) {
    .card-grid {
        grid-template-columns: 1fr;
    }
    
    /* Enhanced mobile optimizations */
    .table-responsive {
        font-size: 0.875rem;
    }
    
    .btn-mobile {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
    
    /* Touch-friendly button sizes */
    button, .btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Mobile-friendly form inputs */
    input, select, textarea {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 0.75rem;
    }
    
    /* Mobile navigation improvements */
    
    /* Compact mobile layouts */
    .mobile-compact {
        padding: 0.5rem;
    }
    
    .mobile-text-sm {
        font-size: 0.875rem;
    }
    
    /* Mobile table optimizations */
    table {
        font-size: 0.75rem;
    }
    
    table th, table td {
        padding: 0.5rem 0.75rem !important;
    }
    
    /* Ensure smooth scroll on mobile */
    .overflow-x-auto {
        -webkit-overflow-scrolling: touch;
    }
}
