/**
 * OrderFlow — Custom CSS
 * Minimal custom styles complementing Tailwind CSS.
 */

:root {
    color-scheme: light;
}

html.dark {
    color-scheme: dark;
}

/* ============================================================
   Custom Scrollbar
   ============================================================ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

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

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f1f5f9;
}

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

html.dark ::-webkit-scrollbar-thumb {
    background: #475569;
}

html.dark ::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

html.dark * {
    scrollbar-color: #475569 #111827;
}

/* ============================================================
   Dark Theme Overrides
   ============================================================ */
html.dark body {
    background-color: #030712 !important;
    color: #e5e7eb;
}

html.dark header,
html.dark aside {
    background-color: #111827 !important;
    border-color: #1f2937 !important;
}

html.dark main {
    background-color: #030712;
}

html.dark .theme-toggle-btn {
    background-color: #111827 !important;
    border-color: #374151 !important;
    color: #e5e7eb !important;
}

html.dark .theme-toggle-btn:hover {
    background-color: #1f2937 !important;
}

html.dark .bg-white {
    background-color: #111827 !important;
}

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

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

html.dark .bg-gray-200 {
    background-color: #374151 !important;
}

html.dark .bg-blue-50 {
    background-color: rgba(30, 64, 175, 0.2) !important;
}

html.dark .bg-green-50 {
    background-color: rgba(21, 128, 61, 0.18) !important;
}

html.dark .bg-red-50 {
    background-color: rgba(185, 28, 28, 0.18) !important;
}

html.dark .bg-yellow-50 {
    background-color: rgba(161, 98, 7, 0.18) !important;
}

html.dark .text-gray-900,
html.dark .text-gray-800,
html.dark .text-gray-700 {
    color: #f3f4f6 !important;
}

html.dark .text-gray-600,
html.dark .text-gray-500,
html.dark .text-gray-400 {
    color: #9ca3af !important;
}

html.dark .border-gray-100,
html.dark .border-gray-200,
html.dark .border-gray-300 {
    border-color: #374151 !important;
}

html.dark .hover\:bg-gray-50:hover {
    background-color: #1f2937 !important;
}

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

html.dark .hover\:text-gray-900:hover {
    color: #f9fafb !important;
}

html.dark .focus\:bg-white:focus {
    background-color: #111827 !important;
}

html.dark .focus\:border-blue-300:focus {
    border-color: #60a5fa !important;
}

html.dark .shadow-sm,
html.dark .shadow-lg,
html.dark .shadow-xl {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35) !important;
}

html.dark #search-overlay {
    background-color: rgba(0, 0, 0, 0.6) !important;
}

/* ============================================================
   Transition Animations
   ============================================================ */
.fade-in {
    animation: fadeIn 0.2s ease-in-out;
}

.slide-in-top {
    animation: slideInTop 0.2s ease-out;
}

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

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

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

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

/* ============================================================
   HTMX Loading State
   ============================================================ */
.htmx-request {
    opacity: 0.6;
    pointer-events: none;
    cursor: wait;
}

.htmx-indicator {
    opacity: 0;
    transition: opacity 0.2s ease-in;
}

.htmx-request .htmx-indicator {
    opacity: 1;
}

/* ============================================================
   Table Styles
   ============================================================ */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    padding: 0.75rem 1rem;
    background-color: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}

html.dark .data-table th {
    color: #9ca3af;
    background-color: #111827;
    border-bottom: 1px solid #374151;
}

.data-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.data-table th.sortable:hover {
    background-color: #f3f4f6;
    color: #374151;
}

.data-table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid #f3f4f6;
    color: #374151;
    font-size: 0.875rem;
}

html.dark .data-table td {
    color: #e5e7eb;
    border-bottom: 1px solid #1f2937;
}

.data-table tbody tr:hover {
    background-color: #f9fafb;
}

html.dark .data-table tbody tr:hover {
    background-color: #111827;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* ============================================================
   Form Styles
   ============================================================ */
.form-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    line-height: 1.5;
    color: #111827;
    background-color: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

html.dark .form-input {
    color: #f3f4f6;
    background-color: #111827;
    border-color: #374151;
}

html.dark .form-input::placeholder {
    color: #9ca3af;
}

html.dark .form-input:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.15);
}

.form-input.error {
    border-color: #ef4444;
}

.form-input.error:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* ============================================================
   Chat Interface
   ============================================================ */
.chat-message {
    animation: slideInBottom 0.2s ease-out;
}

.chat-message.user {
    margin-left: auto;
}

.chat-message.assistant {
    margin-right: auto;
}

/* ============================================================
   Order Preview Card
   ============================================================ */
.order-preview-card {
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

html.dark .order-preview-card {
    border-color: #374151;
    background: #111827;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

/* ============================================================
   Status Badge
   ============================================================ */
.status-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
    padding: 0.25rem 0.625rem;
    white-space: nowrap;
}

/* ============================================================
   Sidebar Active Link
   ============================================================ */
.nav-link-active {
    background-color: #eff6ff;
    color: #1d4ed8;
    font-weight: 600;
}

html.dark .nav-link-active {
    background-color: rgba(30, 64, 175, 0.22);
    color: #93c5fd;
}

/* ============================================================
   Print Styles
   ============================================================ */
@media print {
    header,
    aside,
    #flash-messages {
        display: none !important;
    }

    main {
        margin: 0 !important;
        padding: 1rem !important;
    }
}
