/* ========================================
   CUSTOM STYLES - GurmeClickPos
   Modern, minimal custom CSS
   Tailwind-first approach - Only styles that can't be done with Tailwind
   ======================================== */

/* ========================================
   1. ACCESSIBILITY
   ======================================== */

/* Skip Navigation Links - WCAG 2.1 AA Compliance */
.skip-navigation {
    position: relative;
    z-index: 9999;
}

.skip-link {
    position: absolute;
    top: -9999px;
    left: -9999px;
    opacity: 0;
    pointer-events: none;
    background: #4088F5;
    color: white !important;
    padding: 12px 16px;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: opacity 0.2s ease, top 0s 0.2s, left 0s 0.2s;
}

.skip-link:focus {
    top: 8px;
    left: 8px;
    opacity: 1;
    pointer-events: auto;
    outline: 3px solid rgba(255, 255, 255, 0.8);
    outline-offset: 2px;
    transition: opacity 0.2s ease, top 0s, left 0s;
}

.skip-link:hover {
    background: #3175F1;
    transform: scale(1.05);
}

/* Main content focus styles for skip navigation */
#main-content:focus {
    outline: none;
}

/* ========================================
   2. GLASS MORPHISM UTILITY
   ======================================== */

.glass-morphism {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.18);
}

@supports not (backdrop-filter: blur(20px)) {
    .glass-morphism {
        background: rgba(255, 255, 255, 0.98);
    }
}

/* Dark mode glass morphism */
.dark .glass-morphism {
    background: rgba(17, 24, 39, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* ========================================
   3. HAMBURGER MENU ANIMATION
   ======================================== */

.hamburger-menu {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    cursor: pointer;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.hamburger-menu:hover {
    background: rgba(64, 136, 245, 0.1);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    border-color: rgba(64, 136, 245, 0.3);
}

.hamburger-menu:hover .hamburger-icon span {
    background-color: #2563eb !important;
}

.hamburger-menu:active {
    transform: scale(0.95);
}

.hamburger-menu:active .hamburger-icon {
    transform: scale(0.9);
}

.hamburger-icon {
    width: 24px;
    height: 18px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.3s ease;
}

.hamburger-icon span {
    display: block;
    width: 100%;
    height: 3px;
    background-color: #4088F5 !important;
    border-radius: 2px;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    transform-origin: center;
    margin-bottom: 4px;
    will-change: transform, opacity;
}

.hamburger-icon span:nth-child(1) {
    width: 100%;
}

.hamburger-icon span:nth-child(2) {
    width: 80%;
    margin-left: auto;
}

.hamburger-icon span:nth-child(3) {
    width: 60%;
    margin-left: auto;
    margin-bottom: 0;
}

/* Hamburger Animation - Open State */
.hamburger-icon.open {
    animation: pulse 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.hamburger-icon.open span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 7px);
    width: 100%;
    margin-bottom: 0;
}

.hamburger-icon.open span:nth-child(2) {
    opacity: 0;
    transform: scale(0) rotate(180deg);
    margin-bottom: 0;
}

.hamburger-icon.open span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -7px);
    width: 100%;
    margin-left: 0;
    margin-bottom: 0;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.15);
    }
    100% {
        transform: scale(1);
    }
}

