/* ============================================================
   GRUPO GALILEI · Panel — styles.css
   Tema claro · Naranja #fe6a00 + blanco. Estética limpia y moderna.
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, textarea, select { outline: none; font-family: inherit; }
a { text-decoration: none; color: inherit; }

:root {
  --bg:            #f7f8fa;
  --bg-2:          #ffffff;
  --sb-bg:         #ffffff;
  --card-bg:       #ffffff;
  --card-hover:    #fff8f3;
  --border:        rgba(20, 20, 30, 0.06);
  --border-bright: rgba(20, 20, 30, 0.10);
  --text:          #15161a;
  --text-2:        #5b6675;
  --text-3:        #9aa4b1;
  --primary:       #fe6a00;
  --primary-2:     #ff8c3a;
  --primary-soft:  rgba(254, 106, 0, 0.10);
  --primary-bg:    rgba(254, 106, 0, 0.06);
  --primary-glow:  rgba(254, 106, 0, 0.30);
  --accent:        #ff8c3a;
  --accent-2:      #ffb178;
  --green:         #16a34a;
  --red:           #dc2626;
  --amber:         #d97706;
  --sidebar-w:     258px;
  --topbar-h:      62px;
  --r:             14px;
  --r-sm:          10px;
  --shadow-sm:     0 1px 2px rgba(20,20,30,0.04), 0 1px 1px rgba(20,20,30,0.03);
  --shadow:        0 2px 8px rgba(20,20,30,0.05), 0 1px 2px rgba(20,20,30,0.04);
  --shadow-lg:     0 12px 32px rgba(20,20,30,0.08), 0 4px 12px rgba(20,20,30,0.04);
  --ease:          0.2s ease;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(at 0% 0%, rgba(254, 106, 0, 0.05) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(255, 140, 58, 0.04) 0px, transparent 50%);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ============================================================
   SIDEBAR — fondo naranja, contenido blanco
   ============================================================ */
.sidebar {
  background: linear-gradient(180deg, var(--primary) 0%, #ed5e00 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  transition: transform var(--ease);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 18px;
  height: var(--topbar-h);
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.brand-logo {
  height: 30px;
  width: auto;
  display: block;
  background: #ffffff;
  padding: 6px 14px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.sidebar-label {
  font-size: 9.5px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.65);
  letter-spacing: 1.4px;
  padding: 22px 22px 8px;
  flex-shrink: 0;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 4px 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.20) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.20); border-radius: 2px; }

.nav-item { margin-bottom: 2px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--ease), color var(--ease);
  position: relative;
  user-select: none;
}
.nav-link:hover { background: rgba(255, 255, 255, 0.12); }
.nav-link.active {
  background: rgba(255, 255, 255, 0.22);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}
.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 60%;
  border-radius: 0 3px 3px 0;
  background: #ffffff;
}

.nav-icon {
  width: 17px; height: 17px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: rgba(255, 255, 255, 0.75);
  transition: color var(--ease);
}
.nav-link:hover .nav-icon,
.nav-link.active .nav-icon { color: #ffffff; }

.nav-label {
  flex: 1;
  font-size: 13.5px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
  transition: color var(--ease);
}
.nav-link:hover .nav-label,
.nav-link.active .nav-label { color: #ffffff; }
.nav-link.active .nav-label { font-weight: 600; }

.nav-chevron {
  width: 13px; height: 13px;
  color: rgba(255, 255, 255, 0.65);
  transition: transform 0.25s ease, color var(--ease);
  flex-shrink: 0;
}
.nav-link.open .nav-chevron { transform: rotate(90deg); color: #ffffff; }

.subnav {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease;
}
.subnav.open { max-height: 600px; }

.subnav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 12px 7px 38px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--ease);
  margin-bottom: 1px;
}
.subnav-link:hover { background: rgba(255, 255, 255, 0.10); }
.subnav-link.active { background: rgba(255, 255, 255, 0.18); }

.subnav-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  flex-shrink: 0;
  transition: background var(--ease);
}
.subnav-link:hover .subnav-dot,
.subnav-link.active .subnav-dot { background: #ffffff; }

.subnav-label {
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.85);
  transition: color var(--ease);
}
.subnav-link:hover .subnav-label,
.subnav-link.active .subnav-label { color: #ffffff; font-weight: 500; }

.sidebar-footer {
  padding: 14px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.06);
}

