/* ============================================================
   main.css – Sistema de diseño GDE Chat
   Optimizado para Zebra TC22 y pantallas de escritorio
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Variables ─────────────────────────────────────────────── */
:root {
  /* Colores */
  --bg-base:        #0a0f1e;
  --bg-surface:     #111827;
  --bg-card:        #1a2235;
  --bg-elevated:    #1f2d45;
  --bg-hover:       #243451;
  --border:         #1e3a5f44;
  --border-solid:   #1e3a5f;

  /* Acentos */
  --accent:         #4F86F7;
  --accent-dark:    #3a6fd4;
  --accent-glow:    #4F86F722;
  --purple:         #7C3AED;
  --emerald:        #10B981;
  --amber:          #F59E0B;
  --rose:           #F43F5E;
  --cyan:           #06B6D4;

  /* Texto */
  --text-primary:   #F1F5F9;
  --text-secondary: #94A3B8;
  --text-muted:     #475569;
  --text-inverse:   #0f172a;

  /* Mensajes */
  --msg-sent:       #1e40af;
  --msg-recv:       #1a2235;
  --msg-sent-text:  #e0eaff;
  --msg-recv-text:  #e2e8f0;

  /* Roles */
  --role-admin:      #E74C3C;
  --role-supervisor: #F59E0B;
  --role-bodeguero:  #10B981;

  /* Radios */
  --radius-sm:   6px;
  --radius:      10px;
  --radius-lg:   16px;
  --radius-xl:   24px;
  --radius-full: 9999px;

  /* Sombras */
  --shadow-sm:  0 1px 3px rgba(0,0,0,.4);
  --shadow:     0 4px 16px rgba(0,0,0,.4);
  --shadow-lg:  0 8px 32px rgba(0,0,0,.5);
  --shadow-glow: 0 0 24px rgba(79,134,247,.15);

  /* Transiciones */
  --ease: cubic-bezier(.4,0,.2,1);
  --dur:  150ms;

  /* Layout */
  --sidebar-w:    300px;
  --topbar-h:     64px;
  --input-h:      72px;
}

/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ── Scrollbars ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-solid); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ── Tipografía ─────────────────────────────────────────────── */
h1, h2, h3, h4 { font-weight: 600; line-height: 1.3; color: var(--text-primary); }
h1 { font-size: clamp(1.4rem, 3vw, 2rem); }
h2 { font-size: clamp(1.1rem, 2.5vw, 1.5rem); }
h3 { font-size: 1rem; }
p  { color: var(--text-secondary); }
a  { color: var(--accent); text-decoration: none; }

/* ── Botones ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .7rem 1.4rem;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--purple));
  color: #fff;
  box-shadow: 0 4px 15px rgba(79,134,247,.3);
}
.btn-primary:hover  { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(79,134,247,.4); }
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-solid);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-danger {
  background: linear-gradient(135deg, var(--rose), #be123c);
  color: #fff;
}
.btn-danger:hover { opacity: .9; }

.btn-success {
  background: linear-gradient(135deg, var(--emerald), #059669);
  color: #fff;
}

.btn-sm { padding: .4rem .85rem; font-size: .8rem; border-radius: var(--radius-sm); }
.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-solid);
  font-size: 1.1rem;
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-send {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--accent), var(--purple));
  color: #fff;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform var(--dur) var(--ease);
}
.btn-send:hover  { transform: scale(1.08); }
.btn-send:active { transform: scale(.95); }

/* ── Inputs ─────────────────────────────────────────────────── */
input, textarea, select {
  background: var(--bg-surface);
  border: 1px solid var(--border-solid);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: inherit;
  font-size: .95rem;
  padding: .7rem 1rem;
  width: 100%;
  transition: border-color var(--dur) var(--ease);
  -webkit-appearance: none;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }
textarea { resize: none; min-height: 80px; }
select option { background: var(--bg-surface); }

/* ── Cards & Panels ─────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

/* ── Avatar ─────────────────────────────────────────────────── */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .9rem;
  color: #fff;
  flex-shrink: 0;
  text-transform: uppercase;
  position: relative;
}
.avatar-lg { width: 52px; height: 52px; font-size: 1.1rem; }
.avatar-sm { width: 30px; height: 30px; font-size: .7rem; }
.avatar-online::after {
  content: '';
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  background: var(--emerald);
  border-radius: var(--radius-full);
  border: 2px solid var(--bg-surface);
}

