/* ============================================
   Facturador Web — Estilos personalizados
   UI/UX moderno sobre AdminLTE 3 + Bootstrap 4
   ============================================ */

/* ---------- Variables ---------- */
:root {
  --brand-primary: #3b82f6;
  --brand-success: #10b981;
  --brand-warning: #f59e0b;
  --brand-danger: #ef4444;
  --brand-info: #06b6d4;
  --brand-dark: #111827;
  --brand-darker: #0a0f1a;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.35);
  --transition: 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Body & Scroll ---------- */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0f172a;
  color: #e2e8f0;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #1a2332; border-radius: 4px; }
::-webkit-scrollbar-thumb { background: #374151; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #4b5563; }

/* ---------- Navbar ---------- */
.main-header {
  background: linear-gradient(135deg, #111827 0%, #1a1f2e 100%) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: var(--shadow-sm);
}
.main-header .navbar-nav .nav-link {
  color: #94a3b8 !important;
  transition: color var(--transition);
}
.main-header .navbar-nav .nav-link:hover {
  color: #e2e8f0 !important;
}
.main-header .navbar-brand {
  font-weight: 600;
  color: #e2e8f0 !important;
  letter-spacing: -0.3px;
}

/* ---------- Sidebar ---------- */
.main-sidebar {
  background: linear-gradient(180deg, #0d1117 0%, #111827 100%) !important;
  border-right: 1px solid rgba(255, 255, 255, 0.04);
}
.brand-link {
  padding: 1rem 1.25rem !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
  transition: background var(--transition);
}
.brand-link:hover {
  background: rgba(255, 255, 255, 0.02) !important;
}
.brand-text {
  font-weight: 600 !important;
  letter-spacing: -0.3px;
}
.user-panel {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
  padding: 0.75rem 1.25rem !important;
}
.user-panel .info a {
  color: #94a3b8 !important;
  font-size: 0.875rem;
}

/* Sidebar nav items */
.nav-sidebar .nav-link {
  border-radius: 8px;
  margin: 2px 10px;
  padding: 0.6rem 1rem;
  color: #94a3b8 !important;
  transition: all var(--transition);
  font-size: 0.9rem;
}
.nav-sidebar .nav-link:hover {
  background: rgba(59, 130, 246, 0.1) !important;
  color: #e2e8f0 !important;
}
.nav-sidebar .nav-link.active {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2) 0%, rgba(59, 130, 246, 0.1) 100%) !important;
  color: #60a5fa !important;
  box-shadow: inset 3px 0 0 var(--brand-primary);
}
.nav-sidebar .nav-link .nav-icon {
  font-size: 1.05rem;
  margin-right: 0.75rem;
  width: 1.5rem;
  text-align: center;
  color: #64748b;
  transition: color var(--transition);
}
.nav-sidebar .nav-link:hover .nav-icon,
.nav-sidebar .nav-link.active .nav-icon {
  color: var(--brand-primary);
}
.nav-sidebar .nav-link.text-danger:hover {
  background: rgba(239, 68, 68, 0.15) !important;
  color: #f87171 !important;
}
.nav-sidebar .nav-link.text-danger:hover .nav-icon {
  color: #f87171 !important;
}

/* ---------- Content Wrapper ---------- */
.content-wrapper {
  background: #0f172a !important;
}
.content-header {
  padding: 1.25rem 1.5rem 0.5rem !important;
}
.content-header h1 {
  font-size: 1.35rem;
  font-weight: 600;
  color: #f1f5f9;
  letter-spacing: -0.3px;
}
.content {
  padding: 0.75rem 1.5rem 1.5rem !important;
}

/* ---------- Breadcrumb ---------- */
.breadcrumb {
  background: transparent !important;
  padding: 0 !important;
  font-size: 0.8rem;
}
.breadcrumb-item a { color: #64748b; transition: color var(--transition); }
.breadcrumb-item a:hover { color: #94a3b8; text-decoration: none; }
.breadcrumb-item.active { color: #94a3b8; }

/* ---------- Cards ---------- */
.card {
  border-radius: var(--radius-lg) !important;
  border: 1px solid rgba(255, 255, 255, 0.06) !important;
  background: #1a2332 !important;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
  overflow: hidden;
}
.card:hover {
  box-shadow: var(--shadow);
}
.card-outline {
  border-top: none !important;
}
.card-header {
  background: transparent !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06) !important;
  padding: 1rem 1.25rem !important;
}
.card-header .card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #f1f5f9;
  margin: 0;
}
.card-body {
  padding: 1.25rem !important;
}
.card-footer {
  background: rgba(0, 0, 0, 0.15) !important;
  border-top: 1px solid rgba(255, 255, 255, 0.06) !important;
  padding: 0.85rem 1.25rem !important;
}

/* ---------- Forms ---------- */
.form-group { margin-bottom: 1.1rem; }
.form-group label {
  font-weight: 500;
  font-size: 0.85rem;
  color: #94a3b8;
  margin-bottom: 0.35rem;
}
.form-control {
  background: #111827 !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  color: #e2e8f0 !important;
  border-radius: var(--radius) !important;
  padding: 0.55rem 0.85rem;
  font-size: 0.9rem;
  transition: all var(--transition);
}
.form-control:focus {
  border-color: var(--brand-primary) !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15) !important;
  outline: none;
}
.form-control::placeholder {
  color: #475569;
}
.form-control-sm {
  padding: 0.38rem 0.65rem !important;
  font-size: 0.82rem !important;
}
.form-control-file {
  color: #94a3b8;
  font-size: 0.85rem;
}
select.form-control {
  cursor: pointer;
}
select.form-control option {
  background: #111827;
  color: #e2e8f0;
}
.custom-file-label {
  background: #111827 !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  color: #64748b !important;
  border-radius: var(--radius) !important;
}
.custom-file-label::after {
  background: #1e293b !important;
  color: #94a3b8 !important;
  border-left: 1px solid rgba(255, 255, 255, 0.1) !important;
}
textarea.form-control {
  resize: vertical;
  min-height: 80px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.8rem;
}

/* ---------- Buttons ---------- */
.btn {
  border-radius: var(--radius) !important;
  padding: 0.55rem 1.2rem;
  font-weight: 500;
  font-size: 0.88rem;
  letter-spacing: -0.2px;
  transition: all var(--transition);
  border: none;
}
.btn-lg { padding: 0.7rem 1.6rem; font-size: 0.95rem; }
.btn-sm { padding: 0.35rem 0.85rem; font-size: 0.8rem; }
.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.btn:active {
  transform: translateY(0);
}
.btn-primary {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
}
.btn-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}
.btn-success:hover {
  background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
}
.btn-warning {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #111827;
}
.btn-info {
  background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
}
.btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}
.btn-outline-primary {
  border: 1px solid var(--brand-primary) !important;
  color: var(--brand-primary) !important;
}
.btn-outline-primary:hover {
  background: rgba(59, 130, 246, 0.1) !important;
  color: #60a5fa !important;
}
.btn-outline-secondary {
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  color: #94a3b8 !important;
}
.btn-outline-secondary:hover {
  background: rgba(255, 255, 255, 0.05) !important;
  color: #e2e8f0 !important;
}
.btn-outline-success,
.btn-outline-warning,
.btn-outline-info,
.btn-outline-danger {
  background: transparent !important;
}