.user-avatar {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: #ffffff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  flex-shrink: 0;
  color: var(--primary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 12.5px; font-weight: 600; color: #ffffff; }
.user-role { font-size: 11px; color: rgba(255, 255, 255, 0.70); margin-top: 1px; }

.settings-btn {
  color: rgba(255, 255, 255, 0.80);
  padding: 6px;
  border-radius: 7px;
  transition: color var(--ease), background var(--ease);
}
.settings-btn:hover { color: #ffffff; background: rgba(255, 255, 255, 0.15); }

/* ============================================================
   MAIN WRAPPER + TOPBAR
   ============================================================ */
.main-wrapper {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.topbar-left { display: flex; align-items: center; gap: 14px; }

.hamburger {
  color: var(--text-2);
  padding: 6px;
  border-radius: 7px;
  transition: color var(--ease), background var(--ease);
}
.hamburger:hover { color: var(--primary); background: var(--primary-bg); }

.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text-2);
}
.bc-sep    { color: var(--text-3); }
.bc-parent { cursor: pointer; transition: color var(--ease); }
.bc-parent:hover { color: var(--primary); }
.bc-active { color: var(--text); font-weight: 600; }

.content {
  flex: 1;
  overflow-y: auto;
  padding: 30px 32px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-bright) transparent;
}
.content::-webkit-scrollbar { width: 6px; }
.content::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 3px; }

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header { margin-bottom: 28px; }
.ph-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.ph-left { display: flex; align-items: center; gap: 14px; }
.ph-icon {
  width: 46px; height: 46px;
  border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  box-shadow: 0 6px 16px rgba(254, 106, 0, 0.30);
}
.page-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
  line-height: 1.2;
}
.page-subtitle {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 4px;
}

/* ============================================================
   COMMON COMPONENTS
   ============================================================ */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--ease), box-shadow var(--ease);
}
.card:hover { box-shadow: var(--shadow); }

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
}

.input, .textarea, .select {
  width: 100%;
  padding: 11px 14px;
  background: #ffffff;
  border: 1px solid var(--border-bright);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 13.5px;
  transition: border-color var(--ease), box-shadow var(--ease);
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}
.textarea { resize: vertical; min-height: 110px; line-height: 1.5; font-family: inherit; }
.label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 7px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  font-weight: 600;
  transition: opacity var(--ease), transform var(--ease), box-shadow var(--ease), background var(--ease);
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  box-shadow: 0 4px 14px rgba(254, 106, 0, 0.35);
}
.btn-primary:hover { box-shadow: 0 6px 20px rgba(254, 106, 0, 0.45); }

.btn-accent {
  background: #ffffff;
  color: var(--primary);
  border: 1px solid var(--primary);
}
.btn-accent:hover { background: var(--primary-bg); }

.btn-ghost {
  background: #ffffff;
  border: 1px solid var(--border-bright);
  color: var(--text-2);
}
.btn-ghost:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-bg); }

.btn-danger {
  background: #ffffff;
  border: 1px solid rgba(220, 38, 38, 0.30);
  color: var(--red);
}
.btn-danger:hover { background: rgba(220, 38, 38, 0.06); border-color: var(--red); }

.btn-sm { padding: 6px 12px; font-size: 11.5px; }