/* Dark mode hamburger */
.dark .hamburger-menu {
    background: rgba(31, 41, 55, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.dark .hamburger-menu:hover {
    background: rgba(59, 130, 246, 0.15);
}

/* Responsive adjustments - Tailwind lg breakpoint aligned */
@media (max-width: 1023.98px) {
    .hamburger-menu {
        width: 40px;
        height: 40px;
        min-width: 40px;
        flex-shrink: 0;
    }

    .hamburger-icon {
        width: 20px;
        height: 16px;
    }
}

@media (max-width: 767.98px) {
    .hamburger-menu {
        width: 44px;
        height: 44px;
        min-width: 44px; /* WCAG 2.1 AA touch target */
        margin-right: 4px;
    }

    .hamburger-icon {
        width: 18px;
        height: 14px;
    }

    .hamburger-icon span {
        height: 2px;
        margin-bottom: 3px;
    }

    .hamburger-icon span:last-child {
        margin-bottom: 0;
    }

    .hamburger-icon.open span:nth-child(1) {
        transform: rotate(45deg) translate(0, 6px);
    }

    .hamburger-icon.open span:nth-child(3) {
        transform: rotate(-45deg) translate(0, -6px);
    }
}

/* ========================================
   4. REDUCED MOTION SUPPORT
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    .hamburger-menu,
    .hamburger-icon,
    .hamburger-icon span,
    .skip-link {
        animation: none !important;
        transition: none !important;
    }
}

/* ========================================
   5. TOGGLE SWITCH FIX
   Fix for Flowbite toggle switch animation
   Tailwind JIT doesn't generate peer-checked:after:translate-x-full
   ======================================== */

/* Medium toggle (w-11 h-6) - Default */
.toggle-switch-md {
    overflow: hidden; /* Prevent ball from overflowing */
}

.toggle-switch-md::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    background-color: white;
    border: 1px solid #d1d5db;
    border-radius: 9999px;
    height: 1.25rem; /* 20px */
    width: 1.25rem; /* 20px */
    transition: transform 0.2s ease-in-out;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.peer:checked ~ .toggle-switch-md::after {
    transform: translateX(100%);
    border-color: white;
}

.peer:checked ~ .toggle-switch-md {
    background-color: #2563eb; /* blue-600 */
}

/* Small toggle (w-9 h-5) */
.toggle-switch-sm {
    overflow: hidden;
}

.toggle-switch-sm::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    background-color: white;
    border: 1px solid #d1d5db;
    border-radius: 9999px;
    height: 1rem; /* 16px */
    width: 1rem; /* 16px */
    transition: transform 0.2s ease-in-out;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.peer:checked ~ .toggle-switch-sm::after {
    transform: translateX(100%);
    border-color: white;
}

.peer:checked ~ .toggle-switch-sm {
    background-color: #2563eb; /* blue-600 */
}

/* RTL support for both sizes */
[dir="rtl"] .peer:checked ~ .toggle-switch-md::after,
[dir="rtl"] .peer:checked ~ .toggle-switch-sm::after {
    transform: translateX(-100%);
}

/* Large toggle (w-14 h-7) */
.toggle-switch-lg {
    overflow: hidden;
}

.toggle-switch-lg::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 4px;
    background-color: white;
    border: 1px solid #d1d5db;
    border-radius: 9999px;
    height: 1.5rem; /* 24px */
    width: 1.5rem; /* 24px */
    transition: transform 0.2s ease-in-out;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.peer:checked ~ .toggle-switch-lg::after {
    transform: translateX(100%);
    border-color: white;
}

.peer:checked ~ .toggle-switch-lg {
    background-color: #2563eb; /* blue-600 */
}

/* RTL support for large toggle */
[dir="rtl"] .peer:checked ~ .toggle-switch-lg::after {
    transform: translateX(-100%);
}

/* Dark mode adjustments */
.dark .toggle-switch-md::after,
.dark .toggle-switch-sm::after,
.dark .toggle-switch-lg::after {
    border-color: #4b5563;
}

/* ========================================
   6. BLAZOR ERROR UI
   Standard Blazor WebAssembly error notification
   Hidden by default, shown automatically on unhandled errors
   ======================================== */

#blazor-error-ui {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a5a 100%);
    bottom: 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    display: none;
    left: 0;
    padding: 1rem 1.5rem;
    position: fixed;
    width: 100%;
    z-index: 9999;
    color: white;
    font-weight: 500;
    font-size: 0.95rem;
    backdrop-filter: blur(10px);
}

#blazor-error-ui .reload {
    color: white;
    text-decoration: underline;
    margin-left: 0.5rem;
    font-weight: 600;
}

#blazor-error-ui .reload:hover {
    text-decoration: none;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    transition: background 0.2s ease;
}

#blazor-error-ui .dismiss:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Dark mode support */
.dark #blazor-error-ui {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
}

/* ========================================
   7. MOBILE RESPONSIVE UTILITIES
   Global mobile-first responsive patterns
   WCAG 2.1 AA compliant touch targets (44x44px min)
   ======================================== */

/* Touch-friendly minimum sizes (WCAG 2.1 AA) */
.touch-target {
    min-width: 44px;
    min-height: 44px;
}

.touch-target-lg {
    min-width: 48px;
    min-height: 48px;
}

/* Mobile-first responsive padding */
.responsive-padding {
    padding: 0.5rem;
}

@media (min-width: 640px) {
    .responsive-padding {
        padding: 0.75rem;
    }
}

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

@media (min-width: 1024px) {
    .responsive-padding {
        padding: 1.5rem;
    }
}

/* Mobile card container - full width with minimal padding */
.mobile-card {
    width: 100%;
    padding: 0.75rem;
    border-radius: 0.5rem;
}

@media (min-width: 640px) {
    .mobile-card {
        padding: 1rem;
    }
}

@media (min-width: 768px) {
    .mobile-card {
        padding: 1.25rem;
        border-radius: 0.75rem;
    }
}

/* Mobile-friendly modal/dialog */
.mobile-modal {
    width: calc(100vw - 1rem);
    max-width: 100%;
    max-height: calc(100vh - 6rem);
    margin: 0.5rem;
}

@media (min-width: 640px) {
    .mobile-modal {
        width: calc(100vw - 2rem);
        max-width: 32rem; /* 512px */
        margin: 1rem;
    }
}

@media (min-width: 768px) {
    .mobile-modal {
        max-width: 42rem; /* 672px */
    }
}

@media (min-width: 1024px) {
    .mobile-modal {
        max-width: 56rem; /* 896px */
    }
}

/* Mobile table to card transformation */
.mobile-table-card {
    display: block;
}

.mobile-table-card thead {
    display: none;
}

.mobile-table-card tbody,
.mobile-table-card tr {
    display: block;
}

.mobile-table-card tr {
    background: white;
    border-radius: 0.5rem;
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.mobile-table-card td {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0;
    border: none;
}

.mobile-table-card td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #6b7280;
    flex-shrink: 0;
    margin-right: 0.5rem;
}

