/* ============================================================
   MiniShop360 - Tema visual principal
   País: Paraguay | Bootstrap 5 personalizado
   ============================================================ */

/* ── Google Fonts: Nunito ─────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@300;400;500;600;700;800&display=swap');

/* ── Variables de diseño ──────────────────────────────────── */
:root {
  --ms-primary:       #2563eb;
  --ms-primary-dark:  #1d4ed8;
  --ms-primary-light: #dbeafe;
  --ms-secondary:     #7c3aed;
  --ms-sidebar-from:  #0f172a;
  --ms-sidebar-to:    #1e293b;
  --ms-sidebar-text:  #94a3b8;
  --ms-sidebar-hover: rgba(255,255,255,.08);
  --ms-sidebar-active:#2563eb;
  --ms-bg:            #f1f5f9;
  --ms-card-bg:       #ffffff;
  --ms-text:          #1e293b;
  --ms-text-muted:    #64748b;
  --ms-border:        #e2e8f0;
  --ms-success:       #16a34a;
  --ms-warning:       #d97706;
  --ms-danger:        #dc2626;
  --ms-info:          #0891b2;
  --ms-radius:        .75rem;
  --ms-shadow:        0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
  --ms-shadow-lg:     0 8px 32px rgba(0,0,0,.10);
  --ms-sidebar-w:     260px;
  --ms-header-h:      64px;
  --ms-transition:    .2s ease;
}

/* ── Reset y base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Nunito', sans-serif;
  background: var(--ms-bg);
  color: var(--ms-text);
  font-size: .9375rem;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ── Layout principal ─────────────────────────────────────── */
#app-wrapper { display: flex; min-height: 100vh; }

/* ── Sidebar ──────────────────────────────────────────────── */
#sidebar {
  width: var(--ms-sidebar-w);
  min-height: 100vh;
  background: linear-gradient(180deg, var(--ms-sidebar-from) 0%, var(--ms-sidebar-to) 100%);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  transition: transform var(--ms-transition);
  box-shadow: 4px 0 20px rgba(0,0,0,.15);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #334155 transparent;
}
#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-thumb { background: #334155; border-radius: 2px; }

.sidebar-brand {
  padding: 1.5rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.06);
  display: flex;
  align-items: center;
  gap: .75rem;
  text-decoration: none;
}
.sidebar-brand .brand-icon {
  width: 40px; height: 40px;
  background: var(--ms-primary);
  border-radius: .6rem;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; color: #fff;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(37,99,235,.4);
}
.sidebar-brand .brand-text { line-height: 1.2; }
.sidebar-brand .brand-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: #f8fafc;
  display: block;
}
.sidebar-brand .brand-sub {
  font-size: .72rem;
  color: var(--ms-sidebar-text);
  font-weight: 400;
}

.sidebar-section {
  padding: 1rem 1rem .25rem;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #475569;
}

.sidebar-nav { padding: .5rem .75rem; flex: 1; }

.nav-item { margin-bottom: .1rem; }

