/* CSS Variables */
:root {
  --bg-color: #1a1e29;
  --panel-bg: #222736;
  --text-color: #f1f5f9;
  --accent: #9c27b0;
  --accent-hover: #7b1fa2;
  --sidebar-w: 250px;
  --border: #333a4d;
  --danger: #e74c3c;
  --success: #2ecc71;
  --warning: #f1c40f;
  --text-primary: #ffffff;
  --text-secondary: #9a9a9a;
}

/* Odoo Theme Variables */
:root.theme-odoo {
  --bg-color: #f4f5f7;
  --panel-bg: #ffffff;
  --surface: #ffffff;
  --text-color: #4a4a4a;
  --accent: #714B67;
  --accent-hover: #875A7B;
  --border: #e0e2e6;
  --text-primary: #212529;
  --text-secondary: #6c757d;
  --text-muted: #6c757d;
  --sidebar-bg: #714B67;
  --sidebar-text: #ffffff;
  --primary: #017E84;
}

:root.theme-odoo .sidebar {
  background-color: var(--sidebar-bg);
  color: var(--sidebar-text);
}
:root.theme-odoo .sidebar a,
:root.theme-odoo .nav-menu li,
:root.theme-odoo .nav-group-header, 
:root.theme-odoo .user-info span {
  color: var(--sidebar-text) !important;
}

:root.theme-odoo .nav-menu li.active {
  background: rgba(255, 255, 255, 0.2) !important;
  border-right-color: #fff !important;
}
:root.theme-odoo table th {
  background: #f1f5f9;
  color: #1e293b;
  border-bottom: 2px solid #cbd5e1;
}
:root.theme-odoo .login-box input,
:root.theme-odoo .modal-content input,
:root.theme-odoo .modal-content select {
  background: #ffffff;
  color: #212529;
}
:root.theme-odoo .btn-primary {
  background: var(--primary);
}

