/* Lubricentros MyD — theme.css
   Identidad visual del logo: óvalo amarillo, anillo rojo, negro/blanco.
   Estilo taller/mecánico: alto contraste, bold, esquinas casi rectas. */

:root {
  --brand-yellow: #FFE600;
  --brand-yellow-dark: #E6CE00;
  --brand-red: #E30613;
  --brand-red-dark: #B8050F;
  --brand-black: #111111;
  --brand-white: #FFFFFF;

  --bg: #F4F4F2;
  --surface: #FFFFFF;
  --surface-alt: #F0F0EE;
  --border: #DDDDD8;
  --text: #1A1A1A;
  --text-muted: #5A5A55;

  --danger: #C81E1E;
  --success: #1E8A3C;
  --warning: #B8860B;

  --radius: 4px;
  --shadow: 0 2px 8px rgba(0,0,0,0.12);
  --sidebar-w: 220px;

  --font: -apple-system, "Segoe UI", Arial, Helvetica, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; }

a { color: var(--brand-red); }

h1, h2, h3 { font-weight: 900; letter-spacing: -0.01em; margin: 0 0 12px; }

.hidden { display: none !important; }

/* ---------- Login ---------- */
#loginScreen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-black);
  background-image: radial-gradient(circle at 50% 0%, #2a2a2a 0%, #111 60%);
}

.login-card {
  background: var(--surface);
  border-radius: 8px;
  padding: 40px 36px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  text-align: center;
}

.login-logo {
  width: 140px;
  height: auto;
  margin: 0 auto 8px;
  display: block;
}

.login-logo-fallback {
  width: 140px;
  height: 90px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--brand-yellow);
  border: 6px solid var(--brand-red);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 22px;
  color: var(--brand-black);
  transform: rotate(-8deg);
}

.login-card h1 { font-size: 20px; margin-bottom: 20px; color: var(--brand-black); }

.field { text-align: left; margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin-bottom: 4px; }
.field input, .field select {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}
.field input:focus, .field select:focus { outline: none; border-color: var(--brand-red); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius);
  padding: 10px 18px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.05s ease, filter 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand-yellow); color: var(--brand-black); }
.btn-primary:hover { filter: brightness(0.95); }
.btn-danger { background: var(--brand-red); color: var(--brand-white); }
.btn-danger:hover { filter: brightness(1.1); }
.btn-outline { background: transparent; border: 2px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--brand-black); }
.btn-block { width: 100%; }
.btn-lg { padding: 16px 24px; font-size: 18px; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.error-msg { background: #FDEAEA; border: 1px solid var(--danger); color: var(--danger); padding: 8px 12px; border-radius: var(--radius); font-size: 13px; margin-bottom: 12px; }

/* ---------- App shell ---------- */
#appShell { display: flex; min-height: 100vh; }

#sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--brand-black);
  color: var(--brand-white);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-brand img { width: 40px; height: auto; }
.sidebar-brand .brand-name { font-weight: 900; font-size: 15px; line-height: 1.15; }
.sidebar-brand .brand-name small { display: block; font-weight: 600; font-size: 10px; color: var(--brand-yellow); letter-spacing: 0.05em; }

.nav-menu { list-style: none; margin: 0; padding: 8px; flex: 1; }
.nav-menu li { margin-bottom: 2px; }
.nav-menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius);
  color: #D8D8D5;
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}
.nav-menu a:hover { background: rgba(255,255,255,0.08); color: var(--brand-white); }
.nav-menu a.active { background: var(--brand-yellow); color: var(--brand-black); }

.sidebar-footer { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,0.1); font-size: 12px; color: #B8B8B5; }
.sidebar-footer .user-role { display: inline-block; background: var(--brand-red); color: white; font-size: 10px; font-weight: 800; text-transform: uppercase; padding: 2px 6px; border-radius: 3px; margin-top: 4px; }
.sidebar-footer button { margin-top: 8px; }

#sidebarOverlay { display: none; }

#mainArea { flex: 1; display: flex; flex-direction: column; min-width: 0; }

#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
#topbar h2 { font-size: 20px; margin: 0; }
#hamburger { display: none; background: none; border: none; font-size: 22px; cursor: pointer; }

