/* ================================================================
   style.css — Abuela Canalla · Sistema de Autocontrol
   ================================================================ */

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

:root {
  --brand:       #c0392b;
  --brand-dark:  #922b21;
  --brand-light: #f5b7b1;
  --bg:          #f8f7f5;
  --surface:     #ffffff;
  --border:      #e5e2de;
  --text:        #1a1a1a;
  --text-muted:  #6b6b6b;
  --success:     #27ae60;
  --warning:     #f39c12;
  --danger:      #e74c3c;
  --info:        #2980b9;
  --sidebar-w:   260px;
  --radius:      10px;
  --shadow:      0 1px 4px rgba(0,0,0,.08);
  --shadow-md:   0 4px 16px rgba(0,0,0,.10);
}

body { font-family: 'Inter', -apple-system, sans-serif; font-size: 14px;
  background: var(--bg); color: var(--text); line-height: 1.5; }

/* ---- SIDEBAR ---- */
.sidebar {
  position: fixed; top: 0; left: 0; width: var(--sidebar-w); height: 100vh;
  background: #1c1c1c; color: #e8e8e8; display: flex; flex-direction: column;
  z-index: 300; overflow-y: auto; transition: transform .25s ease;
}
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem 1rem; border-bottom: 1px solid #2e2e2e;
}
.brand { display: flex; align-items: center; gap: .6rem; }
.brand-icon { font-size: 1.6rem; }
.brand-name { font-size: .95rem; font-weight: 700; color: #fff; }
.brand-sub  { font-size: .7rem; color: #aaa; text-transform: uppercase; letter-spacing: .05em; }
.sidebar-close { display: none; background: none; border: none; color: #aaa;
  font-size: 1.2rem; cursor: pointer; }

.tienda-badge {
  margin: .75rem 1rem; background: var(--brand); color: #fff;
  border-radius: 6px; padding: .4rem .75rem; font-size: .75rem; font-weight: 600;
}
.tienda-selector-wrap { padding: .75rem 1rem; }
.form-label-small { display: block; font-size: .68rem; color: #aaa;
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: .3rem; }
.select-tienda { width: 100%; background: #2a2a2a; border: 1px solid #3a3a3a;
  color: #e8e8e8; border-radius: 6px; padding: .4rem .6rem; font-size: .8rem; }

.nav-list { list-style: none; padding: .5rem 0; flex: 1; }
.nav-section { padding: .6rem 1rem .2rem; font-size: .65rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .1em; color: #666; }
.nav-link { display: flex; align-items: center; gap: .6rem; padding: .55rem 1rem;
  color: #c8c8c8; text-decoration: none; border-radius: 0; transition: background .15s; font-size: .84rem; }
.nav-link:hover { background: #2a2a2a; color: #fff; }
.nav-link.active { background: var(--brand); color: #fff; }
.nav-icon { width: 1.2rem; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  border-top: 1px solid #2e2e2e; padding: .9rem 1rem;
  display: flex; align-items: center; gap: .6rem;
}
.user-avatar { width: 32px; height: 32px; background: var(--brand); border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .8rem; color: #fff; flex-shrink: 0; }
.user-info { display: flex; align-items: center; gap: .5rem; flex: 1; min-width: 0; }
.user-name { font-size: .8rem; font-weight: 600; color: #eee; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: .68rem; color: #888; text-transform: capitalize; }
.btn-logout { margin-left: auto; background: none; border: none; color: #888;
  font-size: 1.1rem; cursor: pointer; text-decoration: none; padding: .2rem; flex-shrink: 0; }
.btn-logout:hover { color: var(--danger); }

/* ---- MAIN LAYOUT ---- */
.main-wrap {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.overlay { display: none; }

/* ---- TOPBAR ---- */
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: .75rem 1.5rem; display: flex; align-items: center; gap: 1rem;
  position: sticky; top: 0; z-index: 100; box-shadow: var(--shadow);
}
.menu-btn { display: none; background: none; border: none; font-size: 1.3rem;
  cursor: pointer; color: var(--text); }
.page-title { font-size: 1rem; font-weight: 600; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 1rem; }
.badge-tienda { background: var(--brand-light); color: var(--brand-dark);
  border-radius: 20px; padding: .25rem .75rem; font-size: .75rem; font-weight: 600; }
.topbar-date { color: var(--text-muted); font-size: .8rem; }

/* ---- FLASH ---- */
.flash {
  margin: 1rem 1.5rem 0; padding: .75rem 1rem; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: space-between; font-size: .85rem;
}
.flash-success { background: #d5f5e3; color: #1a5e34; border: 1px solid #a9dfbf; }
.flash-error   { background: #fde8e8; color: #922b21; border: 1px solid #f5b7b1; }
.flash-warning { background: #fef9e7; color: #7d6608; border: 1px solid #f9e79f; }
.flash-close   { background: none; border: none; cursor: pointer; color: inherit; font-size: 1rem; }

/* ---- CONTENT ---- */
.content { padding: 1.5rem; flex: 1; }

/* ---- STATS GRID ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--surface); border-radius: var(--radius); padding: 1.25rem;
  box-shadow: var(--shadow); border-left: 4px solid var(--brand);
}
.stat-card.green { border-color: var(--success); }
.stat-card.orange { border-color: var(--warning); }
.stat-card.red { border-color: var(--danger); }
.stat-card.blue { border-color: var(--info); }
.stat-value { font-size: 2rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: .75rem; color: var(--text-muted); margin-top: .3rem; text-transform: uppercase; letter-spacing: .04em; }
.stat-icon  { font-size: 1.5rem; float: right; opacity: .4; }

/* ---- CARD ---- */
.card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 1.5rem;
}
.card-header {
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
}
.card-title { font-size: .9rem; font-weight: 600; }
.card-body { padding: 1.25rem; }

/* ---- TABLE ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
thead th {
  background: #f4f3f1; padding: .6rem .9rem; text-align: left;
  font-size: .72rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-muted); border-bottom: 2px solid var(--border);
}
tbody td { padding: .65rem .9rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover { background: #faf9f8; }
tbody tr:last-child td { border-bottom: none; }

/* ---- FORMS ---- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.form-group { display: flex; flex-direction: column; gap: .35rem; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: .8rem; font-weight: 500; color: var(--text); }
input, select, textarea {
  border: 1px solid var(--border); border-radius: 7px; padding: .5rem .75rem;
  font-size: .875rem; font-family: inherit; width: 100%;
  background: var(--surface); color: var(--text); transition: border .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(192,57,43,.12);
}
textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: .72rem; color: var(--text-muted); }

/* ---- BUTTONS ---- */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem 1rem;
  border-radius: 7px; border: none; cursor: pointer; font-size: .85rem;
  font-family: inherit; font-weight: 500; text-decoration: none; transition: filter .15s, transform .1s; }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #ddd; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-info { background: var(--info); color: #fff; }
.btn-sm { padding: .3rem .65rem; font-size: .78rem; }
.btn-group { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---- BADGES ---- */
.badge {
  display: inline-block; padding: .2rem .55rem; border-radius: 20px;
  font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
}
.badge-green   { background: #d5f5e3; color: #1a5e34; }
.badge-red     { background: #fde8e8; color: #922b21; }
.badge-orange  { background: #fef0e6; color: #784212; }
.badge-blue    { background: #d6eaf8; color: #1a5276; }
.badge-gray    { background: #ecf0f1; color: #555; }

/* ---- PAGE HEADER ---- */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.25rem; flex-wrap: wrap; gap: .75rem;
}
.page-header h2 { font-size: 1.15rem; font-weight: 700; }

/* ---- EMPTY STATE ---- */
.empty-state {
  text-align: center; padding: 3rem 1rem; color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: .75rem; display: block; }
.empty-state p { font-size: .9rem; }

/* ---- LOGIN PAGE ---- */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1c1c1c 0%, #2c2c2c 50%, var(--brand-dark) 100%);
}
.login-box {
  background: var(--surface); border-radius: 16px; padding: 2.5rem;
  width: 100%; max-width: 400px; box-shadow: var(--shadow-md);
}
.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo .logo-icon { font-size: 3rem; display: block; margin-bottom: .5rem; }
.login-logo h1 { font-size: 1.4rem; font-weight: 800; color: var(--brand); }
.login-logo p  { font-size: .8rem; color: var(--text-muted); }
.login-box .form-group { margin-bottom: 1rem; }
.login-box .btn-primary { width: 100%; justify-content: center; padding: .7rem; font-size: .95rem; }

/* ---- FOOTER ---- */
.app-footer {
  background: var(--surface); border-top: 1px solid var(--border);
  padding: .6rem 1.5rem; display: flex; justify-content: space-between;
  font-size: .72rem; color: var(--text-muted); flex-wrap: wrap; gap: .5rem;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: block; }
  .overlay { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5);
    z-index: 200; opacity: 0; pointer-events: none; transition: opacity .25s; }
  .overlay.show { opacity: 1; pointer-events: auto; }
  .main-wrap { margin-left: 0; }
  .menu-btn { display: block; }
  .form-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .content { padding: 1rem; }
  .topbar { padding: .75rem 1rem; }
}

/* ---- PRINT ---- */
@media print {
  .sidebar, .topbar, .app-footer, .btn, .flash { display: none !important; }
  .main-wrap { margin-left: 0; }
  .content { padding: 0; }
}

/* ---- MISC ---- */
.text-muted    { color: var(--text-muted); }
.text-success  { color: var(--success); }
.text-danger   { color: var(--danger); }
.text-warning  { color: var(--warning); }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-1 { gap: .5rem; }
.text-right { text-align: right; }
hr.divider { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }
