/* ── Variables ────────────────────────────────────────────────────────────── */
:root {
  --c-bg:        #f0f2f5;
  --c-surface:   #ffffff;
  --c-sidebar:   #111827;
  --c-sidebar-h: #1f2937;
  --c-accent:    #4f46e5;
  --c-accent-h:  #4338ca;
  --c-text:      #111827;
  --c-muted:     #6b7280;
  --c-border:    #e5e7eb;
  --c-danger:    #ef4444;
  --c-danger-h:  #dc2626;
  --c-success:   #10b981;
  --c-warn:      #f59e0b;
  --sidebar-w:   260px;
  --topbar-h:    56px;
  --radius:      10px;
  --shadow:      0 1px 3px rgba(0,0,0,.12);
  --transition:  .18s ease;
}

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

/* El atributo hidden debe ganarle a cualquier display del author stylesheet */
[hidden] { display: none !important; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  font-size: 14px;
  color: var(--c-text);
  background: var(--c-bg);
  height: 100vh;
  overflow: hidden;
}

button { cursor: pointer; border: none; background: none; font: inherit; }
input, textarea, select { font: inherit; }
a { color: var(--c-accent); text-decoration: none; }
p { margin: 0; }

/* ── Login overlay ───────────────────────────────────────────────────────── */
#login-overlay {
  position: fixed;
  inset: 0;
  background: var(--c-sidebar);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

#login-card {
  background: var(--c-surface);
  border-radius: var(--radius);
  padding: 40px;
  width: 360px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}

#login-brand {
  text-align: center;
  margin-bottom: 28px;
}

#login-logo {
  width: 80px;
  height: 80px;
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
}

.brand-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: inherit;
}

#login-brand h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--c-text);
  margin-bottom: 4px;
}

#login-brand p {
  color: var(--c-muted);
  font-size: 13px;
}

.login-version-tag {
  display: block;
  font-size: 11.5px;
  font-family: 'SF Mono', 'Fira Mono', monospace;
  color: var(--c-muted);
  letter-spacing: .05em;
  margin-top: 6px;
}

.login-error {
  color: var(--c-danger);
  font-size: 13px;
  margin-top: 10px;
  text-align: center;
  min-height: 18px;
}

/* ── App layout ──────────────────────────────────────────────────────────── */
#app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
#sidebar {
  background: var(--c-sidebar);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

#brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#brand-name {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  line-height: 1.2;
}

#brand-sub {
  font-size: 11px;
  color: rgba(255,255,255,.4);
  letter-spacing: .05em;
  text-transform: uppercase;
}

#nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: rgba(255,255,255,.6);
  font-size: 13.5px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  text-align: left;
  width: 100%;
}

.nav-item:hover  { background: rgba(255,255,255,.07); color: rgba(255,255,255,.9); }
.nav-item.active { background: var(--c-accent); color: #fff; }

.nav-icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  opacity: .75;
}

.nav-item.active .nav-icon { opacity: 1; }

#sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid rgba(255,255,255,.07);
}

#logout-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 8px;
  color: rgba(255,255,255,.5);
  font-size: 13px;
  width: 100%;
  transition: background var(--transition), color var(--transition);
}

#logout-btn:hover {
  background: rgba(255,255,255,.07);
  color: rgba(255,255,255,.8);
}

.footer-version-btn {
  display: block;
  width: 100%;
  text-align: center;
  font-size: 11px;
  font-family: 'SF Mono', 'Fira Mono', monospace;
  color: #00C2FF;
  padding: 6px 12px 10px;
  letter-spacing: .06em;
  transition: color var(--transition), opacity var(--transition);
  opacity: 0.75;
}

.footer-version-btn:hover {
  color: #00C2FF;
  opacity: 1;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ── Main ────────────────────────────────────────────────────────────────── */
#main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#topbar {
  height: var(--topbar-h);
  padding: 0 24px;
  display: flex;
  align-items: center;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  flex-shrink: 0;
}

#topbar h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--c-text);
}

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

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--c-accent);
  color: #fff;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  transition: background var(--transition);
  white-space: nowrap;
}

.btn-primary:hover { background: var(--c-accent-h); }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--c-text);
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  border: 1px solid var(--c-border);
  transition: background var(--transition);
  white-space: nowrap;
}

.btn-secondary:hover { background: var(--c-bg); }

.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--c-danger);
  color: #fff;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  transition: background var(--transition);
  white-space: nowrap;
}

.btn-danger:hover { background: var(--c-danger-h); }
.btn-full { width: 100%; }

/* ── Section header ──────────────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-input,
.filter-select {
  padding: 7px 10px;
  border: 1px solid var(--c-border);
  border-radius: 8px;
  font-size: 13px;
  background: var(--c-surface);
  color: var(--c-text);
  outline: none;
  transition: border-color var(--transition);
}

.filter-input:focus,
.filter-select:focus { border-color: var(--c-accent); }

.filter-input { width: 200px; }

.count-badge {
  font-size: 13px;
  color: var(--c-muted);
  white-space: nowrap;
}

/* ── Table ───────────────────────────────────────────────────────────────── */
.table-wrapper {
  background: var(--c-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  padding: 11px 16px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--c-border);
  background: #fafafa;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--c-border);
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #fafbff; }

/* ── Avatar ──────────────────────────────────────────────────────────────── */
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--c-accent);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-info    { display: flex; flex-direction: column; gap: 1px; }
.user-name    { font-size: 13.5px; font-weight: 500; }
.user-email   { font-size: 12px; color: var(--c-muted); }

.device-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 22px;
  border-radius: 11px;
  background: var(--c-bg);
  font-size: 12px;
  font-weight: 600;
  color: var(--c-muted);
  padding: 0 7px;
}

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 500;
}

.badge-celex       { background: #ede9fe; color: #5b21b6; }
.badge-gestor      { background: #fef3c7; color: #92400e; }
.badge-all         { background: #f0fdf4; color: #166534; }
.badge-admin       { background: #fee2e2; color: #991b1b; }
.badge-supervisor  { background: #dbeafe; color: #1e40af; }
.badge-asesor      { background: #e0f2fe; color: #0369a1; }
.badge-emprendedor { background: #fef9c3; color: #713f12; }
.badge-success     { background: #d1fae5; color: #065f46; }
.badge-warn        { background: #fef3c7; color: #92400e; }

/* ── Feed grid ───────────────────────────────────────────────────────────── */
.feed-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 16px;
}

.feed-card {
  background: var(--c-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow var(--transition);
  border: 1.5px solid transparent;
}

.feed-card:hover         { box-shadow: 0 4px 14px rgba(0,0,0,.13); }
.feed-card-pinned        { border-color: var(--c-accent); }

.feed-card-img {
  width: 100%;
  height: 155px;
  object-fit: cover;
  display: block;
}

.feed-card-img-placeholder {
  width: 100%;
  height: 56px;
  background: var(--c-bg);
}

.feed-card-body {
  padding: 14px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.feed-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.pin-badge {
  font-size: 11.5px;
  color: var(--c-accent);
  font-weight: 600;
}

.feed-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--c-text);
}

.feed-card-text {
  font-size: 13px;
  color: var(--c-muted);
  line-height: 1.5;
  flex: 1;
}

.feed-card-stats {
  display: flex;
  gap: 12px;
  font-size: 12.5px;
  color: var(--c-muted);
  margin-top: 2px;
  align-items: center;
}

.feed-card-actions {
  display: flex;
  border-top: 1px solid var(--c-border);
}

.action-btn {
  flex: 1;
  padding: 9px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--c-muted);
  text-align: center;
  transition: background var(--transition), color var(--transition);
  border-right: 1px solid var(--c-border);
}

.action-btn:last-child  { border-right: none; }
.action-btn:hover       { background: var(--c-bg); color: var(--c-text); }
.action-danger:hover    { background: #fef2f2; color: var(--c-danger); }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}

.form-group:last-child { margin-bottom: 0; }

.form-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--c-text);
}

.form-input,
.form-textarea {
  padding: 9px 12px;
  border: 1px solid var(--c-border);
  border-radius: 8px;
  font-size: 13.5px;
  background: var(--c-surface);
  color: var(--c-text);
  outline: none;
  transition: border-color var(--transition);
  width: 100%;
}

.form-input:focus,
.form-textarea:focus { border-color: var(--c-accent); }

.form-textarea { resize: vertical; min-height: 90px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 14px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.label-required { color: var(--c-danger);  font-size: 11.5px; font-weight: 400; margin-left: 2px; }
.label-optional { color: var(--c-muted);   font-size: 11.5px; font-weight: 400; margin-left: 2px; }

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
  margin-top: 6px;
}

.toggle-text { color: var(--c-muted); }

.field-hint {
  font-size: 12px;
  color: var(--c-muted);
  margin-top: 4px;
}

/* ── Image upload ─────────────────────────────────────────────────────────── */
.image-upload-area { display: flex; flex-direction: column; gap: 8px; }

.img-preview {
  width: 100%;
  max-height: 175px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}

.img-preview-empty {
  width: 100%;
  height: 70px;
  border: 2px dashed var(--c-border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-muted);
  font-size: 13px;
}

.image-upload-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.image-upload-controls .form-input { flex: 1; min-width: 140px; }

.upload-status { font-size: 12.5px; min-height: 16px; color: var(--c-muted); }
.status-ok     { color: var(--c-success); }
.status-error  { color: var(--c-danger); }

/* ── Card ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--c-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  max-width: 520px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--c-text);
}

/* ── Send result ──────────────────────────────────────────────────────────── */
.send-result {
  margin-top: 14px;
  padding: 11px 14px;
  border-radius: 8px;
  font-size: 13.5px;
  line-height: 1.4;
}

.send-ok    { background: #d1fae5; color: #065f46; }
.send-error { background: #fee2e2; color: #991b1b; }

/* ── Versions ─────────────────────────────────────────────────────────────── */
.versions-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 580px;
}

.version-card {
  background: var(--c-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.version-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.version-tag  { font-size: 15px; font-weight: 700; color: var(--c-text); margin-right: 8px; }
.version-date { font-size: 12.5px; }

.version-changes {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.version-changes li {
  font-size: 13.5px;
  color: var(--c-muted);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.4;
}

.version-changes li::before {
  content: '•';
  color: var(--c-accent);
  flex-shrink: 0;
  margin-top: 1px;
  font-weight: 700;
}

/* ── Modal ───────────────────────────────────────────────────────────────── */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.48);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 20px;
}

#modal-card {
  background: var(--c-surface);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--c-border);
  flex-shrink: 0;
}

#modal-title { font-size: 15px; font-weight: 600; }

.modal-close-btn {
  color: var(--c-muted);
  font-size: 15px;
  line-height: 1;
  padding: 4px 7px;
  border-radius: 6px;
  transition: background var(--transition);
}

.modal-close-btn:hover { background: var(--c-bg); }

#modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

#modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--c-border);
  flex-shrink: 0;
}

/* ── Toast ───────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
  pointer-events: none;
}

.toast {
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,.22);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .22s ease, transform .22s ease;
  pointer-events: auto;
  max-width: 320px;
}

.toast.show    { opacity: 1; transform: translateY(0); }
.toast-success { background: #064e3b; color: #d1fae5; }
.toast-error   { background: #7f1d1d; color: #fee2e2; }
.toast-info    { background: var(--c-sidebar); color: rgba(255,255,255,.9); }

/* ── States ──────────────────────────────────────────────────────────────── */
.loading, .empty-msg {
  text-align: center;
  padding: 60px 20px;
  color: var(--c-muted);
  font-size: 14px;
}

.error-msg {
  text-align: center;
  padding: 60px 20px;
  color: var(--c-danger);
  font-size: 14px;
}

.text-muted { color: var(--c-muted); }

/* ── Password field ──────────────────────────────────────────────────────── */
.password-field {
  position: relative;
  display: flex;
  align-items: center;
}

.password-field .form-input { padding-right: 42px; }

.password-toggle {
  position: absolute;
  right: 10px;
  color: var(--c-muted);
  display: flex;
  align-items: center;
  padding: 4px;
  border-radius: 4px;
  transition: color var(--transition);
  line-height: 0;
}

.password-toggle:hover { color: var(--c-text); }

/* ── Quill WYSIWYG ───────────────────────────────────────────────────────── */
.quill-wrapper {
  border: 1px solid var(--c-border);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color var(--transition);
}

.quill-wrapper:focus-within { border-color: var(--c-accent); }

.quill-wrapper .ql-toolbar.ql-snow {
  border: none !important;
  border-bottom: 1px solid var(--c-border) !important;
  padding: 6px 8px !important;
  background: #fafafa;
}

.quill-wrapper .ql-container.ql-snow {
  border: none !important;
  font-family: inherit !important;
  font-size: 13.5px !important;
}

.quill-wrapper .ql-editor {
  min-height: 100px;
  max-height: 200px;
  overflow-y: auto;
  padding: 10px 12px;
  line-height: 1.5;
}

.quill-wrapper .ql-editor.ql-blank::before {
  font-style: normal;
  color: var(--c-muted);
  opacity: 0.65;
  left: 12px;
}

/* ── Profile ─────────────────────────────────────────────────────────────── */
.profile-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 520px;
}

.profile-card { padding: 20px 24px; }

.profile-avatar-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.avatar-lg {
  width: 56px !important;
  height: 56px !important;
  font-size: 18px !important;
  border-radius: 50%;
}

/* ── Feed stat buttons ───────────────────────────────────────────────────── */
.stat-btn {
  background: none;
  border: none;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--c-muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.stat-btn:hover {
  background: var(--c-bg);
  color: var(--c-text);
}

/* ── Notifications — failed count ────────────────────────────────────────── */
.count-failed {
  background: #fee2e2;
  color: var(--c-danger);
}

/* ── Versions switcher ───────────────────────────────────────────────────── */
.versions-switcher {
  display: flex;
  align-items: center;
  gap: 10px;
}

.versions-switcher-label {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--c-text);
  white-space: nowrap;
}
