/* =============================================
   BUFALOS HC HUB - Estilos Principales
   Paleta Oficial Bufalos: Rojo #A72020 | Gris #5B585D | Blanco #FFFFFF
   ============================================= */

:root {
  --color-primary: #A72020;
  --color-primary-dark: #8A1A1A;
  --color-primary-light: #C94040;
  --color-secondary: #5B585D;
  --color-secondary-dark: #434147;
  --color-secondary-light: #7A7780;
  --color-snow: #F5F5F5;
  --color-dark: #2B2828;
  --color-gray: #6B7280;
  --color-success: #10B981;
  --color-warning: #F59E0B;
  --color-error: #EF4444;
  --sidebar-width: 260px;
  --header-height: 64px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #F0F2F5;
  color: var(--color-dark);
  overflow-x: hidden;
}

/* ─── SCROLLBAR ─────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: var(--color-primary); border-radius: 3px; }

/* ─── LOGIN ──────────────────────────────────────────────────────────────── */
#login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #1E1C1C 0%, #2B2828 50%, var(--color-primary-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

#login-page::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(167,32,32,0.2) 0%, transparent 70%);
  top: -100px; right: -100px;
  border-radius: 50%;
}

#login-page::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(91,88,93,0.25) 0%, transparent 70%);
  bottom: -50px; left: -50px;
  border-radius: 50%;
}

.login-card {
  background: white;
  border-radius: 24px;
  padding: 48px 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 25px 60px rgba(0,0,0,0.3);
  position: relative;
  z-index: 10;
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo img {
  height: 80px;
  margin-bottom: 16px;
}

.login-logo h1 {
  font-size: 28px;
  font-weight: 800;
  color: var(--color-dark);
  letter-spacing: -0.5px;
}

.login-logo p {
  color: var(--color-gray);
  font-size: 14px;
  margin-top: 4px;
}

.kirp-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary-dark));
  color: white;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  margin-top: 8px;
}

/* ─── LAYOUT ──────────────────────────────────────────────────────────────── */
#app-layout {
  display: flex;
  min-height: 100vh;
}

/* ─── SIDEBAR ─────────────────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, #1E1C1C 0%, #2B2828 100%);
  color: white;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo-icon {
  width: 42px; height: 42px;
  background: var(--color-primary);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 900;
  color: white;
  flex-shrink: 0;
}

.sidebar-logo-text h2 {
  font-size: 16px;
  font-weight: 800;
  color: white;
  letter-spacing: -0.3px;
}

.sidebar-logo-text p {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  margin-top: 1px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
}

.nav-section {
  margin-bottom: 24px;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: rgba(255,255,255,0.3);
  padding: 0 8px;
  margin-bottom: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: rgba(255,255,255,0.6);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
  text-decoration: none;
}

.nav-item:hover {
  background: rgba(255,255,255,0.08);
  color: white;
}

.nav-item.active {
  background: var(--color-primary);
  color: white;
  box-shadow: 0 4px 12px rgba(230,58,46,0.4);
}

.nav-item .nav-icon {
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.nav-item .nav-badge {
  margin-left: auto;
  background: var(--color-primary);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.nav-item.active .nav-badge {
  background: rgba(255,255,255,0.3);
}

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

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s;
}

.user-info:hover { background: rgba(255,255,255,0.08); }

.user-avatar {
  width: 36px; height: 36px;
  background: var(--color-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: white;
  flex-shrink: 0;
}

.user-details { flex: 1; overflow: hidden; }
.user-name { font-size: 13px; font-weight: 600; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: rgba(255,255,255,0.4); }

/* ─── MAIN CONTENT ────────────────────────────────────────────────────────── */
#main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── HEADER ──────────────────────────────────────────────────────────────── */
#top-header {
  height: var(--header-height);
  background: white;
  border-bottom: 1px solid #E5E7EB;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.header-title {
  flex: 1;
  font-size: 18px;
  font-weight: 700;
  color: var(--color-dark);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ─── PAGE CONTENT ────────────────────────────────────────────────────────── */
.page-content {
  padding: 24px;
  flex: 1;
}