#loading-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(15, 12, 41, 0.9); z-index: 10000;
  display: none; flex-direction: column; justify-content: center; align-items: center;
  backdrop-filter: blur(5px); color: white;
}
.loader {
  border: 5px solid rgba(255, 255, 255, 0.1); border-top: 5px solid var(--accent);
  border-radius: 50%; width: 50px; height: 50px;
  animation: spin 1s linear infinite; margin-bottom: 20px;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

button {
  font-family: 'Cairo', sans-serif;
  cursor: pointer;
}

body {
  font-family: 'Cairo', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  overflow: hidden;
}

/* Screens */
.screen {
  display: none;
  width: 100vw;
  height: 100vh;
}
.screen.active {
  display: flex;
}

/* Login */
#login-screen {
  justify-content: center;
  align-items: center;
}
.login-box {
  background: var(--panel-bg);
  padding: 40px;
  border-radius: 12px;
  width: 350px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  text-align: center;
}
.login-box h2 {
  margin-bottom: 20px;
}
.login-box input {
  width: 100%;
  padding: 12px;
  margin-bottom: 15px;
  border: 1px solid var(--border);
  background: var(--bg-color);
  color: var(--text-primary);
  border-radius: 6px;
  font-family: 'Cairo';
}
.login-box input:focus {
  outline: none;
  border-color: var(--accent);
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Cairo';
  font-weight: bold;
  transition: 0.3s;
}
.btn-primary:hover {
  background: var(--accent-hover);
}
.btn-secondary {
  padding: 12px;
  background: #555;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

/* App Layout */
.sidebar {
  width: var(--sidebar-w);
  background: var(--panel-bg);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.sidebar::-webkit-scrollbar {
  display: none;
}
.brand {
  padding: 20px;
  font-size: 24px;
  font-weight: 800;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.user-info {
  padding: 5px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.badge {
  background: var(--accent);
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 12px;
}
.nav-menu {
  list-style: none;
  padding: 10px 0;
}
.nav-menu li {
  padding: 15px 20px;
  cursor: pointer;
  transition: 0.2s;
}
.nav-menu li:hover {
  background: rgba(255, 255, 255, 0.05);
}
.nav-menu li.active {
  background: rgba(156, 39, 176, 0.15) !important;
  border-right: 4px solid var(--accent) !important;
  color: #fff !important;
  font-weight: bold;
}
.nav-menu li.nav-group {
  padding: 0;
  border-right: none;
}
.nav-menu li.nav-group:hover, .nav-menu li.nav-group.active {
  background: transparent;
  border-right: none;
}
.nav-group-header {
  padding: 12px 20px;
  cursor: pointer;
  font-weight: bold;
  color: var(--text-color);
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.nav-group-header:hover {
  background: rgba(255,255,255,0.08);
}
.nav-group-header::after {
  content: '▼';
  font-size: 10px;
  transition: transform 0.2s;
}
.nav-group.expanded .nav-group-header::after {
  transform: rotate(180deg);
}
.hr-link::after {
  content: none !important;
}
.nav-group-items {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
  background: rgba(0,0,0,0.2);
}
.nav-group.expanded .nav-group-items {
  max-height: 1000px;
}
.nav-group-items li {
  padding: 10px 30px !important;
  border-bottom: 1px solid rgba(255,255,255,0.02);
  font-size: 14px;
}
.text-danger {
  color: var(--danger);
  margin-top: auto;
}

.main-content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

/* Views */
.view { display: none; }
.view.active { display: block; }

.header-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}
.header-actions button {
  width: auto;
  padding: 8px 16px;
}

/* Dashboard */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
.stat-card {
  background: var(--panel-bg);
  padding: 20px;
  border-radius: 10px;
  text-align: center;
}
.stat-card p {
  font-size: 32px;
  font-weight: bold;
  color: var(--accent);
  margin-top: 10px;
}

/* Tables */
.table-container {
  background: var(--panel-bg);
  border-radius: 10px;
  overflow-x: auto;
}
.excel-table {
  width: 100%;
  border-collapse: collapse;
}
.excel-table th, .excel-table td {
  padding: 12px 15px;
  text-align: right;
  border-bottom: 1px solid var(--border);
}
.excel-table th {
  background: rgba(0,0,0,0.2);
  color: var(--text-secondary);
}
.excel-table tbody tr:hover {
  background: rgba(255,255,255,0.05);
}

/* Modals */
.modal {
  display: none;
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.7);
  justify-content: center;
  align-items: center;
  z-index: 999999 !important;
}
.modal.active {
  display: flex;
}
.modal-content {
  max-height: 90vh;
  overflow-y: auto;
  background: var(--panel-bg);
  padding: 30px;
  border-radius: 10px;
  width: 400px;
}
.modal-content h3 { margin-bottom: 20px; }
.modal-content input, .modal-content select {
  width: 100%;
  padding: 10px;
  margin-bottom: 15px;
  background: var(--bg-color);
  border: 1px solid var(--border);
  color: white;
  font-family: 'Cairo';
  border-radius: 5px;
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.modal-actions button { width: auto; }

/* Print Styles */
@media print {
  body {
    background: white;
    color: black;
    overflow: visible;
  }
  .sidebar, .header-actions, .modal-actions, .nav-menu {
    display: none !important;
  }
  .screen, .main-content, .view {
    display: none !important;
  }
  
  /* When printing, we only show the #print-area */
  #print-area {
    display: block !important;
    width: 100%;
    margin: 0;
    padding: 0;
  }
  .print-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    margin-bottom: 40px;
  }
  .print-table th, .print-table td {
    border: 1px solid #000;
    padding: 8px;
    text-align: right;
  }
  .print-header {
    text-align: center;
    margin-bottom: 30px;
    border-bottom: 2px solid #000;
    padding-bottom: 10px;
  }
  .print-signatures {
    display: flex;
    justify-content: space-between;
    margin-top: 50px;
  }
  .print-signatures div {
    text-align: center;
    border-top: 1px solid #000;
    width: 200px;
    padding-top: 5px;
  }
}

/* Data Table inside Modals */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
  background: var(--bg-color);
  color: var(--text-color);
}
.data-table th, .data-table td {
  border: 1px solid rgba(255,255,255,0.1);
  padding: 8px 12px;
  text-align: right;
}
.data-table th {
  background: rgba(255,255,255,0.05);
  font-weight: bold;
}
.data-table tr:hover {
  background: rgba(255,255,255,0.02);
}
.data-table input[type="text"], .data-table input[type="number"] {
  width: 100%;
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.1);
  color: #fff;
  padding: 5px;
  border-radius: 4px;
}

