/* ============================================================
   Grocery POS - Base Stylesheet (Common Styles)
   Theme: Green / White / Gray
   ============================================================ */

/* ── CSS Variables ── */
:root {
  --green-dark:   #1a6b3c;
  --green:        #27ae60;
  --green-light:  #2ecc71;
  --green-pale:   #e8f8ef;
  --white:        #ffffff;
  --gray-50:      #fafbfc;
  --gray-100:     #f4f6f8;
  --gray-200:     #e9ecef;
  --gray-300:     #dee2e6;
  --gray-400:     #ced4da;
  --gray-500:     #adb5bd;
  --gray-600:     #6c757d;
  --gray-700:     #495057;
  --gray-800:     #343a40;
  --gray-900:     #212529;
  --red:          #e74c3c;
  --red-pale:     #fee2e2;
  --red-dark:     #c0392b;
  --yellow:       #f39c12;
  --blue:         #3498db;
  --sidebar-w:    250px;
  --navbar-h:     60px;
  --radius:       8px;
  --shadow:       0 2px 8px rgba(0,0,0,.10);
  --shadow-md:    0 4px 16px rgba(0,0,0,.13);
  --transition:   .2s ease;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  line-height: 1.6;
}
a { color: var(--green); text-decoration: none; }
a:hover { color: var(--green-dark); }
img { max-width: 100%; display: block; }
ul { list-style: none; }

/* ── Layout ── */
.app-wrapper { display: flex; min-height: 100vh; overflow-x: hidden; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--green-dark);
  color: var(--white);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1000;
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.15);
  min-height: var(--navbar-h);
}
.sidebar-logo { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.sidebar-icon-brand { font-size: 1.6rem; color: var(--green-light); }
.sidebar-store-name {
  font-size: .85rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-nav { flex: 1; padding: 10px 0; }
.sidebar-nav ul { padding: 0; }
.nav-section-label {
  font-size: .68rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: rgba(255,255,255,.45);
  padding: 12px 18px 4px;
}
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 18px; color: rgba(255,255,255,.82);
  font-size: .875rem; border-radius: 0;
  transition: background var(--transition), color var(--transition);
}
.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: rgba(255,255,255,.12);
  color: var(--white);
}
.sidebar-nav a.active { border-left: 3px solid var(--green-light); }
.sidebar-nav a i { width: 18px; text-align: center; font-size: .95rem; }
.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.15);
}
.btn-logout {
  display: flex; align-items: center; gap: 8px;
  color: rgba(255,255,255,.7); font-size: .85rem;
  transition: color var(--transition);
}
.btn-logout:hover { color: var(--white); }