/* ─── CARDS ───────────────────────────────────────────────────────────────── */
.card {
  background: white;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

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

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-dark);
}

/* ─── STATS CARDS ────────────────────────────────────────────────────────── */
.stat-card {
  background: white;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  border-left: 4px solid var(--color-primary);
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
}

.stat-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--color-dark);
  line-height: 1;
}

.stat-label {
  font-size: 13px;
  color: var(--color-gray);
  margin-top: 4px;
  font-weight: 500;
}

.stat-change {
  font-size: 12px;
  font-weight: 600;
  margin-top: 8px;
}

.stat-change.up { color: var(--color-success); }
.stat-change.down { color: var(--color-error); }

/* ─── BUTTONS ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--color-primary);
  color: white;
  box-shadow: 0 4px 12px rgba(167,32,32,0.3);
}

.btn-primary:hover {
  background: var(--color-primary-dark);
  box-shadow: 0 6px 16px rgba(167,32,32,0.45);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--color-secondary);
  color: white;
  box-shadow: 0 4px 12px rgba(91,88,93,0.3);
}

.btn-secondary:hover {
  background: var(--color-secondary-dark);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: var(--color-primary);
  border: 2px solid var(--color-primary);
}

.btn-outline:hover {
  background: var(--color-primary);
  color: white;
}

.btn-ghost {
  background: transparent;
  color: var(--color-gray);
  border: 1px solid #E5E7EB;
}

.btn-ghost:hover {
  background: #F9FAFB;
  color: var(--color-dark);
}

/* Sidebar logout button - dark background needs special treatment */
.btn-logout {
  background: transparent;
  color: rgba(255,255,255,0.5);
  border: 1px solid rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-logout:hover {
  background: rgba(167,32,32,0.25);
  color: rgba(255,255,255,0.9);
  border-color: rgba(167,32,32,0.45);
}

/* Sidebar logo image container */
.sidebar-logo-img {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 14px 24px; font-size: 16px; }
.btn-icon { padding: 10px; min-width: 40px; justify-content: center; }

.btn-kirpai {
  background: linear-gradient(135deg, var(--color-primary), #8A1A1A);
  color: white;
  box-shadow: 0 4px 15px rgba(167,32,32,0.35);
}

.btn-kirpai:hover {
  box-shadow: 0 6px 20px rgba(167,32,32,0.55);
  transform: translateY(-1px);
}

/* ─── FORMS ───────────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-dark);
  margin-bottom: 6px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid #E5E7EB;
  border-radius: 10px;
  font-size: 14px;
  color: var(--color-dark);
  background: white;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(167,32,32,0.12);
}

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

/* ─── MODALS ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.modal {
  background: white;
  border-radius: 20px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 60px rgba(0,0,0,0.3);
}

.modal-lg { max-width: 800px; }
.modal-xl { max-width: 1000px; }

.modal-header {
  padding: 24px 24px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-dark);
}

.modal-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: #F3F4F6;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-gray);
  font-size: 16px;
  transition: background 0.2s;
}

.modal-close:hover { background: #E5E7EB; }

.modal-body { padding: 24px; }
.modal-footer {
  padding: 0 24px 24px;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* ─── CALENDAR ────────────────────────────────────────────────────────────── */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.calendar-day-header {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--color-gray);
  text-transform: uppercase;
  padding: 8px 0;
}

.calendar-day {
  min-height: 100px;
  background: white;
  border-radius: 12px;
  padding: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
}

.calendar-day:hover { border-color: var(--color-primary); }
.calendar-day.today { border-color: var(--color-primary); background: #FFF5F5; }
.calendar-day.other-month { background: #F9FAFB; opacity: 0.5; }

.calendar-day-num {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-dark);
  margin-bottom: 4px;
}

.calendar-day.today .calendar-day-num {
  background: var(--color-primary);
  color: white;
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.calendar-post-chip {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 6px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
  cursor: pointer;
}

.chip-facebook { background: #1877F2; color: white; }
.chip-instagram { background: linear-gradient(135deg, #F58529, #DD2A7B); color: white; }
.chip-ad { background: var(--color-secondary); color: white; }
.chip-draft { background: #E5E7EB; color: var(--color-gray); }

/* ─── NETWORK BADGES ──────────────────────────────────────────────────────── */
.network-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
}

.badge-facebook { background: #E8F0FF; color: #1877F2; }
.badge-instagram { background: #FCEEFF; color: #C13584; }

/* ─── STATUS BADGES ──────────────────────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.status-draft { background: #F3F4F6; color: #6B7280; }
.status-scheduled { background: #EFF6FF; color: #3B82F6; }
.status-published { background: #ECFDF5; color: #10B981; }
.status-cancelled { background: #FEF2F2; color: #EF4444; }
.status-pending { background: #FFFBEB; color: #F59E0B; }
.status-in_progress { background: #EFF6FF; color: #3B82F6; }
.status-completed { background: #ECFDF5; color: #10B981; }
.status-active { background: #ECFDF5; color: #10B981; }
.status-overdue { background: #FEF2F2; color: #EF4444; }

/* ─── PRIORITY BADGES ─────────────────────────────────────────────────────── */
.priority-low { background: #F0FDF4; color: #22C55E; border: 1px solid #BBF7D0; }
.priority-medium { background: #FFFBEB; color: #F59E0B; border: 1px solid #FDE68A; }
.priority-high { background: #FFF7ED; color: #EA580C; border: 1px solid #FED7AA; }
.priority-urgent { background: #FEF2F2; color: #EF4444; border: 1px solid #FECACA; }

/* ─── KIRP AI PANEL ───────────────────────────────────────────────────────── */
.kirpai-panel {
  background: linear-gradient(135deg, #1E1C1C 0%, #3A2020 100%);
  border-radius: 16px;
  padding: 24px;
  color: white;
}

.kirpai-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.kirpai-logo {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary-dark));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 14px;
}

.kirpai-name { font-size: 18px; font-weight: 800; }
.kirpai-tagline { font-size: 12px; color: rgba(255,255,255,0.5); }

.kirpai-chat {
  background: rgba(255,255,255,0.05);
  border-radius: 12px;
  padding: 16px;
  min-height: 200px;
  max-height: 350px;
  overflow-y: auto;
  margin-bottom: 16px;
}

.chat-message {
  margin-bottom: 16px;
  display: flex;
  gap: 10px;
}

.chat-message.user { flex-direction: row-reverse; }

.chat-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

.chat-avatar.ai {
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  color: white;
}

.chat-avatar.human { background: rgba(255,255,255,0.2); color: white; }

.chat-bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
}

.chat-bubble.ai { background: rgba(255,255,255,0.12); color: white; border-radius: 4px 14px 14px 14px; }
.chat-bubble.human { background: var(--color-primary); color: white; border-radius: 14px 4px 14px 14px; }

.kirpai-input-area {
  display: flex;
  gap: 8px;
}

.kirpai-input {
  flex: 1;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 10px;
  padding: 10px 14px;
  color: white;
  font-size: 14px;
  outline: none;
}

.kirpai-input::placeholder { color: rgba(255,255,255,0.4); }
.kirpai-input:focus { border-color: var(--color-primary); }


/* ─── PROGRESS BAR ────────────────────────────────────────────────────────── */
.progress-bar {
  height: 8px;
  background: #E5E7EB;
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-secondary-dark));
  border-radius: 4px;
  transition: width 0.5s ease;
}

/* ─── TABS ────────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 2px solid #E5E7EB;
  margin-bottom: 24px;
  gap: 4px;
}

.tab {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-gray);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
  border-radius: 8px 8px 0 0;
}

.tab:hover { color: var(--color-dark); background: #F9FAFB; }
.tab.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }

/* ─── TABLE ───────────────────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-gray);
  padding: 12px 16px;
  background: #F9FAFB;
  border-bottom: 1px solid #E5E7EB;
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid #F3F4F6;
  font-size: 14px;
  color: var(--color-dark);
}

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

/* ─── NETWORK CHECKBOXES ──────────────────────────────────────────────────── */
.network-selector {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.network-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: 2px solid #E5E7EB;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.network-option:hover { border-color: var(--color-primary); }
.network-option.selected-facebook { border-color: #1877F2; background: #F0F5FF; }
.network-option.selected-instagram { border-color: #C13584; background: #FEF0FF; }

/* ─── IMAGE UPLOAD ────────────────────────────────────────────────────────── */
.image-upload-area {
  border: 2px dashed #D1D5DB;
  border-radius: 12px;
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.image-upload-area:hover {
  border-color: var(--color-primary);
  background: #FFF5F5;
}

.image-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.image-preview-item {
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}

.image-preview-item img {
  width: 100%; height: 100%;
  object-fit: cover;
}

/* ─── TOAST / ALERTS ─────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: white;
  border-radius: 12px;
  padding: 14px 18px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
  max-width: 400px;
  animation: slideInRight 0.3s ease;
  border-left: 4px solid var(--color-primary);
}

.toast.success { border-color: var(--color-success); }
.toast.error { border-color: var(--color-error); }
.toast.warning { border-color: var(--color-warning); }

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

/* ─── LOADING ─────────────────────────────────────────────────────────────── */
.loading-spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.page-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  flex-direction: column;
  gap: 16px;
  color: var(--color-gray);
}

.loader-ring {
  width: 48px; height: 48px;
  border: 4px solid #E5E7EB;
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* ─── EMPTY STATE ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--color-gray);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h3 { font-size: 18px; font-weight: 700; color: var(--color-dark); margin-bottom: 8px; }
.empty-state p { font-size: 14px; max-width: 300px; margin: 0 auto 20px; }

/* ─── RESPONSIVE ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  #sidebar { transform: translateX(-100%); }
  #sidebar.open { transform: translateX(0); }
  #main-content { margin-left: 0; }
  .calendar-grid { grid-template-columns: repeat(7, 1fr); gap: 2px; }
  .calendar-day { min-height: 60px; padding: 4px; }
  .page-content { padding: 16px; }
}

/* ─── FINANCE MODULE ──────────────────────────────────────────────────────── */
.billing-card {
  background: linear-gradient(135deg, #1E1C1C 0%, #3A2020 100%);
  border-radius: 20px;
  padding: 28px;
  color: white;
  position: relative;
  overflow: hidden;
}

.billing-card::before {
  content: '';
  position: absolute;
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(167,32,32,0.25) 0%, transparent 70%);
  top: -60px; right: -40px;
  border-radius: 50%;
}

.billing-amount {
  font-size: 42px;
  font-weight: 900;
  color: white;
}

.billing-label { font-size: 14px; color: rgba(255,255,255,0.6); }
.billing-date { font-size: 16px; font-weight: 600; color: white; margin-top: 4px; }

/* ─── ANIMATIONS ──────────────────────────────────────────────────────────── */
.fade-in { animation: fadeIn 0.3s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.slide-up { animation: slideUp 0.4s ease; }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── KIRP AI — MARKDOWN RENDERING ─────────────────────────────────────────── */
.kirp-response {
  font-size: 14px;
  line-height: 1.7;
  color: #1A1A2E;
}
.kirp-response h2 {
  font-size: 18px;
  font-weight: 800;
  color: #A72020;
  margin: 16px 0 8px;
  padding-bottom: 4px;
  border-bottom: 2px solid #FEE2E2;
}
.kirp-response h3 {
  font-size: 16px;
  font-weight: 700;
  color: #1A1A2E;
  margin: 14px 0 6px;
}
.kirp-response h4 {
  font-size: 14px;
  font-weight: 700;
  color: #5B585D;
  margin: 12px 0 4px;
}
.kirp-response p {
  margin-bottom: 10px;
}
.kirp-response ul,
.kirp-response ol {
  padding-left: 20px;
  margin-bottom: 10px;
}
.kirp-response li {
  margin-bottom: 4px;
}
.kirp-response strong { font-weight: 700; color: #1A1A2E; }
.kirp-response em { font-style: italic; color: #374151; }
.kirp-response code {
  background: #F3F4F6;
  border: 1px solid #E5E7EB;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 12px;
  font-family: 'Courier New', monospace;
  color: #A72020;
}
.kirp-response hr {
  border: none;
  border-top: 1px solid #E5E7EB;
  margin: 14px 0;
}

/* ─── KIRP TEAM — PANEL DE FEEDBACK / INSIGHTS ──────────────────────────── */
.kirp-feedback-panel {
  background: linear-gradient(135deg, #1E1C1C 0%, #2B2020 100%);
  border-radius: 16px;
  padding: 20px;
  margin-top: 20px;
  border: 1px solid rgba(167,32,32,0.35);
  box-shadow: 0 4px 20px rgba(0,0,0,0.18);
}
.kirp-feedback-panel .panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.kirp-feedback-panel .panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 700;
  color: #FFFFFF;
}
.kirp-feedback-panel .panel-title .kirp-badge {
  background: linear-gradient(135deg, #A72020, #8A1A1A);
  color: white;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.kirp-feedback-item {
  background: rgba(255,255,255,0.06);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  border-left: 3px solid rgba(167,32,32,0.55);
  transition: background 0.2s;
}
.kirp-feedback-item.pinned {
  border-left-color: #F59E0B;
  background: rgba(245,158,11,0.08);
}
.kirp-feedback-item .item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.kirp-feedback-item .item-author {
  display: flex;
  align-items: center;
  gap: 8px;
}
.kirp-feedback-item .author-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #A72020, #8A1A1A);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  color: white;
  flex-shrink: 0;
}
.kirp-feedback-item .author-name {
  font-size: 12px;
  font-weight: 700;
  color: #F3F4F6;
}
.kirp-feedback-item .item-date {
  font-size: 11px;
  color: rgba(255,255,255,0.4);
}
.kirp-feedback-item .item-content {
  font-size: 13px;
  color: rgba(255,255,255,0.85);
  line-height: 1.6;
}
.kirp-feedback-item .item-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  justify-content: flex-end;
}
.kirp-feedback-item .item-actions button {
  background: rgba(255,255,255,0.1);
  border: none;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  transition: all 0.2s;
}
.kirp-feedback-item .item-actions button:hover {
  background: rgba(255,255,255,0.2);
  color: white;
}
.kirp-feedback-item .item-actions .btn-pin-active {
  color: #F59E0B;
}
.kirp-feedback-empty {
  text-align: center;
  padding: 24px;
  color: rgba(255,255,255,0.35);
  font-size: 13px;
}
.kirp-feedback-add-btn {
  background: rgba(167,32,32,0.15);
  border: 1px dashed rgba(167,32,32,0.4);
  border-radius: 10px;
  padding: 10px;
  text-align: center;
  cursor: pointer;
  color: #C94040;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s;
  margin-top: 8px;
}
.kirp-feedback-add-btn:hover {
  background: rgba(167,32,32,0.25);
  border-color: rgba(167,32,32,0.65);
}

/* ─── RECURSOS GRÁFICOS ─────────────────────────────────────────────────── */
.resource-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}
.resource-card {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  border: 2px solid transparent;
}
.resource-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
  border-color: var(--color-primary);
}
.resource-card .resource-thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: #F3F4F6;
  display: block;
}
.resource-card .resource-thumb-placeholder {
  width: 100%;
  aspect-ratio: 1;
  background: #F3F4F6;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9CA3AF;
  font-size: 32px;
}
.resource-card .resource-info {
  padding: 10px 12px;
}
.resource-card .resource-name {
  font-size: 12px;
  font-weight: 700;
  color: #1A1A2E;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}
.resource-card .resource-meta {
  font-size: 11px;
  color: #9CA3AF;
}

/* ─── IMAGE PICKER MODAL ─────────────────────────────────────────────────── */
.image-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
  max-height: 380px;
  overflow-y: auto;
  padding: 4px;
}
.picker-item {
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.2s, transform 0.2s;
  background: #F3F4F6;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.picker-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.picker-item:hover { border-color: var(--color-primary); transform: scale(1.03); }
.picker-item.selected { border-color: var(--color-primary); }
.picker-item.selected::after {
  content: '\f00c';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--color-primary);
  color: white;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
}
.picker-item-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.55);
  color: white;
  font-size: 9px;
  padding: 2px 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── UPLOAD ZONE ─────────────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed #D1D5DB;
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #FAFAFA;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--color-primary);
  background: #FFF5F5;
}
.upload-zone i { font-size: 28px; color: #9CA3AF; margin-bottom: 8px; }
.upload-zone.dragover i { color: var(--color-primary); }
.upload-zone p { font-size: 13px; color: #6B7280; }
.upload-zone .file-limit { font-size: 11px; color: #9CA3AF; margin-top: 4px; }

/* ─── PALETA BUFALOS GLOBAL OVERRIDE ─────────────────────────────────────── */
/* nav activo y badges usan el rojo oficial */
.nav-item.active { background: var(--color-primary); box-shadow: 0 4px 12px rgba(167,32,32,0.45); }
.nav-item .nav-badge { background: var(--color-primary); }
.stat-card { border-left-color: var(--color-primary); }
.calendar-day.today { border-color: var(--color-primary); background: #FDF2F2; }
.calendar-day.today .calendar-day-num { background: var(--color-primary); }
.chip-ad { background: var(--color-secondary); }
.tab.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }
.chat-bubble.human { background: var(--color-primary); }
.chat-avatar.ai { background: linear-gradient(135deg, var(--color-primary), var(--color-secondary-dark)); }
.toast { border-left-color: var(--color-primary); }
.loader-ring { border-top-color: var(--color-primary); }

/* Scrollbar en rojo oficial */
::-webkit-scrollbar-thumb { background: var(--color-primary); }

/* ─── KIRP AI — POSICIÓN VISIBLE ──────────────────────────────────────────── */
/* Asegura que el panel Kirp AI no quede enterrado al fondo */
.kirpai-panel-sticky {
  position: sticky;
  top: 80px;
}

/* ─── RECURSOS GRÁFICOS — SELECCIÓN MÚLTIPLE DESCARGA ───────────────────── */
.resource-card.selectable { cursor: pointer; position: relative; }
.resource-card.selectable .res-select-check {
  position: absolute;
  top: 8px; left: 8px;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.8);
  background: rgba(0,0,0,0.3);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: white;
  transition: all 0.2s;
  z-index: 2;
}
.resource-card.selected { border-color: var(--color-primary); }
.resource-card.selected .res-select-check {
  background: var(--color-primary);
  border-color: var(--color-primary);
}
.resource-card.selected .res-select-check::after {
  content: '✓';
  font-weight: 900;
}

/* Barra acción selección múltiple */
#res-bulk-bar {
  position: fixed;
  bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1E1C1C;
  border: 1px solid rgba(167,32,32,0.4);
  border-radius: 50px;
  padding: 10px 24px;
  display: flex; align-items: center; gap: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.35);
  z-index: 500;
  color: white; font-size: 14px; font-weight: 600;
  transition: opacity 0.2s, transform 0.2s;
}
#res-bulk-bar.hidden { opacity: 0; pointer-events: none; transform: translateX(-50%) translateY(20px); }

/* ─── GERENTE — BADGE ROL ─────────────────────────────────────────────────── */
.status-gerente { background: #FFF7ED; color: #C2410C; }
.role-badge-gerente {
  display: inline-flex; align-items: center; gap: 4px;
  background: linear-gradient(135deg, #5B585D, #434147);
  color: white; padding: 3px 10px;
  border-radius: 20px; font-size: 11px; font-weight: 700;
}

/* ─── TASK TIMELINE ───────────────────────────────────────────────────────── */
.task-timeline-entry {
  position: relative;
  padding-bottom: 20px;
}
.task-timeline-entry:last-child {
  padding-bottom: 0;
}
.task-timeline-entry .timeline-line {
  position: absolute;
  left: 19px; top: 38px; bottom: 0;
  width: 2px;
  background: linear-gradient(to bottom, rgba(167,32,32,0.3), #E5E7EB);
}

/* Task card hover en actionable detail */
.task-card-clickable {
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.task-card-clickable:hover {
  border-color: var(--color-primary) !important;
  box-shadow: 0 2px 8px rgba(167,32,32,0.12);
}