/* Form Grid */
.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 15px;
}
@media (min-width: 768px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
}
.form-group label {
  display: block;
  margin-bottom: 5px;
}


/* Hide number input spin buttons */
input[type=number]::-webkit-inner-spin-button, 
input[type=number]::-webkit-outer-spin-button { 
  -webkit-appearance: none; 
  margin: 0; 
}
input[type=number] {
  -moz-appearance: textfield;
}

/* Mobile Responsiveness Chrome Robust */
@media (max-width: 768px) {
  body {
    overflow: auto !important;
    overflow-x: hidden !important;
  }
  .screen {
    height: auto !important;
    min-height: 100vh;
    min-height: -webkit-fill-available;
    max-width: 100vw;
    overflow-x: hidden;
  }
  .screen.active {
    flex-direction: column;
  }
  .mobile-only {
    display: flex !important;
  }
  .sidebar {
    width: 280px;
    height: 100vh;
    border-right: none;
    border-left: 1px solid rgba(255,255,255,0.1);
    flex: none;
    position: fixed;
    top: 0;
    right: -300px; /* Hidden off-screen for RTL */
    z-index: 9999;
    background: var(--panel-bg);
    transition: right 0.3s ease;
    overflow-y: auto;
    padding-bottom: 20px;
  }
  .sidebar.mobile-open {
    right: 0;
  }
  .brand, .user-info {
    display: block !important;
  }
  .main-content {
    overflow-y: visible !important;
    height: auto !important;
    max-width: 100vw;
    overflow-x: hidden;
  }
  .nav-menu {
    display: block;
    overflow-x: hidden;
    padding: 0;
    white-space: normal;
  }
  .nav-group-header {
    display: flex !important;
  }
  .nav-menu li.nav-group, .nav-group-items {
    display: block !important;
  }
  .nav-menu li, .nav-group-items li {
    border-bottom: none !important;
    padding: 12px 20px !important;
  }
  .nav-menu li.active, .nav-group-items li.active {
    border-bottom: none !important;
    border-right: 4px solid var(--accent) !important;
    background: rgba(156, 39, 176, 0.15) !important;
  }
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .header-actions {
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 10px;
  }
  .header-actions button {
    width: 100%;
    margin-bottom: 5px;
  }
  .login-box {
    width: 90%;
    margin: 20px auto;
  }
  .modal-content {
    width: 92vw !important;
    max-width: 92vw !important;
    padding: 15px !important;
    margin: 10px auto !important;
    box-sizing: border-box !important;
  }
  .form-group {
    display: flex;
    flex-direction: column;
  }
  .form-group > div,
  .form-group > label {
    flex: none !important;
    width: 100% !important;
    max-width: 100% !important;
    margin-bottom: 10px;
    box-sizing: border-box;
  }
  .flex-row,
  .item-card-filters,
  .item-card-stats {
    flex-wrap: wrap !important;
    height: auto !important;
    gap: 12px !important;
  }
  .flex-row > div,
  .flex-col,
  #view-item-card .item-card-filters > div,
  #view-item-card .item-card-stats > div {
    flex: 1 1 100% !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 100% !important;
    margin-bottom: 6px !important;
    box-sizing: border-box !important;
  }
  .table-container {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  .excel-table th, .excel-table td,
  .data-table th, .data-table td {
    padding: 8px 5px !important;
    font-size: 12px;
  }
}

/* Improve Action Buttons Size */
.theme-odoo table td button, 
.theme-odoo table td .action-btn, 
.theme-odoo table td .btn-delete, 
.theme-odoo table td .btn-pay {
    padding: 4px 8px !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    border-radius: 4px !important;
    margin-bottom: 3px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
}

/* If they are in a flex column container, make them uniform width */
.theme-odoo table th,
.theme-odoo table td {
    font-size: 13px !important;
    padding: 6px 10px !important;
    vertical-align: middle !important;
}