.dark .mobile-table-card tr {
    background: #1f2937;
}

@media (min-width: 768px) {
    .mobile-table-card {
        display: table;
    }

    .mobile-table-card thead {
        display: table-header-group;
    }

    .mobile-table-card tbody {
        display: table-row-group;
    }

    .mobile-table-card tr {
        display: table-row;
        background: transparent;
        border-radius: 0;
        margin-bottom: 0;
        padding: 0;
        box-shadow: none;
    }

    .mobile-table-card td {
        display: table-cell;
        padding: 0.75rem 1rem;
        border-bottom: 1px solid #e5e7eb;
    }

    .mobile-table-card td::before {
        display: none;
    }

    .dark .mobile-table-card tr {
        background: transparent;
    }
}

/* Safe area inset support for notched devices */
.safe-area-top {
    padding-top: max(0px, env(safe-area-inset-top));
}

.safe-area-bottom {
    padding-bottom: max(0px, env(safe-area-inset-bottom));
}

.safe-area-left {
    padding-left: max(0px, env(safe-area-inset-left));
}

.safe-area-right {
    padding-right: max(0px, env(safe-area-inset-right));
}

/* Fluid typography */
.text-fluid-sm {
    font-size: clamp(0.75rem, 2vw, 0.875rem);
}

.text-fluid-base {
    font-size: clamp(0.875rem, 2.5vw, 1rem);
}

.text-fluid-lg {
    font-size: clamp(1rem, 3vw, 1.25rem);
}

.text-fluid-xl {
    font-size: clamp(1.25rem, 4vw, 1.5rem);
}

/* Mobile-friendly button group */
.mobile-btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.mobile-btn-group > * {
    flex: 1 1 auto;
    min-width: 0;
}

@media (min-width: 640px) {
    .mobile-btn-group {
        flex-wrap: nowrap;
    }

    .mobile-btn-group > * {
        flex: 0 0 auto;
    }
}

/* Stack on mobile, row on desktop */
.mobile-stack {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

@media (min-width: 640px) {
    .mobile-stack {
        flex-direction: row;
        gap: 1rem;
    }
}

/* Hide on mobile */
.mobile-hidden {
    display: none;
}

@media (min-width: 768px) {
    .mobile-hidden {
        display: block;
    }
}

/* Show only on mobile */
.mobile-only {
    display: block;
}

@media (min-width: 768px) {
    .mobile-only {
        display: none;
    }
}

/* Responsive grid gap */
.gap-responsive {
    gap: 0.5rem;
}

@media (min-width: 640px) {
    .gap-responsive {
        gap: 0.75rem;
    }
}

@media (min-width: 768px) {
    .gap-responsive {
        gap: 1rem;
    }
}

@media (min-width: 1024px) {
    .gap-responsive {
        gap: 1.5rem;
    }
}

/* Overflow scroll with momentum */
.mobile-scroll-x {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.mobile-scroll-y {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

/* Mobile close button (44x44 WCAG compliant) */
.mobile-close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 0.5rem;
    border-radius: 0.5rem;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.mobile-close-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.mobile-close-btn:active {
    background-color: rgba(0, 0, 0, 0.1);
    transform: scale(0.95);
}

.dark .mobile-close-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.dark .mobile-close-btn:active {
    background-color: rgba(255, 255, 255, 0.15);
}

/* ========================================
   8. TABLE SCROLL INDICATORS
   Visual gradient indicators for horizontal scrollable tables
   Shows left/right shadows based on scroll position
   ======================================== */

/* Scroll indicator container positioning */
[data-scroll-indicators="true"] {
    position: relative;
}

/* Left scroll indicator - gradient fade from left */
/* z-index: 15 to appear above sticky header (z-10) */
.table-scroll-indicator-left {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 24px;
    background: linear-gradient(to right, rgba(255, 255, 255, 0.95), transparent);
    pointer-events: none;
    z-index: 15;
    opacity: 0;
    transition: opacity 0.2s ease;
}

/* Right scroll indicator - gradient fade from right */
/* z-index: 15 to appear above sticky header (z-10) */
.table-scroll-indicator-right {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 24px;
    background: linear-gradient(to left, rgba(255, 255, 255, 0.95), transparent);
    pointer-events: none;
    z-index: 15;
    opacity: 0;
    transition: opacity 0.2s ease;
}

/* Dark mode scroll indicators */
.dark .table-scroll-indicator-left {
    background: linear-gradient(to right, rgba(31, 41, 55, 0.95), transparent);
}

.dark .table-scroll-indicator-right {
    background: linear-gradient(to left, rgba(31, 41, 55, 0.95), transparent);
}

/* Wider indicators on mobile for better visibility */
@media (max-width: 767.98px) {
    .table-scroll-indicator-left,
    .table-scroll-indicator-right {
        width: 32px;
    }
}

/* Reduced motion: instant transitions */
@media (prefers-reduced-motion: reduce) {
    .table-scroll-indicator-left,
    .table-scroll-indicator-right {
        transition: none;
    }
}
