/* SAGE UI - Custom Tailwind Extensions */
/* Updated: Visual Refresh with Sidebar Layout */

/* ============================================
   SIDEBAR NAVIGATION
   ============================================ */

.sidebar {
    width: 260px;
    min-width: 260px;
    transition: width 0.2s ease, min-width 0.2s ease;
    max-height: 100vh;
    max-height: 100dvh; /* Dynamic viewport height for mobile browsers */
}

.sidebar.collapsed {
    width: 72px;
    min-width: 72px;
}

/* Compact sidebar for small screens (height < 700px) */
@media (max-height: 700px) {
    .sidebar {
        width: 220px;
        min-width: 220px;
    }
    .sidebar.collapsed {
        width: 60px;
        min-width: 60px;
    }
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1rem;
    border-radius: 0.5rem;
    color: #e2e8f0;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background-color 0.15s ease, color 0.15s ease;
    cursor: pointer;
}

/* Smaller nav items on short screens */
@media (max-height: 700px) {
    .sidebar-nav-item {
        padding: 0.5rem 0.75rem;
        font-size: 0.8125rem;
        gap: 0.5rem;
    }
}

/* Even more compact for very short screens (< 600px height) */
@media (max-height: 600px) {
    .sidebar {
        width: 200px;
        min-width: 200px;
    }
    .sidebar.collapsed {
        width: 56px;
        min-width: 56px;
    }
    .sidebar-nav-item {
        padding: 0.375rem 0.625rem;
        font-size: 0.75rem;
        gap: 0.375rem;
    }
    .sidebar-nav-item .icon {
        width: 1rem;
        height: 1rem;
    }
}

.sidebar-nav-item:hover {
    background-color: #334155;
    color: #ffffff;
}

.sidebar-nav-item.active {
    background-color: #8b5cf6;
    color: #ffffff;
}

.sidebar-nav-item .icon {
    flex-shrink: 0;
    width: 1.25rem;
    height: 1.25rem;
}

.sidebar-nav-item .label {
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.15s ease;
}

.sidebar.collapsed .sidebar-nav-item .label {
    opacity: 0;
    width: 0;
}

/* Mobile sidebar overlay */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 40;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

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

/* ============================================
   GRADIENT UTILITIES
   ============================================ */

/* Gradient utilities */
.bg-sage-gradient {
    background: linear-gradient(135deg, #6B46C1 0%, #8B5CF6 50%, #14B8A6 100%);
}

.bg-sage-gradient-light {
    background: linear-gradient(135deg, #EDE9FE 0%, #CCFBF1 100%);
}

.bg-sage-gradient-hover:hover {
    background: linear-gradient(135deg, #5b21b6 0%, #7c3aed 50%, #0d9488 100%);
}

/* Text gradient */
.text-sage-gradient {
    background: linear-gradient(135deg, #6B46C1 0%, #14B8A6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

.animate-slide-up {
    animation: slideUp 0.3s ease-out;
}

.animate-slide-down {
    animation: slideDown 0.3s ease-out;
}

.animate-scale-in {
    animation: scaleIn 0.2s ease-out;
}

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

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

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

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Table utilities */
.table-row-hover:hover {
    background-color: rgba(139, 92, 246, 0.05);
}

.table-header {
    padding: 1rem 1.5rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: #e5e7eb;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.table-header:hover {
    background-color: #374151;
}

.table-cell {
    padding: 1rem 1.5rem;
    font-size: 0.875rem;
    color: #111827;
}

/* Responsive table styles for mobile */
@media (max-width: 640px) {
    table th,
    table td {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
    }

    /* Hide less important columns on mobile */
    table th:nth-child(n+4),
    table td:nth-child(n+4) {
        display: none;
    }

    /* Ensure table container allows horizontal scroll */
    .overflow-x-auto {
        -webkit-overflow-scrolling: touch;
    }
}

/* Tab content visibility */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

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

.custom-scrollbar::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

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

/* Sidebar-specific scrollbar (dark theme) */
.sidebar .custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}

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

.sidebar .custom-scrollbar::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 3px;
}

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

/* Smaller scrollbar on compact screens */
@media (max-height: 700px) {
    .sidebar .custom-scrollbar::-webkit-scrollbar {
        width: 4px;
    }
}

/* Focus ring utility */
.focus-ring:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.3);
}

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

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

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

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

/* 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);
}

/* Button press effect */
.btn-press:active {
    transform: scale(0.98);
}

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

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

/* Drag and drop zone */
.dropzone-active {
    border-color: #8b5cf6 !important;
    background-color: rgba(139, 92, 246, 0.05) !important;
}

/* Progress bar animation */
.progress-bar {
    transition: width 0.3s ease;
}

/* Tooltip */
.tooltip {
    position: relative;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem 0.75rem;
    background: #1f2937;
    color: white;
    font-size: 0.75rem;
    border-radius: 0.375rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    margin-bottom: 0.5rem;
    z-index: 50;
}

.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   RESPONSIVE UTILITIES
   ============================================ */

/* Prevent content overflow on all screens */
main,
.main-content,
[class*="content"] {
    max-width: 100%;
    overflow-x: hidden;
}

/* Allow horizontal scroll for specific elements */
.overflow-x-auto {
    max-width: 100%;
    overflow-x: auto;
}

/* Responsive form elements */
@media (max-width: 640px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    input[type="number"],
    textarea,
    select {
        font-size: 16px; /* Prevents iOS zoom on focus */
    }

    /* Stack flex items on mobile */
    .flex.gap-3:not(.flex-wrap) {
        flex-wrap: wrap;
    }

    /* Full width buttons on mobile */
    button.px-8,
    button.px-6 {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    /* Reduce grid gaps on mobile */
    .gap-4 {
        gap: 0.75rem;
    }

    .gap-6 {
        gap: 1rem;
    }
}

/* Portrait mode specific fixes */
@media (max-width: 480px) and (orientation: portrait) {
    /* Ensure cards don't overflow */
    .rounded-xl,
    .rounded-lg {
        max-width: 100%;
    }

    /* Smaller text for data-heavy screens */
    .text-sm {
        font-size: 0.8125rem;
    }

    .text-xs {
        font-size: 0.6875rem;
    }
}
