/*
 * custom.css — Shim de clases Tailwind + estilos globales UI
 * -----------------------------------------------------------
 * La app usa clases de Tailwind CSS en sus templates pero el proyecto no
 * incluye Tailwind como dependencia (sólo Bootstrap 5 + AdminLTE).
 * Este fichero define esas clases con los valores estándar de Tailwind
 * para que los estilos visuales funcionen correctamente sin migrar
 * los templates uno a uno.
 */

/* ── Layout ───────────────────────────────────────────────── */
.flex        { display: flex !important; }
.inline-flex { display: inline-flex !important; }
.block       { display: block !important; }
.grid        { display: grid !important; }
.relative    { position: relative !important; }
.overflow-x-auto { overflow-x: auto !important; }
.w-full      { width: 100% !important; }
.h-full      { height: 100% !important; }
.min-w-0     { min-width: 0 !important; }
.flex-1      { flex: 1 1 0% !important; }
.flex-wrap   { flex-wrap: wrap !important; }
.flex-shrink-0 { flex-shrink: 0 !important; }

/* ── Flex alignment ───────────────────────────────────────── */
.items-center  { align-items: center !important; }
.items-start   { align-items: flex-start !important; }
.items-end     { align-items: flex-end !important; }
.justify-between { justify-content: space-between !important; }
.justify-center  { justify-content: center !important; }

/* ── Gap ──────────────────────────────────────────────────── */
.gap-1  { gap: 0.25rem !important; }
.gap-2  { gap: 0.5rem !important; }
.gap-3  { gap: 0.75rem !important; }
.gap-x-2  { column-gap: 0.5rem !important; }
.gap-y-2  { row-gap:    0.5rem !important; }

/* ── Grid columns (responsive at ≥768px) ─────────────────── */
@media (min-width: 768px) {
  .md\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .md\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
  .md\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
  .md\:grid-cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)) !important; }
  .md\:grid-cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)) !important; }
  .md\:col-span-2  { grid-column: span 2 / span 2 !important; }
}

/* ── Spacing helpers ─────────────────────────────────────── */
.space-x-1 > * + * { margin-left: 0.25rem; }
.space-x-2 > * + * { margin-left: 0.50rem; }
.space-x-3 > * + * { margin-left: 0.75rem; }
.space-y-1 > * + * { margin-top: 0.25rem; }
.space-y-2 > * + * { margin-top: 0.50rem; }