/* Badges / chips */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.2px;
}
.badge-green { background: rgba(22, 163, 74, 0.10); color: var(--green); border: 1px solid rgba(22, 163, 74, 0.20); }
.badge-amber { background: rgba(217, 119, 6, 0.10); color: var(--amber); border: 1px solid rgba(217, 119, 6, 0.22); }
.badge-red   { background: rgba(220, 38, 38, 0.10); color: var(--red);   border: 1px solid rgba(220, 38, 38, 0.22); }
.badge-blue  { background: var(--primary-bg);      color: var(--primary); border: 1px solid rgba(254, 106, 0, 0.22); }
.badge-grey  { background: rgba(20, 20, 30, 0.04);  color: var(--text-2); border: 1px solid var(--border-bright); }

/* Tables */
.tbl {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.tbl th {
  text-align: left;
  font-weight: 700;
  color: var(--text-3);
  font-size: 10.5px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
}
.tbl td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: #fff8f3; }

/* Toast */
.toast-host {
  position: fixed;
  bottom: 22px; right: 22px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 999;
}
.toast {
  padding: 12px 18px;
  border-radius: 10px;
  background: #ffffff;
  border: 1px solid var(--border-bright);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slidein .25s ease;
}
.toast.ok    { border-left: 3px solid var(--green); }
.toast.err   { border-left: 3px solid var(--red); }
.toast.info  { border-left: 3px solid var(--primary); }
@keyframes slidein { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Utility */
.flex { display: flex; }
.row  { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

.muted { color: var(--text-2); }
.tiny  { font-size: 11.5px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }

/* Spinner */
.spin {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border-bright);
  border-top-color: var(--primary);
  animation: spin .8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

code {
  background: var(--primary-bg);
  color: var(--primary);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 0.9em;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

/* ============================================================
   LOGIN SCREEN
   ============================================================ */
#login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background:
    radial-gradient(at 20% 20%, rgba(254, 106, 0, 0.13) 0px, transparent 50%),
    radial-gradient(at 80% 80%, rgba(255, 140, 58, 0.10) 0px, transparent 50%),
    var(--bg);
  z-index: 100;
}
.login-card {
  width: 380px;
  max-width: 100%;
  padding: 44px 38px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  display: block;
  height: 44px;
  width: auto;
  margin: 0 auto 22px;
}
.login-card h2 {
  text-align: center;
  font-size: 19px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}
.login-card .login-sub {
  text-align: center;
  color: var(--text-2);
  font-size: 13px;
  margin-bottom: 26px;
}
.login-error {
  display: none;
  margin-bottom: 14px;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(220, 38, 38, 0.06);
  border: 1px solid rgba(220, 38, 38, 0.20);
  color: var(--red);
  font-size: 12.5px;
}

/* ============================================================
   CHAT (conversaciones)
   ============================================================ */
.chat-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  min-height: 540px;
}
.chat-list {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-sm);
}
.chat-list-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  letter-spacing: 0.6px;
  text-transform: uppercase;
  background: #fafbfc;
}
.chat-list-items { overflow-y: auto; flex: 1; }
.chat-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--ease);
}
.chat-item:hover { background: #fff8f3; }
.chat-item.active { background: var(--primary-bg); border-left: 3px solid var(--primary); padding-left: 13px; }
.chat-item .ci-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.chat-item .ci-name { font-weight: 600; font-size: 13.5px; color: var(--text); }
.chat-item .ci-time { font-size: 10.5px; color: var(--text-3); }
.chat-item .ci-last { font-size: 12px; color: var(--text-2); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chat-detail {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.chat-detail-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: #fafbfc;
}
.chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex; flex-direction: column; gap: 8px;
  background: #fafbfc;
}
.chat-msg {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.42;
  word-break: break-word;
}
.chat-msg.user      { align-self: flex-start; background: #ffffff; border: 1px solid var(--border-bright); color: var(--text); }
.chat-msg.assistant { align-self: flex-end;   background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; box-shadow: 0 2px 8px rgba(254, 106, 0, 0.20); }
.chat-msg .meta { font-size: 10px; opacity: 0.65; margin-top: 4px; }

@media (max-width: 900px) {
  .chat-layout { grid-template-columns: 1fr; }
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; transform: translateX(-100%); width: var(--sidebar-w); z-index: 50; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
}