/* Hover Interactions for Sidebar Tabs */
.nav-group-items li {
  transition: all 0.2s ease !important;
}
.nav-group-items li:hover {
  background: rgba(255,255,255,0.15) !important;
  transform: translateX(-5px);
  cursor: pointer;
}
:root.theme-odoo .nav-group-items li:hover {
  background: rgba(0,0,0,0.2) !important;
}

/* Enhanced Hover Effects */
.nav-group-header { transition: all 0.2s ease !important; }
.nav-group-header:hover { background: rgba(255,255,255,0.1) !important; color: var(--accent) !important; padding-right: 25px !important; }
.nav-menu li:hover { color: var(--accent) !important; }
.rm-link a { transition: all 0.2s ease !important; }
.rm-link a:hover { background: rgba(255,255,255,0.1) !important; color: var(--accent) !important; padding-right: 25px !important; }
.nav-group-items li:hover { color: var(--accent) !important; }

/* Fix RM and HR links to match headers */
.rm-link a, .hr-link a { background: rgba(255,255,255,0.02); display: flex !important; align-items: center; transition: all 0.2s ease !important; }
.rm-link a:hover, .hr-link a:hover { background: rgba(255,255,255,0.1) !important; color: var(--accent) !important; padding-right: 25px !important; }




@media (max-width: 768px) {
  .desktop-sidebar-toggle {
    display: none !important;
  }
}

:root.theme-odoo #mobile-header div {
    color: var(--primary) !important;
}
:root.theme-odoo #mobile-header button {
    color: var(--primary) !important;
}

/* Custom wide layout for User Modal and Light Theme fixes */
#user-modal .modal-content {
    max-width: 950px !important;
    width: 95% !important;
}
#user-modal h3 {
    margin-bottom: 25px;
    border-bottom: 2px solid var(--primary);
    padding-bottom: 10px;
}
.theme-odoo #user-modal label {
    color: var(--text-color) !important;
}










/* Sidebar Links (Pages) */
:root.theme-odoo .nav-menu li:not(.nav-group), 
:root.theme-odoo .nav-group-items li {
    padding: 12px 20px !important;
    padding-right: 30px !important; /* Indent child items */
    color: rgba(255,255,255,0.7) !important;
    font-size: 13.5px !important;
    font-weight: 500 !important;
    border-right: 3px solid transparent !important;
    transition: background 0.2s ease, color 0.2s ease !important;
}

/* Active State */
:root.theme-odoo .nav-menu li.active:not(.nav-group), 
:root.theme-odoo .nav-group-items li.active {
    background: rgba(255, 255, 255, 0.1) !important;
    color: #fff !important;
    font-weight: bold !important;
    border-right: 3px solid #fff !important;
}

/* Hover State */
:root.theme-odoo .nav-menu li:not(.nav-group):hover, 
:root.theme-odoo .nav-group-items li:hover {
    background: rgba(255, 255, 255, 0.05) !important;
    color: #fff !important;
}





/* Elegant White-Alpha Sidebar Design for theme-odoo */

/* 1. Headers (العناوين) */
:root.theme-odoo .nav-group-header {
    background: transparent !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-top: none !important;
    color: #ffffff !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    padding: 12px 20px !important;
    transition: background 0.2s ease !important;
}

:root.theme-odoo .nav-group-header:hover {
    background: rgba(0, 0, 0, 0.1) !important;
}

/* 2. Inactive Pages (باقي الصفحات) */
:root.theme-odoo .nav-menu li:not(.nav-group), 
:root.theme-odoo .nav-group-items li {
    padding: 12px 20px !important;
    padding-right: 35px !important; 
    color: rgba(255, 255, 255, 0.65) !important; /* Soft white */
    font-size: 13.5px !important;
    font-weight: 500 !important;
    border-right: 4px solid transparent !important;
    background: transparent !important;
    transition: all 0.2s ease !important;
}

/* Hover over inactive pages */
:root.theme-odoo .nav-menu li:not(.nav-group):hover, 
:root.theme-odoo .nav-group-items li:hover {
    background: rgba(255, 255, 255, 0.15) !important; /* Brightens cleanly */
    color: #ffffff !important;
}