/* Main content area */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Navbar */
.navbar {
  height: var(--navbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; gap: 14px;
  padding: 0 22px;
  position: sticky; top: 0; z-index: 900;
  box-shadow: var(--shadow);
}
.sidebar-toggle {
  background: none; border: none; cursor: pointer;
  font-size: 1.2rem; color: var(--gray-700);
  display: none;
  z-index: 1001;
  padding: 4px 8px;
  position: relative;
}
.navbar-title h1 { font-size: 1.1rem; font-weight: 600; color: var(--gray-800); }
.navbar-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.navbar-clock { font-size: .8rem; color: var(--gray-500); }
.navbar-user { display: flex; align-items: center; gap: 7px; font-size: .875rem; color: var(--gray-700); }
.navbar-user i { font-size: 1.3rem; color: var(--green); }

/* Page body */
.page-body { padding: 24px; flex: 1; overflow-x: hidden; }

/* Footer */
.app-footer {
  background: var(--white);
  border-top: 1px solid var(--gray-200);
  padding: 12px 22px;
  font-size: .8rem;
  color: var(--gray-500);
  text-align: center;
}

/* ── Flash Messages ── */
.flash-message {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px; margin: 10px 22px 0;
  border-radius: var(--radius); font-size: .9rem;
  animation: slideDown .3s ease;
}
.flash-success { background: #d4edda; color: #155724; border-left: 4px solid var(--green); }
.flash-error   { background: #f8d7da; color: #721c24; border-left: 4px solid var(--red); }
.flash-warning { background: #fff3cd; color: #856404; border-left: 4px solid var(--yellow); }
.flash-info    { background: #d1ecf1; color: #0c5460; border-left: 4px solid var(--blue); }
.flash-close   { margin-left: auto; background: none; border: none; cursor: pointer; font-size: 1.1rem; opacity: .6; }
.flash-close:hover { opacity: 1; }
@keyframes slideDown { from { transform: translateY(-10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── Cards ── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 16px; margin-bottom: 28px;
}
.card {
  background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px;
  transition: box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }
.stat-card { display: flex; align-items: center; gap: 14px; }
.stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; flex-shrink: 0;
}
.icon-green   { background: var(--green-pale); color: var(--green); }
.icon-blue    { background: #dbeafe; color: var(--blue); }
.icon-yellow  { background: #fef3c7; color: var(--yellow); }
.icon-red     { background: #fee2e2; color: var(--red); }
.stat-info .stat-value { font-size: 1.45rem; font-weight: 700; color: var(--gray-900); }
.stat-info .stat-label { font-size: .78rem; color: var(--gray-500); font-weight: 500; }

/* Section card */
.section-card {
  background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 24px;
}
.section-card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--gray-200);
}
.section-card-header h2 { font-size: 1rem; font-weight: 600; }
.section-card-body { padding: 20px; }

/* ── Tables ── */
.table-wrap { 
  overflow-x: auto; 
  width: 100%;
  -webkit-overflow-scrolling: touch;
}
table { 
  width: 100%; 
  border-collapse: collapse; 
  font-size: .875rem;
  table-layout: auto; /* Allow natural column widths */
}
thead th {
  background: var(--gray-100); color: var(--gray-600);
  font-weight: 600; font-size: .78rem; text-transform: uppercase;
  letter-spacing: .05em; padding: 10px 14px; text-align: left;
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}
tbody td { 
  padding: 10px 14px; 
  border-bottom: 1px solid var(--gray-100); 
  vertical-align: middle; 
}
tbody tr:hover { background: var(--gray-50); }
tbody tr:last-child td { border-bottom: none; }
.td-actions { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px; border-radius: var(--radius);
  font-size: .875rem; font-weight: 500; cursor: pointer;
  border: none; transition: all var(--transition);
  text-decoration: none; white-space: nowrap;
}
.btn-sm { padding: 5px 11px; font-size: .8rem; }
.btn-lg { padding: 11px 22px; font-size: 1rem; }
.btn-primary   { background: var(--green);      color: var(--white); }
.btn-primary:hover { background: var(--green-dark); color: var(--white); }
.btn-secondary { background: var(--gray-200);   color: var(--gray-700); }
.btn-secondary:hover { background: var(--gray-300); }
.btn-danger    { background: var(--red);         color: var(--white); }
.btn-danger:hover { background: #c0392b; }
.btn-warning   { background: var(--yellow);      color: var(--white); }
.btn-warning:hover { background: #e67e22; }
.btn-info      { background: var(--blue);        color: var(--white); }
.btn-info:hover { background: #2980b9; }
.btn-outline-primary {
  background: transparent; color: var(--green);
  border: 1.5px solid var(--green);
}
.btn-outline-primary:hover { background: var(--green-pale); }
.btn-block { width: 100%; justify-content: center; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: 5px; color: var(--gray-700); }
.form-control, .form-select {
  width: 100%; padding: 9px 12px;
  border: 1.5px solid var(--gray-300); border-radius: var(--radius);
  font-size: .875rem; font-family: inherit; color: var(--gray-800);
  background: var(--white); transition: border var(--transition);
}
.form-control:focus, .form-select:focus {
  outline: none; border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(39,174,96,.15);
}
textarea.form-control { resize: vertical; min-height: 80px; }
.form-hint { font-size: .78rem; color: var(--gray-500); margin-top: 4px; }
.form-error { font-size: .78rem; color: var(--red); margin-top: 4px; }
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 200px; }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px;
  font-size: .75rem; font-weight: 600;
}
.badge-fresh   { background: #d4edda; color: #155724; }
.badge-near    { background: #fff3cd; color: #856404; }
.badge-expired { background: #f8d7da; color: #721c24; }
.badge-none    { background: var(--gray-200); color: var(--gray-600); }
.badge-pending   { background: #fff3cd; color: #856404; }
.badge-received  { background: #d4edda; color: #155724; }
.badge-cancelled { background: #f8d7da; color: #721c24; }
.badge-active   { background: #d4edda; color: #155724; }
.badge-inactive { background: var(--gray-200); color: var(--gray-600); }

/* ── Modals ── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 2000; display: none;
  align-items: center; justify-content: center;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
  animation: popIn .2s ease;
}
.modal-lg { max-width: 760px; }
.modal-xl { max-width: 960px; }
@keyframes popIn { from { transform: scale(.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--gray-200);
}
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--gray-500); }
.modal-close:hover { color: var(--gray-900); }
.modal-body { padding: 20px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px; border-top: 1px solid var(--gray-200);
}

/* ── Search & Toolbar ── */
.page-toolbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  margin-bottom: 18px;
}
.toolbar-search {
  position: relative; flex: 1; min-width: 200px; max-width: 340px;
}
.search-box {
  position: relative; flex: 1; min-width: 200px; max-width: 340px;
}
.search-box i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--gray-500); font-size: .9rem; }
.search-box input { padding-left: 32px; }
.filter-select { max-width: 180px; }
.toolbar-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.toolbar-select {
  min-width: 160px;
}
.toolbar-btn {
  white-space: nowrap;
}

/* ── Alerts ── */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px; border-radius: var(--radius);
  margin-bottom: 12px; font-size: .875rem;
}
.alert i { font-size: 1rem; margin-top: 2px; }
.alert-warning { background: #fff3cd; color: #856404; border-left: 4px solid var(--yellow); }
.alert-danger  { background: #f8d7da; color: #721c24; border-left: 4px solid var(--red); }
.alert-success { background: #d4edda; color: #155724; border-left: 4px solid var(--green); }
.alert-info    { background: #d1ecf1; color: #0c5460; border-left: 4px solid var(--blue); }

/* ── Pagination ── */
.pagination { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 16px; }
.page-link {
  padding: 6px 12px; border-radius: var(--radius);
  border: 1.5px solid var(--gray-300); color: var(--gray-700); font-size: .85rem;
  transition: all var(--transition); text-decoration: none;
}
.page-link:hover, .page-link.active { background: var(--green); color: var(--white); border-color: var(--green); }

/* ── Utility Classes ── */
.text-muted { color: var(--gray-500); }
.text-success { color: var(--green); }
.text-danger { color: var(--red); }
.text-center { text-align: center; }
.small { font-size: .875rem; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.fw-bold { font-weight: 700; }
.discount-tag { 
  text-decoration: line-through; 
  color: var(--gray-500); 
  font-size: .85rem; 
}
.total-row { 
  display: flex; 
  justify-content: space-between; 
  margin-bottom: 6px; 
}
.total-row.grand { 
  font-weight: 700; 
  font-size: 1.1rem; 
  color: var(--green-dark); 
  border-top: 1px solid var(--gray-200); 
  padding-top: 8px; 
  margin-top: 4px; 
}

/* ── Print Styles ── */
@media print {
  .sidebar, .navbar, .page-toolbar, .btn, .modal-backdrop, .app-footer { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .section-card { box-shadow: none; border: 1px solid #ccc; }
}

/* ── Responsive ── */
@media (max-width: 992px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .sidebar-toggle { display: block !important; }
}