.nav-link-ms {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem .875rem;
  border-radius: .5rem;
  color: var(--ms-sidebar-text);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
  transition: all var(--ms-transition);
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
}
.nav-link-ms i { font-size: 1.1rem; flex-shrink: 0; width: 20px; text-align: center; }
.nav-link-ms:hover {
  color: #f1f5f9;
  background: var(--ms-sidebar-hover);
  transform: translateX(2px);
}
.nav-link-ms.active {
  color: #fff;
  background: var(--ms-primary);
  box-shadow: 0 4px 12px rgba(37,99,235,.35);
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255,255,255,.06);
}
.user-info-sidebar {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem .875rem;
  border-radius: .5rem;
  background: rgba(255,255,255,.04);
}
.user-avatar {
  width: 34px; height: 34px;
  background: var(--ms-primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.user-name { font-size: .8rem; font-weight: 600; color: #e2e8f0; }
.user-rol  { font-size: .7rem; color: var(--ms-sidebar-text); text-transform: capitalize; }

/* ── Contenido principal ──────────────────────────────────── */
#main-content {
  margin-left: var(--ms-sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Header ───────────────────────────────────────────────── */
#top-header {
  height: var(--ms-header-h);
  background: var(--ms-card-bg);
  border-bottom: 1px solid var(--ms-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
  position: sticky; top: 0; z-index: 1030;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
}
.header-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ms-text);
}
.header-actions { display: flex; align-items: center; gap: .75rem; }

/* ── Page content ─────────────────────────────────────────── */
.page-content {
  padding: 1.75rem;
  flex: 1;
}

/* ── Breadcrumb ───────────────────────────────────────────── */
.ms-breadcrumb {
  margin-bottom: 1.25rem;
  font-size: .8125rem;
}
.ms-breadcrumb .breadcrumb { margin: 0; background: transparent; padding: 0; }
.ms-breadcrumb .breadcrumb-item a { color: var(--ms-primary); text-decoration: none; }
.ms-breadcrumb .breadcrumb-item.active { color: var(--ms-text-muted); }

/* ── Cards ────────────────────────────────────────────────── */
.ms-card {
  background: var(--ms-card-bg);
  border: 1px solid var(--ms-border);
  border-radius: var(--ms-radius);
  box-shadow: var(--ms-shadow);
  overflow: hidden;
}
.ms-card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--ms-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--ms-card-bg);
}
.ms-card-title {
  font-size: .9375rem;
  font-weight: 700;
  color: var(--ms-text);
  margin: 0;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.ms-card-title i { color: var(--ms-primary); }
.ms-card-body { padding: 1.25rem; }

/* ── Stat cards (dashboard) ───────────────────────────────── */
.stat-card {
  background: var(--ms-card-bg);
  border: 1px solid var(--ms-border);
  border-radius: var(--ms-radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--ms-shadow);
  transition: transform var(--ms-transition), box-shadow var(--ms-transition);
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--ms-shadow-lg);
}
.stat-card .stat-icon {
  width: 48px; height: 48px;
  border-radius: .75rem;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.stat-card .stat-value { font-size: 1.6rem; font-weight: 800; line-height: 1.1; }
.stat-card .stat-label { font-size: .8rem; color: var(--ms-text-muted); font-weight: 500; }

.stat-primary .stat-icon { background: var(--ms-primary-light); color: var(--ms-primary); }
.stat-success .stat-icon { background: #dcfce7; color: var(--ms-success); }
.stat-warning .stat-icon { background: #fef3c7; color: var(--ms-warning); }
.stat-danger  .stat-icon { background: #fee2e2; color: var(--ms-danger); }
.stat-info    .stat-icon { background: #e0f2fe; color: var(--ms-info); }

/* ── Botones ──────────────────────────────────────────────── */
.btn { font-family: 'Nunito', sans-serif; font-weight: 600; border-radius: .5rem; }
.btn-sm { font-size: .8rem; }
.btn-primary  { background: var(--ms-primary); border-color: var(--ms-primary); }
.btn-primary:hover  { background: var(--ms-primary-dark); border-color: var(--ms-primary-dark); }

/* ── Tablas ───────────────────────────────────────────────── */
.ms-table { width: 100%; font-size: .875rem; }
.ms-table thead th {
  background: var(--ms-bg);
  border-bottom: 2px solid var(--ms-border);
  color: var(--ms-text-muted);
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: .75rem 1rem;
  white-space: nowrap;
}
.ms-table tbody td {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--ms-border);
  vertical-align: middle;
}
.ms-table tbody tr:hover { background: #f8fafc; }
.ms-table tbody tr:last-child td { border-bottom: none; }

/* ── Badges ───────────────────────────────────────────────── */
.badge-estado {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .25rem .6rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-activo    { background: #dcfce7; color: #15803d; }
.badge-inactivo  { background: #fee2e2; color: #b91c1c; }
.badge-abierta   { background: #dcfce7; color: #15803d; }
.badge-cerrada   { background: #f1f5f9; color: #64748b; }
.badge-borrador  { background: #f1f5f9; color: #64748b; }
.badge-enviado   { background: #dbeafe; color: #1d4ed8; }
.badge-aprobado  { background: #dcfce7; color: #15803d; }
.badge-rechazado { background: #fee2e2; color: #b91c1c; }
.badge-emitida   { background: #dcfce7; color: #15803d; }
.badge-anulada   { background: #fee2e2; color: #b91c1c; }
.badge-unidad        { background: #dbeafe; color: #1d4ed8; }
.badge-kilogramo     { background: #fef3c7; color: #92400e; }
.badge-no_permanente { background: #f3e8ff; color: #6b21a8; }

/* ── Formularios ──────────────────────────────────────────── */
.form-control, .form-select {
  border: 1.5px solid var(--ms-border);
  border-radius: .5rem;
  font-family: 'Nunito', sans-serif;
  font-size: .875rem;
  transition: border-color var(--ms-transition), box-shadow var(--ms-transition);
}
.form-control:focus, .form-select:focus {
  border-color: var(--ms-primary);
  box-shadow: 0 0 0 .2rem rgba(37,99,235,.15);
}
.form-label { font-size: .825rem; font-weight: 600; color: var(--ms-text); }

/* ── Modales ──────────────────────────────────────────────── */
.modal-content {
  border: none;
  border-radius: var(--ms-radius);
  box-shadow: var(--ms-shadow-lg);
}
.modal-header {
  background: linear-gradient(135deg, var(--ms-primary) 0%, var(--ms-secondary) 100%);
  color: #fff;
  border-radius: var(--ms-radius) var(--ms-radius) 0 0;
  border-bottom: none;
  padding: 1.1rem 1.5rem;
}
.modal-header .modal-title { font-weight: 700; font-size: 1rem; }
.modal-header .btn-close { filter: invert(1); }
.modal-body  { padding: 1.5rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--ms-border); }

/* ── Foto de producto ─────────────────────────────────────── */
.prod-thumb {
  width: 42px; height: 42px;
  object-fit: cover;
  border-radius: .4rem;
  border: 1px solid var(--ms-border);
}
.foto-preview {
  width: 100px; height: 100px;
  object-fit: cover;
  border-radius: .5rem;
  border: 2px solid var(--ms-border);
}

/* ── Loader overlay ───────────────────────────────────────── */
#ms-loader {
  position: fixed; inset: 0;
  background: rgba(255,255,255,.75);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
#ms-loader.show { opacity: 1; pointer-events: all; }
.ms-spinner {
  width: 48px; height: 48px;
  border: 4px solid var(--ms-primary-light);
  border-top-color: var(--ms-primary);
  border-radius: 50%;
  animation: ms-spin .7s linear infinite;
}
@keyframes ms-spin { to { transform: rotate(360deg); } }

/* ── Footer ───────────────────────────────────────────────── */
#app-footer {
  padding: .75rem 1.75rem;
  font-size: .78rem;
  color: var(--ms-text-muted);
  border-top: 1px solid var(--ms-border);
  background: var(--ms-card-bg);
  text-align: center;
}

/* ── Login page ───────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #1e293b 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%232563eb' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.login-card {
  background: #fff;
  border-radius: 1.25rem;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  position: relative;
  z-index: 1;
}
.login-logo {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--ms-primary) 0%, var(--ms-secondary) 100%);
  border-radius: 1rem;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem; color: #fff;
  margin: 0 auto 1rem;
  box-shadow: 0 8px 24px rgba(37,99,235,.35);
}
.login-title  { font-size: 1.5rem; font-weight: 800; color: var(--ms-text); }
.login-subtitle { font-size: .875rem; color: var(--ms-text-muted); }
.login-input-icon { position: relative; }
.login-input-icon i {
  position: absolute; left: .875rem; top: 50%;
  transform: translateY(-50%);
  color: var(--ms-text-muted); font-size: 1rem;
  pointer-events: none;
}
.login-input-icon .form-control { padding-left: 2.5rem; height: 46px; }
.btn-login {
  height: 46px;
  background: linear-gradient(135deg, var(--ms-primary) 0%, var(--ms-secondary) 100%);
  border: none;
  font-size: .9375rem;
  font-weight: 700;
  letter-spacing: .02em;
  color: #fff;
  border-radius: .6rem;
  width: 100%;
  transition: opacity .2s, transform .2s;
}
.btn-login:hover { opacity: .9; transform: translateY(-1px); color: #fff; }

/* ── Página caja / POS ─────────────────────────────────────── */
.pos-product-row { border-bottom: 1px solid var(--ms-border); padding: .5rem 0; }
.pos-total-box {
  background: var(--ms-sidebar-from);
  color: #fff;
  border-radius: var(--ms-radius);
  padding: 1.25rem;
}
.pos-total-monto { font-size: 2rem; font-weight: 800; }

/* ── Impresión ────────────────────────────────────────────── */
@media print {
  #sidebar, #top-header, #app-footer,
  .no-print, .btn, .modal { display: none !important; }
  #main-content { margin: 0 !important; }
  body { background: #fff; font-size: 11pt; }
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 991.98px) {
  #sidebar {
    transform: translateX(-100%);
    z-index: 1045;
  }
  #sidebar.show { transform: translateX(0); }
  #main-content { margin-left: 0; }
  .sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 1044;
  }
  .sidebar-overlay.show { display: block; }
}
