/* ============================================
   Y GROUP UNIFIED PLATFORM — MINIMAL CSS
   Only includes what Tailwind CSS can't handle
   Most styling is now done via Tailwind utilities
   ============================================ */

/* Active nav state indicator (template tag-based) */
.nav-item.nav-active {
    background: rgba(255, 213, 0, 0.1);
    color: #FFD500;
    font-weight: 600;
}

/* Chart.js responsive container */
.chart-container {
    position: relative;
    width: 100%;
    height: 300px;
}

.chart-container canvas {
    max-width: 100%;
    height: auto !important;
}

/* HTMX loading states */
.htmx-request {
    opacity: 0.6;
    pointer-events: none;
}

.htmx-swapping {
    opacity: 0.5;
    transition: opacity 0.2s ease;
}

.htmx-settling {
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* Smooth page transitions with HTMX */
[hx-boost] {
    transition: opacity 0.2s ease;
}

/* Loading spinner for HTMX */
.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: inline-block;
    animation: spin 1s linear infinite;
}

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

/* Table responsiveness - horizontal scroll on mobile */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

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

/* Sticky table headers */
.table-sticky thead th {
    position: sticky;
    top: 0;
    background: inherit;
    z-index: 10;
}

/* Line clamp utilities (Tailwind backup) */
.line-clamp-1 {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Toast notifications (if not using Alpine) */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    min-width: 250px;
    padding: 1rem;
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
    z-index: 9999;
    animation: slideInRight 0.3s ease;
}

.dark .toast {
    background: #1F2937;
    border: 1px solid #374151;
}

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

/* Pulse animation for status indicators */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.animate-pulse-slow {
    animation: pulse 3s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Safe area insets for iOS */
@supports (padding: max(0px)) {
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
    
    .fixed-bottom {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Print styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    .sidebar,
    header,
    .mobile-action-bar,
    button {
        display: none !important;
    }
    
    main {
        margin: 0 !important;
    }
}

/* Focus visible (accessibility) */
*:focus-visible {
    outline: 2px solid #FFD500;
    outline-offset: 2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .border {
        border-width: 2px !important;
    }
}

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

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

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.dark ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

.dark ::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Skeleton loading animation (if needed) */
@keyframes skeleton-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.skeleton-loader {
    animation: skeleton-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
    background: linear-gradient(
        90deg,
        rgba(0, 0, 0, 0.05) 0%,
        rgba(0, 0, 0, 0.1) 50%,
        rgba(0, 0, 0, 0.05) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
}

.dark .skeleton-loader {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.05) 0%,
        rgba(255, 255, 255, 0.1) 50%,
        rgba(255, 255, 255, 0.05) 100%
    );
}

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

/* Empty state illustration fix */
.empty-state svg {
    max-width: 200px;
    margin: 0 auto;
}

/* Data table zebra striping (optional enhancement) */
.table-zebra tbody tr:nth-child(even) {
    background: rgba(0, 0, 0, 0.02);
}

.dark .table-zebra tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

/* Badge pulse for new notifications */
@keyframes badge-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

.badge-pulse {
    animation: badge-pulse 2s ease-in-out infinite;
}

/* Preserve aspect ratio for images */
.aspect-video {
    aspect-ratio: 16 / 9;
}

.aspect-square {
    aspect-ratio: 1 / 1;
}

/* Truncate with ellipsis */
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Chart.js dark mode adjustments */
.dark canvas {
    filter: brightness(0.9);
}

/* Mobile tap highlight removal */
* {
    -webkit-tap-highlight-color: transparent;
}

/* Ensure proper text rendering */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Fix for Alpine.js [x-cloak] */
[x-cloak] {
    display: none !important;
}
