/* Custom Styles for Booking System */

* {
    -webkit-tap-highlight-color: transparent;
}

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

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

/* Smooth transitions for all elements */
* {
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

/* Custom scrollbar for light mode */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.dark ::-webkit-scrollbar-track {
    background: #374151;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.dark ::-webkit-scrollbar-thumb {
    background: #6b7280;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.dark ::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Improved focus states for accessibility */
input:focus,
select:focus,
button:focus {
    outline: none;
}

/* Loading state */
.loading {
    pointer-events: none;
    opacity: 0.6;
}

/* Admin tab active state */
.admin-tab.active {
    background-color: #f9fafb;
    border-bottom-color: #2563eb;
}

.dark .admin-tab.active {
    background-color: #1f2937;
    border-bottom-color: #3b82f6;
}

/* Admin header */
.admin-header {
    background-color: #FFA62E !important;
}

.dark .admin-header {
    background-color: #cc8a26 !important;
}

/* Ristorazione header */
.ristorazione-header {
    background-color: #f4c430 !important;
}

.dark .ristorazione-header {
    background-color: #d4a017 !important;
}

/* Table responsive */
@media (max-width: 768px) {
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}

/* Improved toast container positioning for mobile */
@media (max-width: 640px) {
    #toast-container {
        left: 1rem;
        right: 1rem;
        top: 1rem;
    }
    
    #toast-container > div {
        width: 100%;
    }
}

/* Toast dark mode support */
.dark #toast-container .bg-green-500 {
    background-color: #10b981 !important;
}

.dark #toast-container .bg-red-500 {
    background-color: #ef4444 !important;
}

.dark #toast-container .bg-blue-500 {
    background-color: #3b82f6 !important;
}

.dark #toast-container .bg-yellow-500 {
    background-color: #f59e0b !important;
}

/* Smooth modal transitions */
#edit-modal,
#anagrafica-modal {
    transition: opacity 0.3s ease;
}

#edit-modal:not(.hidden),
#anagrafica-modal:not(.hidden) {
    animation: fadeIn 0.3s ease;
}

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

/* Company yellow color scheme for primary action buttons only */
/* Primary action buttons (submit, save, add, export, etc.) */
.bg-blue-600,
.bg-green-600 {
    background-color: #eaab00 !important;
    color: #000000 !important;
}

.bg-blue-600:hover,
.bg-green-600:hover {
    background-color: #d4a017 !important;
    color: #000000 !important;
}

/* Login button */
button[type="submit"] {
    background-color: #eaab00 !important;
    color: #000000 !important;
}

button[type="submit"]:hover {
    background-color: #d4a017 !important;
    color: #000000 !important;
}

/* Setup button */
#setup-btn {
    background-color: #eaab00 !important;
    color: #000000 !important;
}

#setup-btn:hover {
    background-color: #d4a017 !important;
    color: #000000 !important;
}

/* Export and Import buttons */
button[id*="export"],
button[id*="import"],
.bg-green-600[id*="export"],
.bg-purple-600[id*="import"] {
    background-color: #eaab00 !important;
    color: #000000 !important;
}

button[id*="export"]:hover,
button[id*="import"]:hover,
.bg-green-600[id*="export"]:hover,
.bg-purple-600[id*="import"]:hover {
    background-color: #d4a017 !important;
    color: #000000 !important;
}

/* Add buttons */
button[id*="add"],
.bg-blue-600[id*="add"] {
    background-color: #eaab00 !important;
    color: #000000 !important;
}

button[id*="add"]:hover,
.bg-blue-600[id*="add"]:hover {
    background-color: #d4a017 !important;
    color: #000000 !important;
}

/* Save buttons */
button[id*="save"],
.bg-blue-600[id*="save"] {
    background-color: #eaab00 !important;
    color: #000000 !important;
}

button[id*="save"]:hover,
.bg-blue-600[id*="save"]:hover {
    background-color: #d4a017 !important;
    color: #000000 !important;
}

/* Submit booking button */
#submit-booking-btn {
    background-color: #eaab00 !important;
    color: #000000 !important;
}

#submit-booking-btn:hover {
    background-color: #d4a017 !important;
    color: #000000 !important;
}

/* Secondary buttons (cancel, etc.) remain as they were */
.bg-gray-300 {
    background-color: #f6f6f6 !important;
    color: #374151 !important;
    border: 1px solid #d1d5db !important;
}

