body {
    font-family: 'Cairo', sans-serif;
    background-color: #f8fafc;
    transition: background-color 0.3s ease, color 0.3s ease;
}
/* مظهر كلاسيكي منظم بلمسة مترو */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
    background: #10b981;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #059669;
}

.metro-tile {
    transition: all 0.2s ease-in-out;
}
.metro-tile:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

/* Dark Mode Custom Overrides */
html.dark {
    background-color: #090d16;
    color: #f8fafc;
}
html.dark body {
    background-color: #090d16;
    color: #f8fafc;
}

/* Modals and Cards */
html.dark .bg-white,
html.dark .bg-slate-50,
html.dark .bg-slate-100/50,
html.dark .bg-slate-100 {
    background-color: #131926 !important;
    color: #f8fafc !important;
}

/* Inputs, Selects, Textareas */
html.dark input,
html.dark select,
html.dark textarea {
    background-color: #0b0f19 !important;
    border-color: #1e293b !important;
    color: #ffffff !important;
}

html.dark input:focus,
html.dark select:focus,
html.dark textarea:focus {
    outline: none;
    border-color: #10b981 !important;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

/* Borders */
html.dark .border,
html.dark .border-slate-100,
html.dark .border-slate-200,
html.dark .border-slate-300,
html.dark .border-slate-250,
html.dark .border-gray-100,
html.dark .border-gray-200,
html.dark .divide-y > *,
html.dark .divide-slate-100 > :not([hidden]) ~ :not([hidden]) {
    border-color: #1e293b !important;
}

/* Text colors */
html.dark .text-slate-800,
html.dark .text-slate-900,
html.dark .text-slate-700,
html.dark .text-slate-600,
html.dark .text-slate-500,
html.dark .text-gray-800,
html.dark .text-gray-900,
html.dark .text-gray-700,
html.dark .text-gray-600,
html.dark .text-gray-500 {
    color: #f8fafc !important;
}

html.dark .text-slate-400,
html.dark .text-gray-400 {
    color: #94a3b8 !important;
}

/* Hover states in dark mode */
html.dark .hover\:bg-slate-50:hover,
html.dark .hover\:bg-slate-100:hover,
html.dark .hover\:bg-gray-50:hover,
html.dark tr:hover {
    background-color: #1c2536 !important;
}

/* Top Header specifically */
html.dark header.bg-white {
    background-color: #131926 !important;
    border-bottom: 1px solid #1e293b !important;
}

html.dark header button.text-slate-600 {
    color: #f8fafc !important;
}

html.dark header button.text-slate-600:hover {
    background-color: #1c2536 !important;
}

/* Sidebar overrides */
html.dark aside#sidebar {
    background-color: #0b0e14 !important;
    border-left: 1px solid #1e293b !important;
}

html.dark aside#sidebar .bg-emerald-950 {
    background-color: #06080c !important;
}

html.dark aside#sidebar .menu-btn {
    color: #94a3b8 !important;
}

html.dark aside#sidebar .menu-btn:hover {
    background-color: #131926 !important;
    color: #f8fafc !important;
}

html.dark aside#sidebar .menu-btn.bg-slate-800 {
    background-color: #1c2536 !important;
    color: #ffffff !important;
}

/* POS and tables */
html.dark table thead th {
    background-color: #0b0f19 !important;
    color: #94a3b8 !important;
    border-bottom: 2px solid #1e293b !important;
}

html.dark .bg-slate-100 {
    background-color: #0b0f19 !important;
}

html.dark #pos-autocomplete-results,
html.dark #purchase-autocomplete-results {
    background-color: #131926 !important;
    border: 1px solid #1e293b !important;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

html.dark #pos-autocomplete-results > div,
html.dark #purchase-autocomplete-results > div {
    border-bottom: 1px solid #1e293b !important;
    color: #f8fafc !important;
}

html.dark #pos-autocomplete-results > div:hover,
html.dark #purchase-autocomplete-results > div:hover {
    background-color: #1c2536 !important;
}

html.dark .bg-emerald-50\/40 {
    background-color: rgba(16, 185, 129, 0.05) !important;
}

html.dark .bg-slate-900\/50 {
    background-color: rgba(0, 0, 0, 0.7) !important;
}

.glass-card {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.04);
    transition: all 0.3s ease;
}
html.dark .glass-card {
    background: rgba(19, 25, 38, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.25);
}

