/* ===== DI-One Hardware Management System - Global Styles ===== */

:root {
  --primary: #1a3c5e;
  --primary-light: #2563a8;
  --accent: #e07b2a;
  --accent-light: #f59e42;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --bg: #f0f4f8;
  --sidebar-bg: #1a3c5e;
  --sidebar-text: #cbd5e1;
  --sidebar-active: #e07b2a;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 2px 8px rgba(0,0,0,0.10);
  --radius: 10px;
  --font: 'Segoe UI', Arial, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ===== LAYOUT ===== */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: width 0.25s ease;
  overflow: hidden;
}
.sidebar.collapsed { width: 64px; }

/* Logo */
.sidebar-logo {
  padding: 20px 18px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-logo .logo-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  width: 28px;
  text-align: center;
}
.sidebar-logo .logo-text h2 {
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
}
.sidebar-logo .logo-text h2 span { color: var(--accent); }
.sidebar-logo .logo-text p {
  font-size: 0.68rem;
  color: var(--sidebar-text);
  opacity: 0.6;
  margin-top: 1px;
}

/* Toggle button */
.sidebar-toggle {
  position: absolute;
  top: 18px; right: -12px;
  width: 24px; height: 24px;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 0.7rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  z-index: 101;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  transition: transform 0.25s;
  flex-shrink: 0;
}
.sidebar.collapsed .sidebar-toggle { transform: rotate(180deg); }

/* User info */
.sidebar-user {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  min-height: 58px;
  white-space: nowrap;
  overflow: hidden;
}
.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; font-size: 0.95rem;
  flex-shrink: 0;
}
.user-info { overflow: hidden; }
.user-info small {
  display: block;
  font-size: 0.68rem;
  opacity: 0.55;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-info strong {
  font-size: 0.85rem;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.sidebar.collapsed .user-info,
.sidebar.collapsed .logo-text { display: none; }

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 10px 0;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }

/* Section divider */
.nav-section-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.28);
  padding: 10px 18px 3px;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar.collapsed .nav-section-label {
  padding: 10px 0 3px;
  text-align: center;
  font-size: 0;      /* hide text, keep spacing */
}
.sidebar.collapsed .nav-section-label::before {
  content: '';
  display: block;
  height: 1px;
  background: rgba(255,255,255,0.1);
  margin: 0 10px;
}

/* Nav links */
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  border-radius: 0 8px 8px 0;
  margin-right: 8px;
  transition: all 0.18s;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
}
.sidebar-nav a:hover {
  background: rgba(255,255,255,0.07);
  color: #fff;
  border-left-color: rgba(255,255,255,0.2);
}
.sidebar-nav a.active {
  background: rgba(224,123,42,0.18);
  color: #fff;
  border-left-color: var(--accent);
  font-weight: 600;
}
.sidebar-nav a .nav-icon {
  font-size: 1.05rem;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sidebar-nav a .nav-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-nav a .nav-badge {
  background: var(--danger);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 99px;
  flex-shrink: 0;
}

/* Collapsed state — show only icons, tooltip on hover */
.sidebar.collapsed .sidebar-nav a {
  padding: 11px 0;
  justify-content: center;
  margin-right: 0;
  border-left: 3px solid transparent;
  border-radius: 0;
}
.sidebar.collapsed .sidebar-nav a.active {
  border-left-color: var(--accent);
}
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-badge { display: none; }

/* Tooltip for collapsed sidebar */
.sidebar.collapsed .sidebar-nav a::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 68px;
  top: 50%;
  transform: translateY(-50%);
  background: #1e293b;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 200;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.sidebar.collapsed .sidebar-nav a:hover::after { opacity: 1; }

/* Footer */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.sidebar-footer a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 2px;
  color: #fca5a5;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 6px;
  transition: all 0.18s;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-footer a:hover { color: #f87171; background: rgba(248,113,113,0.08); padding-left: 6px; }
.sidebar.collapsed .sidebar-footer a {
  justify-content: center;
  padding: 8px 0;
}
.sidebar.collapsed .sidebar-footer .footer-label { display: none; }

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: 240px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.25s ease;
}
.main-content.expanded { margin-left: 64px; }

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar h1 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
}
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.breadcrumb span { color: var(--text-muted); opacity: 0.5; }
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.topbar-date {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: none;
}
@media (min-width: 900px) { .topbar-date { display: block; } }

.page-body {
  padding: 24px 28px;
  flex: 1;
}