.bg-gray-300:hover {
    background-color: #e5e5e5 !important;
    color: #374151 !important;
}

/* Delete buttons (keep red for danger indication) */
.text-red-600,
.text-red-800 {
    color: #dc2626 !important;
}

.text-red-600:hover,
.text-red-800:hover {
    color: #b91c1c !important;
}

/* Edit buttons (yellow accent) */
.text-\[#eaab00\] {
    color: #eaab00 !important;
}

.text-\[#eaab00\]:hover {
    color: #d4a017 !important;
}

/* Better button states */
button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
    background-color: #cccccc !important;
    color: #666666 !important;
}

button:not(:disabled):active {
    transform: scale(0.98);
}

/* Improved card hover effects */
.hover\:shadow-md:hover {
    transform: translateY(-2px);
    transition: all 0.2s ease;
}

/* Print styles */
@media print {
    #toast-container,
    button,
    header button,
    #theme-toggle,
    #theme-toggle-header {
        display: none !important;
    }
    
    table {
        page-break-inside: auto;
    }
    
    tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }
    
    .dark body {
        background: white !important;
        color: black !important;
    }
    
    .dark * {
        background: white !important;
        color: black !important;
        border-color: #e5e7eb !important;
    }
}

/* PWA installation prompt */
.pwa-install-prompt {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    padding: 1rem;
    box-shadow: 0 -4px 6px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.dark .pwa-install-prompt {
    background: #1f2937;
    box-shadow: 0 -4px 6px rgba(0, 0, 0, 0.3);
}

.pwa-install-prompt.show {
    transform: translateY(0);
}

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

.dark .skeleton {
    background: linear-gradient(90deg, #374151 25%, #4b5563 50%, #374151 75%);
    background-size: 200% 100%;
}

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

/* Loading screen animations */
@keyframes fadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.95);
    }
}

.loading-screen-exit {
    animation: fadeOut 0.5s ease-out forwards;
}

/* Enhanced logo glow */
@keyframes logoGlow {
    0%, 100% {
        box-shadow: 0 0 20px rgba(234, 171, 0, 0.3), 0 0 40px rgba(234, 171, 0, 0.2);
    }
    50% {
        box-shadow: 0 0 30px rgba(234, 171, 0, 0.5), 0 0 60px rgba(234, 171, 0, 0.3);
    }
}

.logo-glow {
    animation: logoGlow 2s ease-in-out infinite;
}