/* 3. Active Page (الصفحة المختارة) */
:root.theme-odoo .nav-menu li.active:not(.nav-group), 
:root.theme-odoo .nav-group-items li.active {
    background: rgba(255, 255, 255, 0.25) !important; /* Most prominent */
    color: #ffffff !important;
    font-weight: 700 !important;
    border-right: 4px solid #ffffff !important;
}


/* Harmonious Standalone Links (HR & Ready Mix) */
:root.theme-odoo .rm-link a, 
:root.theme-odoo .hr-link a {
    background: transparent !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: #ffffff !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    padding: 12px 20px !important;
    transition: background 0.2s ease !important;
    display: block !important;
    text-decoration: none !important;
}

:root.theme-odoo .rm-link a:hover, 
:root.theme-odoo .hr-link a:hover {
    background: rgba(0, 0, 0, 0.1) !important;
}


/* Ensure Action Buttons stay in one row */
table.data-table td:last-child, 
table.excel-table td:last-child {
    white-space: nowrap !important;
}
.action-btn {
    white-space: nowrap !important;
    display: inline-block !important;
    margin-bottom: 0 !important;
}





/* Custom Dark Highlights for Active Page and Active Header */

/* The Active Group Header (عنوان المجموعة المفتوحة) - لون غامق */
:root.theme-odoo .nav-group:has(.nav-group-items li.active) .nav-group-header,
:root.theme-odoo .nav-group-header.active-header {
    background: #1e293b !important; /* Distinct Dark Slate/Navy */
    color: #ffffff !important;
    border-right: 4px solid rgba(255, 255, 255, 0.5) !important;
}

/* The Active Page (الصفحة المختارة) - نفس اللون درجة أقل */
:root.theme-odoo .nav-menu li.active:not(.nav-group), 
:root.theme-odoo .nav-group-items li.active {
    background: #334155 !important; /* Lighter shade of Slate */
    color: #ffffff !important;
    font-weight: bold !important;
    border-right: 4px solid #ffffff !important;
}

/* Standalone active link (like Ready Mix, HR) */
:root.theme-odoo .rm-link.active a, 
:root.theme-odoo .hr-link.active a {
    background: #1e293b !important; /* Standalone gets the dark header color */
    border-right: 4px solid #ffffff !important;
}


/* Force right alignment for standalone links to match headers */
:root.theme-odoo .rm-link a, 
:root.theme-odoo .hr-link a {
    text-align: right !important;
}


/* Fix standalone links padding to exactly match normal headers */
:root.theme-odoo .rm-link, 
:root.theme-odoo .hr-link {
    padding-right: 0 !important; /* Remove the 35px indent applied to child items */
    padding-left: 0 !important;
}

:root.theme-odoo .rm-link a, 
:root.theme-odoo .hr-link a {
    padding: 12px 20px !important; /* Exact match to .nav-group-header */
    text-align: right !important;
    display: block !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

/* ===== Odoo/Light Theme: Data Table & Abstract Table Fixes ===== */
:root.theme-odoo .data-table {
    background: #ffffff;
    color: #333333;
}
:root.theme-odoo .data-table th,
:root.theme-odoo .data-table td {
    border: 1px solid #dee2e6 !important;
    color: #333333;
}
:root.theme-odoo .data-table th {
    background: #e9ecef !important;
    color: #212529 !important;
}
:root.theme-odoo .data-table tr:hover {
    background: #f1f3f5 !important;
}
:root.theme-odoo .data-table td input,
:root.theme-odoo .data-table td span {
    color: #333333 !important;
}
:root.theme-odoo .data-table td input {
    background: transparent !important;
}
:root.theme-odoo .data-table .ab-item-curr-val {
    color: var(--primary) !important;
}
:root.theme-odoo .data-table .ab-item-accum-val {
    color: #2e7d32 !important;
}
:root.theme-odoo .data-table .ab-item-accum-qty {
    color: #e65100 !important;
}
:root.theme-odoo .data-table .ab-item-curr-qty {
    border: 1px solid var(--primary) !important;
    background: #f0fafa !important;
    color: #333333 !important;
}