/* ── Typography ───────────────────────────────────────────── */
.text-xs        { font-size: 0.75rem !important;  line-height: 1rem !important; }
.text-sm        { font-size: 0.875rem !important; line-height: 1.25rem !important; }
.text-base      { font-size: 1rem !important;     line-height: 1.5rem !important; }
.text-lg        { font-size: 1.125rem !important; line-height: 1.75rem !important; }
.text-2xl       { font-size: 1.5rem !important;   line-height: 2rem !important; }
.text-left      { text-align: left !important; }
.text-right     { text-align: right !important; }
.font-medium    { font-weight: 500 !important; }
.font-semibold  { font-weight: 600 !important; }
.uppercase      { text-transform: uppercase !important; }
.tracking-wide  { letter-spacing: 0.025em !important; }
.truncate       { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.whitespace-nowrap { white-space: nowrap !important; }

/* ── Border radius ────────────────────────────────────────── */
.rounded-xl   { border-radius: 0.75rem !important; }
.rounded-lg   { border-radius: 0.5rem !important; }
.rounded-full { border-radius: 9999px !important; }

/* ── Border helpers ──────────────────────────────────────── */
.border-b { border-bottom: 1px solid #e5e7eb !important; }

/* ── Border colours ──────────────────────────────────────── */
.border-gray-200  { border-color: #e5e7eb !important; }
.border-gray-300  { border-color: #d1d5db !important; }
.border-slate-200 { border-color: #e2e8f0 !important; }
.border-slate-300 { border-color: #cbd5e1 !important; }
.border-slate-500 { border-color: #64748b !important; }
.border-slate-700 { border-color: #334155 !important; }
.border-amber-200 { border-color: #fde68a !important; }

/* ── Background colours ───────────────────────────────────── */
.bg-gray-50    { background-color: #f9fafb !important; }
.bg-gray-100   { background-color: #f3f4f6 !important; }
.bg-blue-50    { background-color: #eff6ff !important; }
.bg-blue-700   { background-color: #1d4ed8 !important; }
.bg-amber-50   { background-color: #fffbeb !important; }
.bg-emerald-50 { background-color: #ecfdf5 !important; }
.bg-red-600    { background-color: #dc2626 !important; }

/* ── Text colours ─────────────────────────────────────────── */
.text-gray-500  { color: #6b7280 !important; }
.text-gray-600  { color: #4b5563 !important; }
.text-gray-700  { color: #374151 !important; }
.text-gray-900  { color: #111827 !important; }
.text-slate-50  { color: #f8fafc !important; }
.text-slate-100 { color: #f1f5f9 !important; }
.text-slate-500 { color: #64748b !important; }
.text-slate-600 { color: #475569 !important; }
.text-slate-700 { color: #334155 !important; }
.text-slate-900 { color: #0f172a !important; }
.text-amber-700 { color: #b45309 !important; }
.text-amber-900 { color: #78350f !important; }
.text-blue-700  { color: #1d4ed8 !important; }
.text-emerald-800 { color: #065f46 !important; }

/* ── Hover states ─────────────────────────────────────────── */
.hover\:bg-gray-100:hover  { background-color: #f3f4f6 !important; }
.hover\:bg-slate-100:hover { background-color: #f1f5f9 !important; }
.hover\:bg-blue-800:hover  { background-color: #1e40af !important; }

/* ── Shadow ──────────────────────────────────────────────── */
.shadow-sm { box-shadow: 0 1px 2px 0 rgba(0,0,0,.05) !important; }

/* ══════════════════════════════════════════════════════════ */
/*  COMPONENT STYLES                                          */
/* ══════════════════════════════════════════════════════════ */

/* ── Tailwind-style list tables ───────────────────────────── */
/* Applied to tables using class="w-full text-left text-sm text-gray-600" */
table.w-full thead th {
  padding: 0.6rem 0.875rem;
  border-bottom: 2px solid #e5e7eb;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #4b5563;
  background-color: #f9fafb;
}
table.w-full tbody td {
  padding: 0.6rem 0.875rem;
  vertical-align: middle;
}
table.w-full tbody tr:hover td {
  background-color: #f0f7ff;
}

/* ── Page header ──────────────────────────────────────────── */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  border-radius: 0.625rem;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}
.page-header__title {
  margin: 0 0 0.2rem;
  font-size: 1.375rem;
  font-weight: 600;
  color: #111827;
  line-height: 1.3;
}
.page-header__subtitle {
  margin: 0;
  font-size: 0.85rem;
  color: #6b7280;
}
.page-header__actions { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }

/* ── KPI stat card ────────────────────────────────────────── */
.kpi-card {
  border-radius: 0.625rem;
  border: 1px solid #e5e7eb;
  padding: 0.6rem 1rem;
  background: #fff;
  min-width: 140px;
}
.kpi-card--danger  { border-color: #fca5a5; background: #fff5f5; }
.kpi-card--warning { border-color: #fde68a; background: #fffbeb; }
.kpi-card--success { border-color: #6ee7b7; background: #f0fdf4; }
.kpi-card__label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
  margin-bottom: 0.1rem;
}
.kpi-card--danger  .kpi-card__label { color: #b91c1c; }
.kpi-card--warning .kpi-card__label { color: #92400e; }
.kpi-card--success .kpi-card__label { color: #065f46; }
.kpi-card__value {
  font-size: 1.2rem;
  font-weight: 700;
  color: #111827;
  line-height: 1.2;
}
.kpi-card--danger  .kpi-card__value { color: #dc2626; }
.kpi-card--warning .kpi-card__value { color: #b45309; }
.kpi-card--success .kpi-card__value { color: #059669; }

/* ── Status badges ────────────────────────────────────────── */
.status-badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  vertical-align: middle;
}
.status-badge.paid     { background: #d1fae5; color: #065f46; }
.status-badge.pending  { background: #fef9c3; color: #854d0e; }
.status-badge.issued   { background: #dbeafe; color: #1e40af; }
.status-badge.overdue  { background: #fee2e2; color: #991b1b; }
.status-badge.draft    { background: #f3f4f6; color: #4b5563; }

/* ── Pending rows in tables ──────────────────────────────── */
.row-pending-red { background-color: #fff5f5 !important; }
.row-pending-red:hover td,
tr.row-pending-red:hover td { background-color: #fee2e2 !important; }
a.client-pending-link { color: #dc2626; font-weight: 600; }
a.factura-nopagada    { color: #dc2626; font-weight: 600; }
a.factura-pagada      { color: #16a34a; }

/* ── Section helpers ─────────────────────────────────────── */
.section-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #475569;
}
.pending-total-highlight {
  font-size: 0.9rem;
  font-weight: 600;
  color: #b91c1c;
  margin-bottom: 0.2rem;
}

/* ── Doc form fields (invoice/quote/received-invoice detail) ─ */
.doc-screen { max-width: 1100px; }
.doc-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #475569;
  margin-bottom: 0.2rem;
}
.doc-screen input[type="text"],
.doc-screen input[type="number"],
.doc-screen input[type="email"],
.doc-screen input[type="date"],
.doc-screen select,
.doc-screen textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 0.4rem;
  padding: 0.4rem 0.6rem;
  font-size: 0.875rem;
  background: #fff;
  color: #0f172a;
  line-height: 1.4;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.doc-screen input:focus,
.doc-screen select:focus,
.doc-screen textarea:focus {
  outline: 0;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
.doc-screen input[readonly] { background: #f8fafc; color: #64748b; }
.doc-screen textarea { min-height: 90px; resize: vertical; }
.doc-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.doc-inline .doc-grow { flex: 1 1 0%; min-width: 0; }
.doc-check {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.875rem;
  cursor: pointer;
  user-select: none;
  padding: 0.3rem 0;
}
.doc-check input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
  accent-color: #2563eb;
  flex-shrink: 0;
}
.doc-side-panel {
  border: 1px solid #e2e8f0;
  border-radius: 0.625rem;
  background: #f8fafc;
  padding: 1rem;
  height: 100%;
}
.doc-side-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #475569;
  margin-bottom: 0.75rem;
}
.doc-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid #e2e8f0;
}
.doc-form-title { font-size: 1rem; font-weight: 600; margin: 0; color: #1e293b; }
.doc-lines-wrap { overflow-x: auto; }
.doc-lines-head td {
  background: #e2e8f0;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #334155;
  padding: 0.5rem 0.625rem;
}
.doc-totals-box {
  display: inline-block;
  text-align: right;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  padding: 0.75rem 1.25rem;
  margin-top: 0.5rem;
  font-size: 0.9rem;
  line-height: 1.8;
}
.coef-doc-label { font-size: 0.75rem; color: #94a3b8; margin-bottom: 0.2rem; }

/* ── Client profile card ─────────────────────────────────── */
.client-section {
  border: 1px solid #e2e8f0;
  border-radius: 0.625rem;
  background: #fff;
  padding: 0.875rem 1rem;
  height: 100%;
}
.client-section-title {
  margin: 0 0 0.5rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #475569;
}
.client-field {
  width: 100%;
  min-height: 38px;
  border: 1px solid #cbd5e1;
  border-radius: 0.4rem;
  background: #fff;
  padding: 0.4rem 0.6rem;
  font-size: 0.875rem;
  line-height: 1.4;
}
.client-field:focus {
  outline: 0;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.client-form-grid textarea.client-field { min-height: 90px; resize: vertical; }

/* ── Supplier detail — invoice list rows ─────────────────── */
.supplier-invoice-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem 0.75rem;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.875rem;
  transition: background 0.12s;
}
.supplier-invoice-row:hover { background: #f8fafc; }
.supplier-invoice-row:last-child { border-bottom: none; }
.supplier-invoice-row .inv-meta {
  color: #64748b;
  font-size: 0.8rem;
  white-space: nowrap;
}
.supplier-invoice-row .inv-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-left: auto;
}

/* ── Sidebar treeview open state ─────────────────────────── */
.app-sidebar[data-bs-theme="dark"] .sidebar-menu > .nav-item {
  margin: 0.18rem 0.45rem;
}

.app-sidebar[data-bs-theme="dark"] .sidebar-menu > .nav-item > .nav-link {
  border-radius: 0.8rem;
  border: 1px solid transparent;
  transition: background-color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, color 0.18s ease;
}

.app-sidebar[data-bs-theme="dark"] .sidebar-menu > .nav-item.menu-open > .nav-link {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.24), rgba(37, 99, 235, 0.16));
  border-color: rgba(96, 165, 250, 0.45);
  box-shadow: inset 4px 0 0 #60a5fa, 0 0 0 1px rgba(96, 165, 250, 0.1);
  color: #f8fbff;
}

.app-sidebar[data-bs-theme="dark"] .sidebar-menu > .nav-item.menu-open > .nav-link .nav-icon,
.app-sidebar[data-bs-theme="dark"] .sidebar-menu > .nav-item.menu-open > .nav-link p,
.app-sidebar[data-bs-theme="dark"] .sidebar-menu > .nav-item.menu-open > .nav-link .nav-arrow {
  color: #f8fbff;
}

.app-sidebar[data-bs-theme="dark"] .sidebar-menu > .nav-item.menu-open > .nav-link .nav-arrow {
  font-weight: 700;
}

.app-sidebar[data-bs-theme="dark"] .sidebar-menu > .nav-item.menu-open > .nav-treeview {
  margin-top: 0.25rem;
  padding: 0.35rem 0 0.35rem 0.75rem;
  border-left: 2px solid rgba(96, 165, 250, 0.4);
}
