/* =============================================
   AB Thunder Food — Modern Enhanced Styles
   ============================================= */

/* CSS Variables for consistent theming */
:root {
  --primary-color: #f27f0d;
  --primary-hover: #e67200;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --error-color: #ef4444;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --bg-primary: #ffffff;
  --bg-secondary: #f9fafb;
  --border-color: #e5e7eb;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
}

.dark {
  --text-primary: #f9fafb;
  --text-secondary: #d1d5db;
  --bg-primary: #111827;
  --bg-secondary: #1f2937;
  --border-color: #374151;
}

/* Scrollbar Hide */
.scrollbar-hide::-webkit-scrollbar {
    display: none;
}

.scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Safe Area */
.pt-safe-top {
    padding-top: env(safe-area-inset-top, 20px);
}

.pb-safe-bottom {
    padding-bottom: env(safe-area-inset-bottom, 20px);
}

/* Modern Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes bounce {
    0%, 20%, 53%, 80%, 100% {
        transform: translate3d(0, 0, 0);
    }
    40%, 43% {
        transform: translate3d(0, -8px, 0);
    }
    70% {
        transform: translate3d(0, -4px, 0);
    }
    90% {
        transform: translate3d(0, -2px, 0);
    }
}

@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

.animate-fade-in-up {
    animation: fadeInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.animate-fade-in-down {
    animation: fadeInDown 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.animate-slide-in-right {
    animation: slideInRight 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.animate-spin {
    animation: spin 1s linear infinite;
}

.animate-bounce {
    animation: bounce 1s infinite;
}

/* Staggered animations */
.animate-stagger-1 { animation-delay: 0.1s; }
.animate-stagger-2 { animation-delay: 0.2s; }
.animate-stagger-3 { animation-delay: 0.3s; }
.animate-stagger-4 { animation-delay: 0.4s; }
.animate-stagger-5 { animation-delay: 0.5s; }

/* Modern Loading States */
.loading-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 1000px 100%;
    animation: shimmer 2s infinite;
    border-radius: 0.5rem;
}

.dark .loading-skeleton {
    background: linear-gradient(90deg, #374151 25%, #4b5563 50%, #374151 75%);
    background-size: 1000px 100%;
}

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(242, 127, 13, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
}

.loading-dots {
    display: inline-flex;
    gap: 4px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--primary-color);
    animation: bounce 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }

/* Modern Button Styles */
.btn {
    position: relative;
    overflow: hidden;
    transition: all var(--transition-normal);
    transform: translateZ(0);
    backface-visibility: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    box-shadow: 0 4px 15px rgba(242, 127, 13, 0.3);
    transition: all var(--transition-normal);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(242, 127, 13, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 4px 15px rgba(242, 127, 13, 0.3);
}

/* Modern Card Styles */
.card {
    background: var(--bg-primary);
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: all var(--transition-normal);
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-elevated {
    box-shadow: var(--shadow-lg);
    transition: all var(--transition-normal);
}

.card-elevated:hover {
    box-shadow: var(--shadow-xl);
    transform: translateY(-4px);
}

/* Modern Input Styles */
.input-modern {
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 16px;
    transition: all var(--transition-normal);
    outline: none;
}

.input-modern:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(242, 127, 13, 0.1);
    transform: translateY(-1px);
}

.input-modern::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

/* Print Styles */
@media print {
    .no-print {
        display: none !important;
    }

    body {
        background: white !important;
        color: black !important;
    }

    #bottom-nav {
        display: none !important;
    }

    #snackbar {
        display: none !important;
    }

    .btn,
    .card {
        box-shadow: none !important;
        border: 1px solid #000 !important;
    }
}

/* Selection */
::selection {
    background: rgba(242, 127, 13, 0.2);
}

/* Smooth scroll */
html {
    scroll-behavior: smooth;
}

/* Toggle switch fix */
input[type="checkbox"]:checked+div {
    background-color: inherit;
}

/* Details marker hide */
details summary::-webkit-details-marker {
    display: none;
}