/* Improved mobile menu */
@media (max-width: 640px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

/* Better spacing for form elements on mobile */
@media (max-width: 640px) {
    form input,
    form select,
    form button {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* Dark mode datalist support */
.dark input[list]::-webkit-calendar-picker-indicator {
    filter: invert(1);
}

/* Dark mode date input support */
.dark input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
}

.dark input[type="color"] {
    cursor: pointer;
}

/* Theme toggle button animation */
#theme-toggle,
#theme-toggle-header {
    position: relative;
}

#theme-toggle i,
#theme-toggle-header i {
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Dark mode stats cards */
.dark .bg-blue-50 {
    background-color: #1e3a5f !important;
}

.dark .bg-green-50 {
    background-color: #1a3d2e !important;
}

.dark .bg-red-50 {
    background-color: #3d1a1a !important;
}

.dark .bg-yellow-50 {
    background-color: #3d351a !important;
}

/* Select elements dark mode fix */
.dark select {
    background-color: #374151 !important;
    color: #f3f4f6 !important;
    border-color: #4b5563 !important;
}

.dark select:focus {
    background-color: #4b5563 !important;
    border-color: #60a5fa !important;
}

/* Select option dark mode fix */
.dark select option {
    background-color: #374151 !important;
    color: #f3f4f6 !important;
}

/* Ensure select dropdowns are visible */
.dark select option:hover,
.dark select option:focus {
    background-color: #4b5563 !important;
}

/* Fix for select elements that might use different background classes */
.dark select.bg-gray-700,
.dark select.bg-gray-800 {
    background-color: #374151 !important;
}

/* Fix anagrafica list items and similar elements with dark backgrounds */
.dark .bg-gray-50,
.dark .bg-gray-100 {
    background-color: #374151 !important;
    border-color: #4b5563 !important;
}

.dark .bg-gray-50 *,
.dark .bg-gray-100 * {
    color: #f3f4f6 !important;
}

/* Ensure text in dark background elements is readable */
.dark .bg-gray-50 .text-gray-600,
.dark .bg-gray-100 .text-gray-600 {
    color: #d1d5db !important;
}

/* Fix hover states for anagrafica items */
.dark .bg-gray-50:hover,
.dark .bg-gray-100:hover {
    background-color: #4b5563 !important;
}

/* Fix autocomplete suggestions */
.dark .suggestion-item:hover {
    background-color: #4b5563 !important;
}

/* Fix table headers and rows */
.dark thead.bg-gray-100 {
    background-color: #374151 !important;
    border-color: #4b5563 !important;
}

.dark tbody tr.hover\:bg-gray-50:hover {
    background-color: #4b5563 !important;
}

/* Fix settings sector items */
.dark .bg-gray-50.rounded.border {
    background-color: #374151 !important;
    border-color: #4b5563 !important;
}

/* Fix any remaining bg-gray-300 elements */
.dark .bg-gray-300 {
    background-color: #4b5563 !important;
}

.dark .bg-gray-300:hover {
    background-color: #374151 !important;
}

/* Backdrop for modals in dark mode */
.dark .bg-black {
    background-color: rgba(0, 0, 0, 0.75) !important;
}

/* Better dark mode borders */
.dark .border-gray-300 {
    border-color: #4b5563;
}

.dark .border-gray-200 {
    border-color: #374151;
}

/* Fix white backgrounds in dark mode */
.dark input,
.dark select,
.dark textarea {
    background-color: #374151 !important;
    border-color: #4b5563 !important;
    color: #f3f4f6 !important;
}

.dark input::placeholder,
.dark textarea::placeholder {
    color: #9ca3af !important;
}

.dark input:focus,
.dark select:focus,
.dark textarea:focus {
    background-color: #4b5563 !important;
    border-color: #60a5fa !important;
}

/* Fix specific input types in dark mode */
.dark input[type="text"],
.dark input[type="password"],
.dark input[type="email"],
.dark input[type="number"],
.dark input[type="date"],
.dark input[type="time"],
.dark input[type="color"] {
    background-color: #374151 !important;
}

/* Fix form elements that might still have white backgrounds */
.dark .bg-white {
    background-color: #1f2937 !important;
}

.dark .bg-gray-50 {
    background-color: #111827 !important;
}

.dark .bg-gray-100 {
    background-color: #1f2937 !important;
}

/* Comprehensive dark mode text colors - HIGH PRIORITY */
.dark .text-gray-100 { color: #f3f4f6 !important; }
.dark .text-gray-200 { color: #e5e7eb !important; }
.dark .text-gray-300 { color: #d1d5db !important; }
.dark .text-gray-400 { color: #9ca3af !important; }
.dark .text-gray-500 { color: #6b7280 !important; }
.dark .text-gray-600 { color: #4b5563 !important; }
.dark .text-gray-700 { color: #374151 !important; }
.dark .text-gray-800 { color: #1f2937 !important; }
.dark .text-gray-900 { color: #111827 !important; }

.dark .text-black { color: #ffffff !important; }
.dark .text-white { color: #f3f4f6 !important; }

/* Force all text to be light in dark mode backgrounds */
.dark .bg-gray-700,
.dark .bg-gray-800,
.dark .bg-gray-900,
.dark .bg-black {
    color: #f3f4f6 !important;
}

.dark .bg-gray-700 *,
.dark .bg-gray-800 *,
.dark .bg-gray-900 *,
.dark .bg-black * {
    color: inherit !important;
}

/* Ensure headings have good contrast in dark mode */
.dark h1,
.dark h2,
.dark h3,
.dark h4,
.dark h5,
.dark h6 {
    color: #f9fafb !important;
}

/* Fix login screen text in dark mode */
.dark #login-screen h1,
.dark #login-screen h2,
.dark #login-screen p {
    color: #f9fafb !important;
}

/* Fix login form labels */
.dark #login-screen label {
    color: #e5e7eb !important;
}

/* Fix setup screen text */
.dark #setup-screen h1,
.dark #setup-screen p {
    color: #f9fafb !important;
}

/* Fix user interface elements in dark mode */
.dark #user-interface h1,
.dark #user-interface h2,
.dark #user-interface h3,
.dark #user-interface p,
.dark #user-interface span {
    color: #f9fafb !important;
}

/* Fix user interface form labels */
.dark #user-interface label {
    color: #e5e7eb !important;
}

/* Fix user interface warning messages */
.dark #deadline-warning {
    background-color: #7f1d1d !important;
    border-color: #dc2626 !important;
}

.dark #deadline-warning p,
.dark #deadline-warning div {
    color: #fca5a5 !important;
}

/* Fix user interface booking list */
.dark #user-bookings-list .bg-white {
    background-color: #1f2937 !important;
}

.dark #user-bookings-list .text-gray-600 {
    color: #d1d5db !important;
}

/* Fix user interface no bookings message */
.dark #no-bookings-message {
    color: #9ca3af !important;
}

/* Fix daily menu text contrast in dark mode */
.dark #daily-menu-display .text-gray-700 {
    color: #e5e7eb !important;
}

.dark #daily-menu-display h3 {
    color: #f9fafb !important;
}

