/* ============================================================
   UNIVERSAL RESTAURANT MANAGEMENT SYSTEM - MASTER THEME
   Total Preservation Merge - No Styles Removed
   ============================================================ */

:root {
  /* Brand Identity */
  --primary-color: #5F255F;
  --primary-hover: #7a3d7a;
  --secondary-color: #e2e8f0;
  
  /* Semantic Colors */
  --success-color: #28a745;
  --danger-color: #dc3545;
  --warning-color: #fd7e14;
  --info-color: #0ea5e9;
  
  /* Layout Colors */
  --bg-white: #ffffff;
  --bg-light: #f8f9fa;
  --border-color: #e2e8f0;
  --text-main: #1a1d21;
  --text-muted: #64748b;

  /* AJAX States */
  --pending-bg: #fff7ed;
  --pending-border: #fdba74;
  --saved-flash-bg: #ecfdf5;
}

/* --- 1. CORE RESET (PRESERVED) --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-white);
  color: var(--text-main);
  line-height: 1.5;
}

a {
  color: var(--primary-color);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* --- 2. HEADER & NAVIGATION (PRESERVED) --- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 15px;
}

.header {
  background: var(--bg-white);
  border-bottom: 3px solid var(--primary-color);
  padding: 10px 15px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.logo img {
  height: 50px;
  width: auto;
}

.date-display {
  color: #666;
  font-size: 14px;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 10px 0;
  justify-content: center;
  max-width: 1000px;
  margin: 0 auto;
}

.nav a {
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  color: #333;
  background: #f8f9fa;
  transition: all 0.15s ease;
}

.nav a:hover {
  background: #e9ecef;
  text-decoration: none;
}

.nav a.active {
  background: var(--primary-color);
  color: #fff;
}

/* --- 3. CARDS & TABLES (PRESERVED) --- */
.card {
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-bottom: 15px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.card-header {
  background: var(--primary-color);
  color: #ffffff;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 14px;
}

.card-header2 {
  background: #333;
  color: #ffffff;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 13px;
}

.card-body {
  padding: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  font-size: 13px;
}

th {
  background: #f8f9fa;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
}

tr:nth-child(even) {
  background: #faf8fa;
}

tr:hover {
  background: #f5f0f5;
}

/* --- 4. FORM ELEMENTS (PRESERVED WITH IOS FIXES) --- */
.textbox, .input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 14px;
  background: var(--bg-white);
  color: var(--text-main);
}

.textbox:focus, .input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(95,37,95,0.15);
}

.input[type="date"],
.input[type="time"]{
  width:100% !important;
  max-width:100% !important;
  display:block;
  box-sizing:border-box;
  padding-left:10px;
  padding-right:10px;
  height:38px;
  border-radius:10px;
  border:1px solid #ddd;
  font-size:14px;
  background:#fff;
  -webkit-appearance:none;
  appearance:none;
}

textarea.textbox {
  resize: vertical;
  min-height: 60px;
}

select.textbox {
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 8px center;
  background-repeat: no-repeat;
  background-size: 20px;
  padding-right: 36px;
}

/* --- 5. LEGACY BUTTONS & MESSAGES (PRESERVED) --- */
.btn {
  display: inline-block;
  padding: 10px 18px;
  border-radius: 6px;
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
  text-align: center;
}