/* Receipt Edge */
.receipt-edge {
    background-color: transparent;
    background-size: 20px 20px;
    height: 20px;
    width: 100%;
    background-repeat: repeat-x;
    background-image: linear-gradient(45deg, transparent 33.333%, #ffffff 33.333%, #ffffff 66.667%, transparent 66.667%),
        linear-gradient(-45deg, transparent 33.333%, #ffffff 33.333%, #ffffff 66.667%, transparent 66.667%);
    background-position: 0px 10px;
}

.dark .receipt-edge {
    background-image: linear-gradient(45deg, transparent 33.333%, #1e1e1e 33.333%, #1e1e1e 66.667%, transparent 66.667%),
        linear-gradient(-45deg, transparent 33.333%, #1e1e1e 33.333%, #1e1e1e 66.667%, transparent 66.667%);
}

/* =============================================
   Mobile Responsive Fixes
   ============================================= */

/* iOS momentum scroll + overscroll */
#app {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    scroll-behavior: smooth;
}

/* Prevent horizontal overflow on all pages */
#app>div {
    max-width: 100vw;
    overflow-x: hidden;
}

/* Dynamic viewport height fallback */
@supports not (height: 100dvh) {
    body {
        height: 100vh;
    }
}

/* Touch feedback for buttons */
button,
a,
[onclick] {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Prevent text selection on interactive elements */
nav,
button,
.round-btn {
    -webkit-user-select: none;
    user-select: none;
}

/* Image rendering */
img {
    -webkit-user-drag: none;
    user-select: none;
}

/* Prevent pull-to-refresh interference */
body {
    overscroll-behavior-y: none;
}

/* Fix input zoom on iOS (font-size < 16px triggers zoom) */
input,
textarea,
select {
    font-size: 16px !important;
}

/* Modern Micro-interactions */
.interactive-scale {
    transition: transform var(--transition-fast);
}

.interactive-scale:hover {
    transform: scale(1.05);
}

.interactive-scale:active {
    transform: scale(0.98);
}

.interactive-glow {
    transition: all var(--transition-normal);
}

.interactive-glow:hover {
    box-shadow: 0 0 20px rgba(242, 127, 13, 0.3);
}

.interactive-lift {
    transition: all var(--transition-normal);
}

.interactive-lift:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

/* Success/Error States */
.state-success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    animation: fadeInUp 0.5s ease-out;
}

.state-error {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    animation: shake 0.5s ease-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-2px); }
    20%, 40%, 60%, 80% { transform: translateX(2px); }
}

/* Modern Notification Styles */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: var(--shadow-xl);
    animation: slideInRight 0.3s ease-out;
    max-width: 400px;
    backdrop-filter: blur(10px);
}

.notification-success {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.9), rgba(5, 150, 105, 0.9));
    color: white;
}

.notification-error {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.9), rgba(220, 38, 38, 0.9));
    color: white;
}

.notification-info {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.9), rgba(37, 99, 235, 0.9));
    color: white;
}

/* Smooth transitions for page changes */
#app {
    transition: opacity var(--transition-normal);
}

.page-transition-enter {
    opacity: 0;
    transform: translateY(20px);
}

.page-transition-enter-active {
    opacity: 1;
    transform: translateY(0);
    transition: all var(--transition-normal);
}

.page-transition-exit {
    opacity: 1;
    transform: translateY(0);
}

.page-transition-exit-active {
    opacity: 0;
    transform: translateY(-20px);
    transition: all var(--transition-normal);
}

/* Grid responsive: smaller screens get 1 column */
@media (max-width: 320px) {
    .grid-cols-2 {
        grid-template-columns: 1fr !important;
    }
}

/* Fix for notch/home indicator on modern phones */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    #bottom-nav {
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
    }
}

/* =============================================
   Modern Performance Optimizations
   ============================================= */

/* GPU acceleration for smooth animations */
.gpu-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000000;
        --text-secondary: #000000;
    }
    
    .dark {
        --border-color: #ffffff;
        --text-secondary: #ffffff;
    }
}

/* Modern Focus Styles */
.focus-modern:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Modern Scrollbar */
.scrollbar-modern::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.scrollbar-modern::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

.scrollbar-modern::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
    transition: background var(--transition-fast);
}

.scrollbar-modern::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Dark mode scrollbar */
.dark .scrollbar-modern::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

.dark .scrollbar-modern::-webkit-scrollbar-thumb {
    background: var(--border-color);
}

.dark .scrollbar-modern::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}