/* ===== Variables ===== */
:root {
  --bg: #FBF7F3;
  --surface: #FFFFFF;
  --surface-2: #F5EDE5;
  --primary: #C4815A;
  --primary-dark: #A06340;
  --primary-light: #F2E0D4;
  --primary-xlight: #FBF2EC;
  --text: #3D2B1F;
  --text-muted: #8B6E5A;
  --border: #E5D5C8;
  --sidebar-bg: #2D1F17;
  --sidebar-text: #F5EDE6;
  --sidebar-muted: #A08878;
  --sidebar-active-bg: rgba(196, 129, 90, 0.2);
  --sidebar-active-text: #F2C4A0;
  --success: #6B9E70;
  --success-light: #EBF5EC;
  --danger: #B85450;
  --danger-light: #FAEAEA;
  --warning: #C8943A;
  --warning-light: #FEF5E7;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 2px 12px rgba(61, 43, 31, 0.08);
  --shadow-md: 0 4px 24px rgba(61, 43, 31, 0.12);
  --transition: 0.18s ease;
  --sidebar-width: 240px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; }
input, textarea, select, button { font-family: var(--font); }

/* ===== Layout con sidebar ===== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-logo {
  padding: 28px 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.sidebar-logo h1 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--sidebar-active-text);
  letter-spacing: 0.01em;
}
.sidebar-logo p {
  font-size: 0.75rem;
  color: var(--sidebar-muted);
  margin-top: 3px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  opacity: 0.75;
}
.sidebar-nav a:hover {
  background: rgba(255,255,255,0.07);
  opacity: 1;
}
.sidebar-nav a.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  opacity: 1;
}
.sidebar-nav .nav-icon {
  font-size: 1.1rem;
  width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid rgba(255,255,255,0.07);
  font-size: 0.75rem;
  color: var(--sidebar-muted);
}

/* ===== Main content ===== */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.page-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 20px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.page-header h2 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
}
.page-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-body {
  padding: 28px 32px;
  flex: 1;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background var(--transition), transform 0.1s, box-shadow var(--transition);
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }

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

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

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover { background: #9D3F3C; }

.btn-success {
  background: var(--success);
  color: white;
}
.btn-success:hover { background: #5A8A5F; }

.btn-sm {
  padding: 6px 13px;
  font-size: 0.8rem;
}
.btn-icon {
  padding: 8px;
  border-radius: var(--radius-sm);
}

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}
.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

/* ===== Forms ===== */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.form-control {
  padding: 9px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(196, 129, 90, 0.15);
}
.form-control::placeholder { color: #C0A898; }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

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

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.form-check input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}
.form-check label { font-size: 0.9rem; cursor: pointer; }

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-success { background: var(--success-light); color: #3A7040; }
.badge-danger  { background: var(--danger-light); color: #8B2E2B; }
.badge-warning { background: var(--warning-light); color: #8B5E1A; }
.badge-neutral { background: var(--surface-2); color: var(--text-muted); }
.badge-primary { background: var(--primary-light); color: var(--primary-dark); }

/* ===== Table ===== */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
thead th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 11px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--primary-xlight); }
tbody td {
  padding: 12px 16px;
  color: var(--text);
  vertical-align: middle;
}

/* ===== Modal ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 12, 8, 0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity var(--transition);
}
.modal-backdrop.visible { opacity: 1; }

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(16px);
  transition: transform var(--transition);
}
.modal-backdrop.visible .modal { transform: translateY(0); }

.modal-lg { max-width: 700px; }

.modal-header {
  padding: 20px 24px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.05rem; font-weight: 600; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  padding: 4px;
  border-radius: 4px;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--text); }

.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 16px 24px 20px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--border);
}

/* ===== Search ===== */
.search-box {
  position: relative;
}
.search-box .search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
  pointer-events: none;
}
.search-box input {
  padding-left: 34px;
}

/* ===== Tags/Chips ===== */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 500;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.chip-primary {
  background: var(--primary-light);
  color: var(--primary-dark);
  border-color: var(--primary-light);
}

/* ===== Empty state ===== */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}
.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.4;
}
.empty-state h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}
.empty-state p { font-size: 0.88rem; }

/* ===== Tabs ===== */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
}
.tab-btn {
  background: none;
  border: none;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color var(--transition), border-color var(--transition);
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ===== Toast notifications ===== */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 13px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  animation: slideInToast 0.25s ease;
}
.toast-success { border-left: 3px solid var(--success); }
.toast-error   { border-left: 3px solid var(--danger); }
.toast-info    { border-left: 3px solid var(--primary); }
@keyframes slideInToast {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

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

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(251, 247, 243, 0.7);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== Login page ===== */
.login-page {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  padding: 48px 40px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.login-logo {
  font-size: 2.8rem;
  margin-bottom: 12px;
}
.login-card h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.login-card p {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 32px;
}
.login-card .form-control {
  text-align: center;
  font-size: 1.1rem;
  letter-spacing: 0.15em;
  padding: 13px;
}
.login-btn {
  width: 100%;
  padding: 13px;
  font-size: 1rem;
  margin-top: 8px;
  border-radius: var(--radius-sm);
}
.login-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 10px;
  display: none;
}

/* ===== FullCalendar overrides ===== */
.fc {
  font-family: var(--font) !important;
}
.fc .fc-toolbar-title {
  font-size: 1.1rem !important;
  font-weight: 600 !important;
  color: var(--text) !important;
}
.fc .fc-button {
  background: var(--surface) !important;
  border: 1.5px solid var(--border) !important;
  color: var(--text) !important;
  font-weight: 500 !important;
  font-size: 0.85rem !important;
  box-shadow: none !important;
  transition: background var(--transition) !important;
}
.fc .fc-button:hover {
  background: var(--surface-2) !important;
}
.fc .fc-button-primary:not(.fc-button-active):hover {
  background: var(--surface-2) !important;
  border-color: var(--border) !important;
}
.fc .fc-button-active, .fc .fc-button-primary.fc-button-active {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: white !important;
}
.fc .fc-col-header-cell-cushion {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.fc .fc-daygrid-day-number {
  color: var(--text);
  font-size: 0.85rem;
}
.fc .fc-event {
  border-radius: 4px !important;
  border: none !important;
  font-size: 0.8rem !important;
  font-weight: 500 !important;
  cursor: pointer !important;
}
.fc-day-today .fc-daygrid-day-number {
  background: var(--primary) !important;
  color: white !important;
  border-radius: 50% !important;
  width: 26px !important;
  height: 26px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}
.fc .fc-scrollgrid { border-color: var(--border) !important; }
.fc .fc-scrollgrid-section > td { border-color: var(--border) !important; }
.fc .fc-daygrid-day { border-color: var(--border) !important; }

/* ===== Quill overrides ===== */
.ql-toolbar.ql-snow {
  border-color: var(--border) !important;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0 !important;
  background: var(--surface-2) !important;
}
.ql-container.ql-snow {
  border-color: var(--border) !important;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm) !important;
  font-family: var(--font) !important;
  font-size: 0.92rem !important;
  min-height: 300px;
}
.ql-editor {
  min-height: 300px;
  line-height: 1.7 !important;
  color: var(--text) !important;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .page-header { padding: 16px 20px; }
  .page-body { padding: 20px; }
  .form-row { grid-template-columns: 1fr; }
  .login-card { padding: 36px 24px; }
}