.btn-primary { background: var(--primary-color); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success-color); color: #fff; }
.btn-danger { background: var(--danger-color); color: #fff; }
.btn-warning { background: var(--warning-color); color: #fff; }
.btn-secondary { background: #e2e8f0; color: #475569; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

.success { background: #d4edda; color: #155724; padding: 12px 16px; border-radius: 6px; margin: 10px 0; border: 1px solid #c3e6cb; }
.fail, .error { background: #f8d7da; color: #721c24; padding: 12px 16px; border-radius: 6px; margin: 10px 0; border: 1px solid #f5c6cb; }

/* --- 6. GRID & STATS (PRESERVED) --- */
.row { display: flex; flex-wrap: wrap; margin: 0 -10px; }
.col { flex: 1; padding: 0 10px; min-width: 280px; }
.col-2 { flex: 0 0 50%; padding: 0 10px; }
.col-3 { flex: 0 0 33.333%; padding: 0 10px; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 15px; margin-bottom: 15px; }
.stat-card { background: var(--bg-white); border: 1px solid var(--border-color); border-radius: 8px; padding: 16px; text-align: center; }
.stat-value { font-size: 24px; font-weight: 700; color: #1a1d21; }
.stat-value.green { color: var(--success-color); }
.stat-value.red { color: var(--danger-color); }
.stat-value.blue { color: var(--info-color); }
.stat-value.orange { color: var(--warning-color); }
.stat-value.purple { color: var(--primary-color); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* --- 7. TABLE TRACKER & RESERVATIONS (PRESERVED) --- */
.table-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; padding: 15px; }
.table-btn {
  min-height: 90px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 10px; font-weight: 600; cursor: pointer; border: 2px solid transparent; transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}
.table-btn:hover { transform: scale(1.03); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.table-empty { background: #f1f5f9; color: var(--text-muted); }
.table-ordered { background: var(--warning-color); color: #fff; }
.table-served { background: var(--success-color); color: #fff; }
.table-delayed { background: var(--danger-color); color: #fff; animation: pulse-delayed 1s infinite; }

@keyframes pulse-delayed {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,53,69,0.4); }
  50% { box-shadow: 0 0 0 8px rgba(220,53,69,0); }
}

.row-today { background: var(--bg-white); }
.row-future { background: #f5f0f8; border-left: 4px solid var(--primary-color); }
.row-waiting { background: #fce4ec; border-left: 4px solid #e91e63; }

/* --- 8. WEEKLY GRID & STOCK (PRESERVED) --- */
.weekly-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; background: var(--border-color); border: 1px solid var(--border-color); border-radius: 8px; overflow: hidden; margin-bottom: 15px; }
.weekly-day { background: #e0f7fa; padding: 8px; font-size: 11px; line-height: 1.4; }
.weekly-total { background: #333; color: #fff; padding: 8px; font-size: 11px; line-height: 1.4; }
.weekly-day-header { background: var(--primary-color); color: #fff; padding: 8px; font-weight: 600; font-size: 12px; text-align: center; }

.stock-supplier { background: var(--primary-color); color: #fff; padding: 12px 16px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.stock-items { background: #fff; padding: 12px 16px; }
.stock-item { padding: 6px 0; font-size: 13px; color: #333; }
.stock-item.has-qty { color: var(--danger-color); font-weight: 500; }

.legend { display: flex; flex-wrap: wrap; gap: 20px; padding: 12px 16px; background: #f8f9fa; border-radius: 8px; margin-bottom: 15px; font-size: 13px; }
.legend-item { display: flex; align-items: center; gap: 8px; }
.legend-color { width: 16px; height: 16px; border-radius: 4px; }

/* --- 9. LOGIN & MOBILE (PRESERVED) --- */
.login-container { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--primary-color) 0%, #8a4a8a 100%); }
.login-box { background: var(--bg-white); border-radius: 12px; padding: 40px; width: 100%; max-width: 360px; box-shadow: 0 10px 40px rgba(0,0,0,0.2); text-align: center; }
.login-logo { max-height: 80px; margin-bottom: 20px; }
.login-title { font-size: 20px; font-weight: 600; color: var(--text-main); margin-bottom: 8px; }
.login-subtitle { font-size: 14px; color: var(--text-muted); margin-bottom: 24px; }

.mobile-menu-btn { display: none; background: none; border: none; font-size: 24px; cursor: pointer; padding: 8px; }

@media (max-width: 768px) {
  .mobile-menu-btn { display: block; }
  .nav { display: none; flex-direction: column; width: 100%; }
  .nav.open { display: flex; }
  .nav a { text-align: center; }
  .col, .col-2, .col-3 { flex: 0 0 100%; }
  .weekly-grid { grid-template-columns: repeat(4, 1fr); }
  .table-grid { grid-template-columns: repeat(4, 1fr); }
}

/* --- 10. NEW UNIVERSAL SYSTEM TOOLS (APPENDED) --- */

/* Framework Tabs */
.tab-bar { display: flex; gap: 5px; border-bottom: 3px solid var(--primary-color); padding: 0 10px; margin-top: 15px; margin-bottom: 25px; overflow-x: auto; }
/* Fixed Tab Button Frame for Vertical Lists */
.tab-btn-frame { 
    padding: 14px 20px; 
    font-weight: 800; 
    color: #333333; 
    background: #f1f5f9; 
    border: 2px solid var(--border-color); 
    cursor: pointer; 
    font-size: 15px; 
    border-radius: 12px; 
    transition: all 0.2s; 
    width: 100%;
    text-align: left;
    display: block;
}

.tab-btn-frame.active { 
    background: var(--bg-white); 
    color: var(--primary-color); 
    border: 2px solid var(--primary-color); 
    box-shadow: 0 4px 12px rgba(95,37,95,0.12);
}
/* Big Add Button */
.big-add-btn { 
    width: 100%; padding: 18px; margin-bottom: 25px; background: var(--primary-color); color: #fff; 
    border: none; border-radius: 12px; font-weight: 900; font-size: 18px; cursor: pointer; 
    display:flex; align-items:center; justify-content:center; gap:10px; box-shadow: 0 10px 15px -3px rgba(95,37,95,0.2);
}




/* --- UNIVERSAL MODAL SYSTEM --- */
.modalOverlay { 
    position: fixed !important; 
    inset: 0 !important; 
    background: rgba(0,0,0,0.75) !important; 
    display: none; 
    align-items: center; 
    justify-content: center; 
    z-index: 999999 !important; 
    padding: 20px; 
    backdrop-filter: blur(8px); 
}

.modalBox { 
    background: var(--bg-white); 
    width: 92%; 
    max-width: 450px; 
    border-radius: 24px; 
    padding: 40px; 
    text-align: center; 
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.modal-icon { 
    font-size: 50px; 
    margin-bottom: 15px; 
    display: block;
}

.modalTitle { 
    font-size: 24px; 
    font-weight: 900; 
    margin-bottom: 10px; 
    color: var(--text-main); 
}

.modal-body { 
    font-size: 15px; 
    color: var(--text-muted); 
    margin-bottom: 30px; 
    line-height: 1.5; 
    font-weight: 600;
}

.modal-actions { 
    display: flex; 
    gap: 15px; 
    justify-content: center;
}

/* Modal-Specific Buttons */
.modal-btn {
    flex: 1;
    padding: 14px;
    border-radius: 12px;
    font-weight: 800;
    font-size: 15px;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.modal-btn-secondary { background: #f1f5f9; color: #475569; }
.modal-btn-secondary:hover { background: #e2e8f0; }

.modal-btn-danger { background: var(--danger-color); color: #fff; }
.modal-btn-danger:hover { background: #b91c1c; box-shadow: 0 4px 12px rgba(220,38,38,0.3); }

.modal-btn-primary { background: var(--primary-color); color: #fff; }
.modal-btn-primary:hover { background: var(--primary-hover); }



/* Admin Grid Layout */
.admin-grid { display: grid; grid-template-columns: 2.5fr 1.2fr; gap: 25px; margin-top: 20px; align-items: start; }
@media (max-width: 1100px) { .admin-grid { grid-template-columns: 1fr; } }

/* Reorder Controls */
.move-col { flex: 0 0 65px; display: flex; flex-direction: column; gap: 5px; }
.move-btn { 
    height: 44px; width: 100%; font-size: 20px; background: #f8fafc; border: 1px solid #d1d5db; 
    border-radius: 8px; cursor: pointer; color: var(--primary-color); display: flex; align-items: center; justify-content: center;
}

/* AJAX States */
.is-pending { background-color: var(--pending-bg) !important; border-color: var(--pending-border) !important; }
.is-saved-flash { animation: savedFlash 650ms ease-out; }

/* Utilities */
.text-green { color: var(--success-color); }
.text-red { color: var(--danger-color); }
.text-orange { color: var(--warning-color); }
.text-blue { color: var(--info-color); }
.text-purple { color: var(--primary-color); }
.text-gray { color: var(--text-muted); }
.text-center { text-align: center; }
.text-right { text-align: right; }


/* --- UNIVERSAL CONFIG TABLE ALIGNMENT --- */
.cfg-header-row, .cfg-row { 
    display: flex !important; 
    align-items: center !important; 
    gap: 15px !important; 
    width: 100%;
}

/* Pinning column widths so Headers and Rows match perfectly */
.col-move { flex: 0 0 50px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.col-name { flex: 2; } /* Name takes most space */
.col-type { flex: 1; min-width: 110px; } /* Type is smaller */
.col-del  { flex: 0 0 50px; display: flex; align-items: center; justify-content: center; }

/* Reorder Buttons Styling */
.move-btn-container { display: flex; flex-direction: column; gap: 2px; }
.m-btn { 
    height: 30px; width: 44px; border-radius: 6px; background: #fff; 
    border: 1px solid var(--border-color); font-size: 12px; cursor: pointer; 
    display: flex; align-items: center; justify-content: center; 
}
.m-btn:active { background: var(--primary-color); color: #fff; }

/* Filter Pill Buttons */
.pill-nav { display: flex; gap: 10px; margin-bottom: 25px; padding: 5px; flex-wrap: wrap; }
.pill-btn { 
    padding: 10px 22px; border-radius: 12px; font-weight: 800; font-size: 14px; 
    color: var(--text-muted); background: var(--bg-light); border: 2px solid var(--border-color); 
    cursor: pointer; transition: 0.2s; text-decoration: none;
}
.pill-btn.active { 
    background: var(--bg-white); color: var(--primary-color); 
    border-color: var(--primary-color); box-shadow: 0 4px 12px rgba(95,37,95,0.15); 
}



/* --- PREMIUM ORDER MIRROR (Matching image_828899.png) --- */
.mirror-group-header {
    background: var(--primary-color);
    color: #fff;
    padding: 10px 15px;
    font-weight: 800;
    font-size: 13px;
    border-radius: 6px;
    margin-top: 20px;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mirror-item {
    background: #fff;
    border-radius: 12px;
    padding: 12px 18px;
    margin-bottom: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid #f1f5f9;
}

.mirror-qty {
    font-size: 19px;
    font-weight: 900;
    color: var(--text-main);
    width: 35px;
    text-align: right;
}

.mirror-sep {
    font-weight: 800;
    color: var(--text-muted);
    font-size: 14px;
}

.mirror-name {
    font-size: 15px;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.2;
    flex: 1;
}

/* --- HIGH CONTRAST CONTACT BUTTONS --- */
.contact-btn { 
    padding: 8px 16px; 
    border-radius: 8px; 
    font-weight: 900; 
    font-size: 13px; 
    cursor: pointer; 
    border: none; 
    transition: 0.2s; 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    text-shadow: 0 1px 1px rgba(0,0,0,0.1);
}

/* WhatsApp / Group Button: Darker green for white text legibility */
.cb-wa { background: #128c7e; color: #ffffff; } 
.cb-wa:hover { background: #075e54; }

/* Email Button */
.cb-email { background: #1e40af; color: #ffffff; }
.cb-email:hover { background: #1e3a8a; }

/* Standard Copy Button */
.cb-copy { background: #475569; color: #ffffff; }
.cb-copy:hover { background: #334155; }




/* --- SILENT GUARD: NATIVE APP SYNCING BAR --- */
#syncingProgressBar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 4px;
    background: linear-gradient(90deg, #f59e0b, #10b981); /* Orange to Green gradient */
    z-index: 9999999;
    transition: opacity 0.3s ease;
    display: none;
    opacity: 0;
}

#syncingProgressBar.active {
    display: block;
    opacity: 1;
    animation: progressIndeterminate 2s infinite linear;
}

@keyframes progressIndeterminate {
    0% { width: 0%; left: 0%; }
    50% { width: 70%; left: 15%; }
    100% { width: 0%; left: 100%; }
}