#content { flex: 1; padding: 24px; overflow-y: auto; }

/* ---------- Cards / tables ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 18px; margin-bottom: 18px; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi-card { background: var(--surface); border: 1px solid var(--border); border-left: 6px solid var(--brand-yellow); border-radius: 8px; padding: 16px 18px; }
.kpi-card.alert { border-left-color: var(--brand-red); }
.kpi-card .kpi-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); font-weight: 700; }
.kpi-card .kpi-value { font-size: 28px; font-weight: 900; margin-top: 4px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); font-weight: 800; }
tr:hover td { background: var(--surface-alt); }

.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 800; text-transform: uppercase; }
.badge-yellow { background: var(--brand-yellow); color: var(--brand-black); }
.badge-red { background: var(--brand-red); color: white; }
.badge-gray { background: #E0E0DC; color: var(--text-muted); }
.badge-green { background: #DFF3E3; color: var(--success); }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar input, .toolbar select { padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius); }
.toolbar .spacer { flex: 1; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }

/* ---------- Side panel (modal lateral) ---------- */
#spOverlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: none; z-index: 40;
}
#sp {
  position: fixed; top: 0; right: -420px; width: 420px; max-width: 92vw; height: 100vh;
  background: var(--surface); box-shadow: -4px 0 24px rgba(0,0,0,0.25);
  z-index: 41; display: flex; flex-direction: column; transition: right 0.2s ease;
}
#sp.open { right: 0; }
#spOverlay.open { display: block; }
#spHeader { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); }
#spHeader h3 { margin: 0; }
#spClose { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-muted); }
#spBody { flex: 1; overflow-y: auto; padding: 20px; }
#spFooter { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ---------- Toast ---------- */
#toastHost { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--brand-black); color: white; padding: 12px 18px; border-radius: var(--radius); box-shadow: var(--shadow); font-weight: 700; font-size: 14px; border-left: 5px solid var(--brand-yellow); }
.toast.error { border-left-color: var(--brand-red); }

/* ---------- POS ---------- */
#posLayout { display: flex; gap: 16px; height: calc(100vh - 130px); }
#posProducts { flex: 1 1 60%; display: flex; flex-direction: column; min-width: 0; }
#posSearch { padding: 14px 16px; font-size: 16px; border: 2px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; }
#posSearch:focus { outline: none; border-color: var(--brand-red); }
#posGrid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; align-content: start; }
.pos-product-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px; cursor: pointer; text-align: left; }
.pos-product-card:hover { border-color: var(--brand-yellow); box-shadow: var(--shadow); }
.pos-product-card:disabled, .pos-product-card.out-of-stock { opacity: 0.4; cursor: not-allowed; }
.pos-product-card .p-name { font-weight: 700; font-size: 13px; margin-bottom: 6px; min-height: 34px; }
.pos-product-card .p-price { font-weight: 900; color: var(--brand-red); font-size: 15px; }
.pos-product-card .p-stock { font-size: 11px; color: var(--text-muted); }

#posCart { flex: 0 0 380px; max-width: 40%; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; display: flex; flex-direction: column; }
#posCartItems { flex: 1; overflow-y: auto; padding: 12px; }
.cart-item { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.cart-item .ci-name { flex: 1; font-size: 13px; font-weight: 600; }
.cart-item .ci-qty { width: 60px; padding: 4px; border: 1px solid var(--border); border-radius: 3px; text-align: center; }
.cart-item .ci-remove { background: none; border: none; color: var(--brand-red); cursor: pointer; font-size: 16px; }
#posCartFooter { padding: 16px; border-top: 2px solid var(--brand-black); }
#posTotal { display: flex; justify-content: space-between; font-size: 22px; font-weight: 900; margin-bottom: 12px; }

@media (max-width: 900px) {
  #sidebar { position: fixed; top: 0; left: 0; height: 100vh; z-index: 30; transform: translateX(-100%); }
  #sidebar.open { transform: translateX(0); }
  #sidebarOverlay.open { display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 29; }
  #hamburger { display: block; }
  #posLayout { flex-direction: column; height: auto; }
  #posCart { max-width: 100%; flex: none; }
}