/* ---------- Alerts ---------- */
.alert {
  border-radius: var(--radius) !important;
  border: none !important;
  padding: 0.85rem 1.15rem;
  font-size: 0.9rem;
  animation: alertSlideDown 0.3s ease;
}
@keyframes alertSlideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.alert-success { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.alert-danger { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.alert-warning { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.alert-info { background: rgba(6, 182, 212, 0.15); color: #22d3ee; }
.alert .close {
  color: inherit;
  opacity: 0.5;
  font-size: 1.1rem;
}

/* ---------- Small Box (Stats Card) ---------- */
.small-box {
  border-radius: var(--radius-lg) !important;
  overflow: hidden;
  position: relative;
  margin-bottom: 1rem;
  transition: transform var(--transition), box-shadow var(--transition);
}
.small-box:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg) !important;
}
.small-box .inner {
  padding: 1.15rem;
}
.small-box .inner h3 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  letter-spacing: -0.5px;
}
.small-box .inner p {
  font-size: 0.82rem;
  opacity: 0.85;
}
.small-box .icon {
  font-size: 3.5rem;
  opacity: 0.15;
  top: 5px;
  right: 15px;
  transition: transform var(--transition);
}
.small-box:hover .icon {
  transform: scale(1.1);
}
.bg-gradient-info {
  background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%) !important;
}
.bg-gradient-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
}
.bg-gradient-warning {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
}
.bg-gradient-danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
}
.bg-gradient-primary {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important;
}
.bg-gradient-teal {
  background: linear-gradient(135deg, #14b8a6 0%, #0d9488 100%) !important;
}
.bg-gradient-indigo {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%) !important;
}
.bg-gradient-dark {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%) !important;
}