html.dark ::-webkit-scrollbar-track {
    background: #0b0f19;
}
html.dark ::-webkit-scrollbar-thumb {
    background: #10b981;
}
html.dark ::-webkit-scrollbar-thumb:hover {
    background: #059669;
}

.transition-all {
    transition-property: all;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 200ms;
}

.no-scrollbar::-webkit-scrollbar {
    display: none;
}
.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Keep every large section scrollable inside the fixed app shell. */
#main-app-layout {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
}

#main-app-layout > .flex-1,
#main-content {
    min-height: 0;
}

#main-content {
    overflow-y: auto !important;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

#main-content > [id^="tab-"] {
    min-height: 0;
    padding-bottom: 1rem;
}

#tab-pos > .flex,
#tab-purchases > .flex,
#tab-banner_calc > .grid,
#tab-sticker_calc > .grid {
    min-height: 0;
    overflow: auto !important;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 1279px) {
    #tab-pos > .flex,
    #tab-purchases > .flex,
    #tab-banner_calc > .grid,
    #tab-sticker_calc > .grid {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }
}

@media (min-width: 1280px) {
  #tab-pos > .flex,
  #tab-purchases > .flex {
    max-height: calc(100vh - 120px);
    max-height: calc(100dvh - 120px);
  }
}

/* Task management has long boards and a dense edit modal; keep both usable. */
#tab-tasks.task-workspace {
  max-width: 100%;
}

#tab-tasks .task-stat-card {
  min-height: 88px;
  border-radius: 14px;
}

#tab-tasks .task-toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
}

#tab-tasks select,
#tab-tasks input,
#tab-tasks button {
  min-height: 38px;
}

#tab-tasks #tasks-list-view {
  min-height: 360px;
}

#tab-tasks #tasks-list-view table {
  min-width: 980px;
}

#tab-tasks #tasks-list-view thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

#tab-tasks #tasks-list-view th,
#tab-tasks #tasks-list-view td {
  white-space: nowrap;
}

#tab-tasks #tasks-list-view td:first-child,
#tab-tasks #tasks-list-view th:first-child {
  min-width: 260px;
  white-space: normal;
}

#tab-tasks .task-empty-state {
  min-height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  background: rgba(248, 250, 252, 0.75);
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

#task-modal > .bg-white {
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  display: flex;
  flex-direction: column;
}

#task-modal form {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#tab-tasks #tasks-kanban-view > div {
  min-height: 360px;
}

#tab-tasks #kanban-pending,
#tab-tasks #kanban-progress,
#tab-tasks #kanban-completed {
  min-height: 0;
}

@media (min-width: 768px) {
  #tab-tasks #tasks-kanban-view > div {
    max-height: calc(100vh - 330px);
    max-height: calc(100dvh - 330px);
  }
}

@media (max-width: 767px) {
  #tab-tasks .task-toolbar {
    position: static;
  }

  #tab-tasks .task-stat-card {
    min-height: 76px;
  }

  #tab-tasks #tasks-kanban-view > div {
    max-height: none;
  }
}

@media print {
    /* Hide the sidebar, background overlays, action buttons and everything else */
    body * {
        visibility: hidden !important;
    }

    /* Make sure the invoice print area and all its children are visible */
    #invoice-detail-modal,
    #invoice-detail-modal *,
    #ledger-modal,
    #ledger-modal * {
        visibility: visible !important;
    }

    /* Make the modal container full page and remove absolute centering/shadows */
    #invoice-detail-modal,
    #ledger-modal {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        height: auto !important;
        padding: 0 !important;
        margin: 0 !important;
        background: white !important;
        display: block !important;
        z-index: 99999 !important;
        box-shadow: none !important;
    }

    /* Remove the card container restrictions, borders, shadows, rounded corners */
    #invoice-detail-modal > div,
    #ledger-modal > div {
        width: 100% !important;
        max-width: 100% !important;
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        margin: 0 !important;
        padding: 0 !important;
        background: white !important;
        height: auto !important;
        max-height: none !important;
    }

    /* Format the print area to take 100% width and display completely */
    #invoice-print-area,
    #ledger-print-area {
        width: 100% !important;
        padding: 10px !important;
        margin: 0 !important;
        max-height: none !important;
        overflow: visible !important;
        box-sizing: border-box !important;
    }
}