/* Ensure labels and form text have good contrast */
.dark label {
    color: #e5e7eb !important;
}

/* Fix any remaining text issues */
.dark p,
.dark span,
.dark div {
    color: inherit;
}

/* Special fix for elements that might still have black text */
.dark * {
    color: inherit;
}

.dark .text-inherit {
    color: #f3f4f6 !important;
}

/* Improved table styling in dark mode */
.dark tbody tr:hover {
    background-color: #374151;
}

/* Better visibility for disabled elements in dark mode */
.dark button:disabled,
.dark input:disabled,
.dark select:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Loading screen smooth transition */
#loading-screen {
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

#loading-screen.hidden {
    opacity: 0;
    transform: scale(0.95);
    pointer-events: none;
}

/* Smooth page transitions */
#login-screen,
#setup-screen,
#main-app {
    transition: opacity 0.3s ease;
}

/* Icon transitions for theme toggle */
@keyframes rotateIn {
    from {
        transform: rotate(-180deg);
        opacity: 0;
    }
    to {
        transform: rotate(0deg);
        opacity: 1;
    }
}

.icon-rotate {
    animation: rotateIn 0.3s ease;
}

/* Responsive improvements */
@media (max-width: 640px) {
    #admin-nav {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    #admin-nav::-webkit-scrollbar {
        height: 0;
    }
}

/* Focus visible for accessibility */
button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.dark button:focus-visible,
.dark input:focus-visible,
.dark select:focus-visible {
    outline-color: #60a5fa;
}

/* Better color picker in dark mode */
.dark input[type="color"] {
    border: 2px solid #4b5563;
    background-color: #374151;
}

/* Enhanced shadow for cards in dark mode */
.dark .shadow-md {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.16);
}

.dark .shadow-lg {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.16);
}

.dark .shadow-xl {
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.14);
}

/* HIGH CONTRAST FIX FOR BATCH BOOKING CARDS IN DARK MODE */
.dark .employee-card .font-semibold,
.dark .employee-card .font-medium {
    color: #ffffff !important; /* Pure white for employee names */
}

.dark .employee-card .text-sm:not(.font-semibold):not(.font-medium) {
    color: #d1d5db !important; /* Light gray for secondary text like sector */
}

.dark .employee-card label {
    color: #e5e7eb !important; /* Light gray for labels */
}

.dark .employee-card select {
    background-color: #374151 !important;
    border-color: #4b5563 !important;
    color: #ffffff !important; /* Pure white text in selects */
}

.dark .employee-card select option {
    background-color: #374151 !important;
    color: #ffffff !important;
}

.dark .employee-card select:focus {
    border-color: #60a5fa !important;
    background-color: #4b5563 !important;
}

/* SLIDER TOGGLE SWITCH - AFFIDABILE E MOBILE FRIENDLY */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 56px;
    height: 32px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    border-radius: 32px;
    transition: 0.4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 24px;
    width: 24px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    border-radius: 50%;
    transition: 0.4s;
}

input:checked + .slider {
    background-color: #22c55e; /* Green when checked */
}

input:checked + .slider:before {
    transform: translateX(24px);
}

.toggle-switch:hover .slider {
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.2);
}

/* Dark mode for slider */
.dark .slider {
    background-color: #6b7280;
}

.dark input:checked + .slider {
    background-color: #22c55e; /* Same green in dark mode */
}