/* ---------- Info Box ---------- */
.info-box {
  border-radius: var(--radius-lg) !important;
  min-height: 70px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1rem;
  transition: transform var(--transition), box-shadow var(--transition);
  overflow: hidden;
}
.info-box:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.info-box .info-box-icon {
  border-radius: var(--radius-lg) 0 0 var(--radius-lg) !important;
  width: 70px;
}
.info-box .info-box-text {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.8;
}
.info-box .info-box-number {
  font-size: 1.25rem;
  font-weight: 700;
}

/* ---------- Tables ---------- */
.table {
  font-size: 0.84rem;
  margin-bottom: 0;
}
.table thead th {
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 2px solid rgba(255, 255, 255, 0.08);
  color: #94a3b8;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.65rem 0.75rem;
}
.table td, .table th {
  border-color: rgba(255, 255, 255, 0.05);
  vertical-align: middle;
  padding: 0.5rem 0.75rem;
}
.table-hover tbody tr:hover {
  background: rgba(59, 130, 246, 0.05) !important;
}
.table-striped tbody tr:nth-of-type(odd) {
  background: rgba(255, 255, 255, 0.015);
}
.table-bordered {
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.table-sm td, .table-sm th {
  padding: 0.4rem 0.55rem;
}
.preview-table-wrapper {
  max-height: 500px;
  overflow: auto;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.preview-table-wrapper table {
  white-space: nowrap;
}
/* Fix columna Enviar mail: checkbox y texto lado a lado sin pisarse */
#data-table th:last-child,
#data-table td:last-child {
  min-width: 140px !important;
  width: 140px !important;
  white-space: nowrap;
  vertical-align: middle;
  text-align: center;
}
#data-table td:last-child input[type="checkbox"] {
  margin: 0;
  vertical-align: middle;
  flex-shrink: 0;
}
#data-table td:last-child small {
  line-height: 1;
  white-space: nowrap;
}

/* ---------- Tabs (Card Header) ---------- */
.nav-tabs {
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.nav-tabs .nav-link {
  border: none !important;
  color: #64748b;
  padding: 0.7rem 1.15rem;
  font-size: 0.88rem;
  font-weight: 500;
  transition: all var(--transition);
  border-radius: var(--radius) var(--radius) 0 0 !important;
}
.nav-tabs .nav-link:hover {
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.03);
}
.nav-tabs .nav-link.active {
  color: var(--brand-primary) !important;
  background: transparent !important;
  border-bottom: 2px solid var(--brand-primary) !important;
}

/* ---------- Dropzone ---------- */
.dropzone-area {
  border: 2px dashed rgba(255, 255, 255, 0.15) !important;
  border-radius: var(--radius-lg) !important;
  padding: 2.5rem 2rem !important;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: rgba(255, 255, 255, 0.01);
}
.dropzone-area:hover,
.dropzone-area.dragover {
  border-color: var(--brand-primary) !important;
  background: rgba(59, 130, 246, 0.05) !important;
  transform: scale(1.01);
}
.dropzone-area i {
  font-size: 2.8rem;
  color: #475569;
  transition: color var(--transition);
}
.dropzone-area:hover i,
.dropzone-area.dragover i {
  color: var(--brand-primary);
}
.dropzone-area p {
  color: #94a3b8;
  margin-bottom: 0.25rem;
}