/* ===== CARDS ===== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-bottom: 22px;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== STAT CARDS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-left: 4px solid var(--primary-light);
}

.stat-card.orange { border-left-color: var(--accent); }
.stat-card.green  { border-left-color: var(--success); }
.stat-card.red    { border-left-color: var(--danger); }
.stat-card.blue   { border-left-color: var(--primary-light); }

.stat-card .stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-card .stat-value {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.stat-card .stat-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border: none;
  border-radius: 7px;
  font-size: 0.87rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s;
  text-decoration: none;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); }
.btn-accent  { background: var(--accent); color: #fff; }
.btn-accent:hover  { background: var(--accent-light); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(1.1); }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover  { filter: brightness(1.1); }
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: 5px 12px; font-size: 0.80rem; }
.btn-lg { padding: 11px 26px; font-size: 0.95rem; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.form-control {
  width: 100%;
  padding: 9px 13px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-size: 0.9rem;
  font-family: var(--font);
  background: #fff;
  color: var(--text);
  transition: border-color 0.2s;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary-light);
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}

/* ===== TABLES ===== */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.87rem;
}
thead th {
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 2px solid var(--border);
}
tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }

/* ===== BADGES ===== */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 0.73rem;
  font-weight: 600;
}
.badge-green  { background: #dcfce7; color: #15803d; }
.badge-red    { background: #fee2e2; color: #b91c1c; }
.badge-orange { background: #ffedd5; color: #c2410c; }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-gray   { background: #f1f5f9; color: #475569; }

/* ===== MODALS ===== */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  animation: slideUp 0.22s ease;
}
.modal-lg { max-width: 720px; }
@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary);
}
.modal-close {
  background: none; border: none;
  font-size: 1.3rem; cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
}
.modal-close:hover { background: var(--bg); }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ===== ALERTS ===== */
.alert {
  padding: 11px 16px;
  border-radius: 7px;
  font-size: 0.87rem;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.alert-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.alert-danger   { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-warning  { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

/* ===== SEARCH BAR ===== */
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.search-bar input {
  flex: 1;
  min-width: 180px;
  padding: 8px 13px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-size: 0.87rem;
  font-family: var(--font);
}
.search-bar input:focus {
  outline: none;
  border-color: var(--primary-light);
}

/* ===== SECTION HEADER ===== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 10px;
}
.section-header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary);
}

/* ===== LOGIN PAGE ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a3c5e 0%, #2563a8 100%);
}
.login-box {
  background: #fff;
  border-radius: 14px;
  padding: 40px 36px 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.18);
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
}
.login-logo h1 span { color: var(--accent); }
.login-logo p { font-size: 0.8rem; color: var(--text-muted); margin-top: 3px; }
.login-box .btn { width: 100%; justify-content: center; }

/* ===== POS LAYOUT ===== */
.pos-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
  align-items: start;
}
.pos-cart {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 120px);
  overflow: hidden;
  position: sticky;
  top: 80px;
}
.pos-cart-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 1rem;
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.pos-cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
}
.cart-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.cart-item:last-child { border-bottom: none; }
.cart-item-name { flex: 1; font-size: 0.87rem; }
.cart-item-qty {
  display: flex;
  align-items: center;
  gap: 6px;
}
.qty-btn {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.qty-btn:hover { background: var(--bg); }
.cart-item-price { font-size: 0.87rem; font-weight: 600; min-width: 70px; text-align: right; }
.cart-item-remove {
  background: none; border: none;
  color: var(--danger); cursor: pointer;
  font-size: 1rem; padding: 2px;
}
.pos-cart-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
}
.cart-total-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.87rem;
  padding: 3px 0;
  color: var(--text-muted);
}
.cart-total-row.grand {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  padding-top: 8px;
  margin-top: 4px;
  border-top: 1px solid var(--border);
}

/* ===== PRODUCT GRID ===== */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.product-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  cursor: pointer;
  transition: all 0.18s;
  border: 2px solid transparent;
  text-align: center;
}
.product-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.product-card .product-icon { font-size: 2rem; margin-bottom: 6px; }
.product-card .product-name { font-size: 0.82rem; font-weight: 600; }
.product-card .product-price { font-size: 0.78rem; color: var(--accent); font-weight: 600; }
.product-card .product-stock { font-size: 0.72rem; color: var(--text-muted); }

/* ===== PRINT ===== */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .main-content { margin-left: 0; }
  .page-body { padding: 0; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .sidebar { width: 60px; }
  .sidebar-logo h2, .sidebar-logo p, .user-info,
  .nav-section-label, .sidebar-nav a span,
  .sidebar-footer a span { display: none; }
  .main-content { margin-left: 60px; }
  .pos-layout { grid-template-columns: 1fr; }
  .pos-cart { position: static; max-height: none; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
}