/* ── Badge ───────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .15rem .5rem;
  border-radius: var(--radius-full);
  font-size: .7rem;
  font-weight: 700;
  line-height: 1;
}
.badge-accent   { background: var(--accent);  color: #fff; }
.badge-emerald  { background: var(--emerald); color: #fff; }
.badge-amber    { background: var(--amber);   color: #000; }
.badge-rose     { background: var(--rose);    color: #fff; }
.badge-unread {
  min-width: 18px;
  height: 18px;
  background: var(--rose);
  color: #fff;
  font-size: .65rem;
}

/* ── Role chips ─────────────────────────────────────────────── */
.role-chip {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .6rem;
  border-radius: var(--radius-full);
  font-size: .7rem;
  font-weight: 600;
}
.role-admin      { background: #7f1d1d33; color: var(--role-admin);      border: 1px solid #7f1d1d55; }
.role-supervisor { background: #78350f33; color: var(--role-supervisor);  border: 1px solid #78350f55; }
.role-bodeguero  { background: #14532d33; color: var(--role-bodeguero);   border: 1px solid #14532d55; }

/* ── Toast Notifications ────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  pointer-events: none;
  max-width: 320px;
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-solid);
  border-radius: var(--radius-lg);
  padding: .85rem 1.2rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  pointer-events: all;
  animation: slideIn .25s var(--ease);
  border-left: 3px solid var(--accent);
}
.toast.success { border-left-color: var(--emerald); }
.toast.error   { border-left-color: var(--rose); }
.toast.warning { border-left-color: var(--amber); }
.toast-icon    { font-size: 1.1rem; flex-shrink: 0; }
.toast-body    {}
.toast-title   { font-weight: 600; font-size: .85rem; color: var(--text-primary); }
.toast-msg     { font-size: .8rem; color: var(--text-secondary); }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(100%); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes fadeOut {
  to { opacity: 0; transform: translateX(100%); }
}

/* ── Modal ───────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeInBg .2s var(--ease);
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-solid);
  border-radius: var(--radius-xl);
  padding: 2rem;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: scaleIn .2s var(--ease);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.modal-footer {
  display: flex;
  gap: .75rem;
  margin-top: 1.5rem;
  justify-content: flex-end;
}

@keyframes fadeInBg { from { opacity: 0; } }
@keyframes scaleIn  { from { opacity: 0; transform: scale(.95); } }

/* ── Form groups ────────────────────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }
.form-group label {
  display: block;
  font-size: .82rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: .4rem;
}
.form-row { display: flex; gap: 1rem; }
.form-row .form-group { flex: 1; }

/* ── Dividers ────────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border-solid);
  margin: 1rem 0;
}

/* ── Empty state ────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  padding: 3rem 1rem;
  color: var(--text-muted);
  text-align: center;
}
.empty-state .icon { font-size: 2.5rem; opacity: .5; }
.empty-state p     { font-size: .9rem; }

/* ── Loading spinner ────────────────────────────────────────── */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border-solid);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Utilidades ─────────────────────────────────────────────── */
.flex        { display: flex; }
.flex-col    { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1   { gap: .25rem; }
.gap-2   { gap: .5rem; }
.gap-3   { gap: .75rem; }
.gap-4   { gap: 1rem; }
.mt-1    { margin-top: .25rem; }
.mt-2    { margin-top: .5rem; }
.mt-4    { margin-top: 1rem; }
.mb-1    { margin-bottom: .25rem; }
.mb-2    { margin-bottom: .5rem; }
.mb-4    { margin-bottom: 1rem; }
.text-sm    { font-size: .82rem; }
.text-xs    { font-size: .72rem; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.font-600   { font-weight: 600; }
.truncate   { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden     { display: none !important; }
.w-full     { width: 100%; }

/* ── Responsive: Handheld pequeño ──────────────────────────── */
@media (max-width: 640px) {
  :root {
    --sidebar-w: 100%;
    --topbar-h:  56px;
  }
  .btn { padding: .65rem 1.2rem; }
  .modal { padding: 1.5rem; border-radius: var(--radius-lg); }
}