/* ---------- Progress ---------- */
.progress {
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}
.progress-bar {
  border-radius: 4px;
  transition: width 0.5s ease;
}
.progress-thin {
  height: 6px;
}

/* ---------- Badges ---------- */
.badge {
  border-radius: 20px;
  padding: 0.3em 0.7em;
  font-weight: 500;
  font-size: 0.75rem;
}
.badge-success { background: rgba(16, 185, 129, 0.2) !important; color: #34d399; }
.badge-danger { background: rgba(239, 68, 68, 0.2) !important; color: #f87171; }
.badge-warning { background: rgba(245, 158, 11, 0.2) !important; color: #fbbf24; }
.badge-info { background: rgba(6, 182, 212, 0.2) !important; color: #22d3ee; }
.badge-secondary { background: rgba(100, 116, 139, 0.2) !important; color: #94a3b8; }

/* ---------- Dividers ---------- */
hr {
  border-color: rgba(255, 255, 255, 0.06);
  margin: 1.25rem 0;
}

/* ---------- Footer ---------- */
.main-footer {
  background: #111827 !important;
  border-top: 1px solid rgba(255, 255, 255, 0.05) !important;
  padding: 0.75rem 1.5rem !important;
  color: #64748b;
  font-size: 0.8rem;
}
.main-footer a {
  color: #64748b;
  transition: color var(--transition);
}
.main-footer a:hover {
  color: #94a3b8;
}

/* ---------- Code blocks ---------- */
code.kv {
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.78rem;
  color: #60a5fa;
  user-select: all;
}

/* ---------- Custom Switch ---------- */
.custom-control-input:checked ~ .custom-control-label::before {
  background-color: var(--brand-primary) !important;
  border-color: var(--brand-primary) !important;
}

/* ---------- File Info ---------- */
.file-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.02);
  margin-bottom: 0.35rem;
  transition: background var(--transition);
}
.file-list-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

/* ---------- DL (Description List) ---------- */
dl.row dd {
  color: #cbd5e1;
  font-size: 0.88rem;
  margin-bottom: 0.35rem;
}
dl.row dt {
  color: #64748b;
  font-size: 0.82rem;
  font-weight: 500;
  margin-bottom: 0.35rem;
}

/* ---------- Toasts (Custom) ---------- */
.toast-container-custom {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast-item {
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 500;
  color: #fff;
  box-shadow: var(--shadow-lg);
  animation: toastSlideIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}
@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(50px); }
  to { opacity: 1; transform: translateX(0); }
}
.toast-success { background: linear-gradient(135deg, #10b981, #059669); }
.toast-error { background: linear-gradient(135deg, #ef4444, #dc2626); }
.toast-info { background: linear-gradient(135deg, #3b82f6, #2563eb); }

/* ---------- Empty State ---------- */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
}
.empty-state i {
  font-size: 3.5rem;
  color: #374151;
  margin-bottom: 1rem;
}
.empty-state h5 {
  color: #64748b;
  margin-bottom: 0.5rem;
}
.empty-state p {
  color: #4b5563;
  font-size: 0.9rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .content-header { padding: 1rem 0.75rem 0.25rem !important; }
  .content { padding: 0.5rem 0.75rem 1rem !important; }
  .small-box .inner h3 { font-size: 1.4rem; }
  .card-body { padding: 1rem !important; }
  .btn-lg { padding: 0.55rem 1.2rem; font-size: 0.9rem; }
}

/* ---------- Animation: Fade In ---------- */
.fade-in {
  animation: fadeIn 0.4s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Link Button Style ---------- */
a.btn { text-decoration: none; }

/* ---------- Select2-like custom select ---------- */
select[multiple] {
  padding: 0.4rem;
}
select[multiple] option {
  padding: 0.35rem 0.6rem;
  border-radius: 4px;
  margin: 1px;
}
select[multiple] option:checked {
  background: var(--brand-primary) linear-gradient(0deg, var(--brand-primary), var(--brand-primary));
}

/* ---------- Copy button ---------- */
.copy-btn {
  cursor: pointer;
  opacity: 0.5;
  transition: opacity var(--transition);
  border: none;
  background: none;
  color: #94a3b8;
  padding: 2px 6px;
}
.copy-btn:hover { opacity: 1; }
