/*
  publikFiscal — Design System (Clean Human Minimalist / Stripe-Linear-Vercel style)
  Shared by resources/views/layouts/admin.blade.php and layouts/app.blade.php.
  Class names are kept stable on purpose so every existing view keeps working.
*/

:root {
  color-scheme: light;

  /* ---- Color tokens (Light Clean Minimalist / Stripe-Linear-Vercel style) ---- */
  --bg-dark: #f8fafc;
  --bg-sunken: #f1f5f9;
  --card-bg: #ffffff;
  --card-bg-elevated: #ffffff;
  --border-color: rgba(226, 232, 240, 0.9);
  --border-color-strong: rgba(203, 213, 225, 0.9);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  /* single brand accent (10% focal point - Stripe/Linear refined indigo) */
  --accent-purple: #4f46e5;
  --accent-purple-hover: #4338ca;
  --accent-blue: #0284c7;

  /* semantic status colors */
  --accent-emerald: #059669;
  --accent-rose: #e11d48;
  --accent-amber: #d97706;

  /* ---- Radius scale (Stripe/Linear crisp corners, max 12px) ---- */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* ---- Elevation (Soft light shadows) ---- */
  --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 16px -2px rgba(15, 23, 42, 0.08), 0 1px 2px -1px rgba(15, 23, 42, 0.04);

  /* ---- Typography ---- */
  --font-family-display: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-family-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-family-mono: 'JetBrains Mono', ui-monospace, monospace;

  --font-size-h1: clamp(1.4rem, 1.1vw + 1.1rem, 2rem);
  --font-size-h2: clamp(1.15rem, 0.8vw + 0.95rem, 1.4rem);
  --font-size-h3: clamp(1rem, 0.4vw + 0.9rem, 1.15rem);
  --font-size-h4: 0.88rem;
  --font-size-h5: 0.82rem;
  --font-size-body: 0.9rem;
  --font-size-sm: 0.78rem;
  --font-size-xs: 0.72rem;

  /* ---- Motion ---- */
  --ease-smooth: cubic-bezier(0.16, 1, 0.3, 1);
  --transition-fast: 150ms var(--ease-smooth);
  --transition-normal: 220ms var(--ease-smooth);
}

/* ---------------------------------------------------------------- */
/* Reset & base                                                      */
/* ---------------------------------------------------------------- */

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family-body);
  font-size: var(--font-size-body);
  line-height: 1.5;
  background-color: var(--bg-dark);
  color: var(--text-primary);
  display: flex;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5 {
  font-family: var(--font-family-display);
  color: var(--text-primary);
}

h1 { font-size: var(--font-size-h1); font-weight: 800; line-height: 1.25; letter-spacing: -0.02em; }
h2 { font-size: var(--font-size-h2); font-weight: 700; line-height: 1.3; letter-spacing: -0.01em; }
h3 { font-size: var(--font-size-h3); font-weight: 700; line-height: 1.35; }
h4 { font-size: var(--font-size-h4); font-weight: 700; line-height: 1.4; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-secondary); }
h5 { font-size: var(--font-size-h5); font-weight: 600; line-height: 1.4; color: var(--text-secondary); }

code, pre, .font-mono, .mono {
  font-family: var(--font-family-mono);
  font-size: 0.82em;
}

a { color: inherit; }

img, svg { display: block; max-width: 100%; }

@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------------------------------------------------------------- */
/* Accessibility helpers                                             */
/* ---------------------------------------------------------------- */

:focus-visible {
  outline: 2px solid var(--accent-purple);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.22);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: -48px;
  left: 12px;
  z-index: 10000;
  background: var(--accent-purple);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: var(--font-size-sm);
  text-decoration: none;
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: 12px;
}

/* ---------------------------------------------------------------- */
/* Shell: sidebar + topbar                                           */
/* ---------------------------------------------------------------- */

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--bg-sunken);
  border-right: 1px solid var(--border-color);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-family-display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  margin-bottom: 32px;
  padding-left: 8px;
  min-width: 0;
}

.brand span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent-purple), #818cf8);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item a {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 10px 12px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: var(--font-size-body);
  min-height: 40px;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.nav-item a span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item a svg { flex-shrink: 0; }

.nav-item a:hover,
.nav-item.active a {
  background: rgba(79, 70, 229, 0.08);
  color: var(--accent-purple);
}

.nav-item a:hover svg,
.nav-item.active a svg {
  color: var(--accent-purple);
}

.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  min-height: 64px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 32px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
}

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  color: var(--text-primary);
  cursor: pointer;
}

.sidebar-overlay {
  display: none;
}

.badge-superadmin,
.badge-environment {
  padding: 5px 12px;
  border-radius: var(--radius-xs);
  font-size: var(--font-size-xs);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.badge-superadmin {
  background: rgba(79, 70, 229, 0.08);
  color: var(--accent-purple);
  border: 1px solid rgba(79, 70, 229, 0.2);
}

.badge-homologation {
  background: rgba(217, 119, 6, 0.1);
  color: var(--accent-amber);
  border: 1px solid rgba(217, 119, 6, 0.25);
}

.badge-production {
  background: rgba(5, 150, 105, 0.1);
  color: var(--accent-emerald);
  border: 1px solid rgba(5, 150, 105, 0.25);
}

.content {
  padding: 32px;
  flex: 1;
  min-width: 0;
}

/* ---------------------------------------------------------------- */
/* Components                                                        */
/* ---------------------------------------------------------------- */

.card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  min-width: 0;
}

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

.card-title {
  font-family: var(--font-family-display);
  font-size: var(--font-size-h3);
  font-weight: 700;
}

.btn {
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-family-body);
  font-weight: 600;
  border: none;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  font-size: var(--font-size-body);
  transition: transform var(--transition-fast), background-color var(--transition-fast), box-shadow var(--transition-fast);
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-purple,
.btn-primary {
  background: var(--accent-purple);
  color: white;
}

.btn-purple:hover,
.btn-primary:hover {
  background: var(--accent-purple-hover);
}

.btn-secondary {
  background: var(--bg-sunken);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(203, 213, 225, 0.4);
}

.btn-danger {
  background: rgba(225, 29, 72, 0.08);
  color: var(--accent-rose);
  border: 1px solid rgba(225, 29, 72, 0.2);
}

.btn-danger:hover {
  background: rgba(225, 29, 72, 0.15);
}

.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  font-size: var(--font-size-body);
}

.alert svg { flex-shrink: 0; margin-top: 1px; }

.alert-success {
  background: rgba(5, 150, 105, 0.08);
  color: var(--accent-emerald);
  border: 1px solid rgba(5, 150, 105, 0.2);
}

.alert-danger {
  background: rgba(225, 29, 72, 0.08);
  color: var(--accent-rose);
  border: 1px solid rgba(225, 29, 72, 0.2);
}

.alert-warning {
  background: rgba(217, 119, 6, 0.08);
  color: var(--accent-amber);
  border: 1px solid rgba(217, 119, 6, 0.2);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.form-group label {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  font-weight: 500;
}

.form-control {
  width: 100%;
  max-width: 100%;
  background: var(--bg-sunken);
  border: 1px solid var(--border-color);
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-family-body);
  font-size: 16px;
  min-height: 44px;
  outline: none;
  transition: border-color var(--transition-fast);
}

@media (min-width: 641px) {
  .form-control { font-size: var(--font-size-body); }
}

.form-control:focus {
  border-color: var(--accent-purple);
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  flex-shrink: 0;
}

.status-dot--success { background: var(--accent-emerald); box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15); }
.status-dot--danger { background: var(--accent-rose); box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.15); }
.status-dot--warning { background: var(--accent-amber); box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.15); }
.status-dot--muted { background: var(--text-muted); box-shadow: 0 0 0 3px rgba(100, 116, 139, 0.15); }

.table-wrapper {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  margin-top: 16px;
}

th, td {
  padding: 13px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  font-size: var(--font-size-sm);
}

th {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---------------------------------------------------------------- */
/* Toast system (replaces window.alert/confirm)                      */
/* ---------------------------------------------------------------- */

.toast-container {
  position: fixed;
  z-index: 20000;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  pointer-events: none;
  width: calc(100% - 2rem);
  max-width: 380px;

  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  bottom: auto;
  right: auto;
}

@media (min-width: 641px) {
  .toast-container {
    top: auto;
    left: auto;
    transform: none;
    bottom: 1.5rem;
    right: 1.5rem;
  }
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--card-bg-elevated);
  border: 1px solid var(--border-color-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 13px 14px;
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  animation: toast-in var(--transition-normal);
}

.toast svg { flex-shrink: 0; margin-top: 1px; }
.toast-message { flex: 1; min-width: 0; }

.toast--success { border-left: 3px solid var(--accent-emerald); }
.toast--success svg { color: var(--accent-emerald); }
.toast--error { border-left: 3px solid var(--accent-rose); }
.toast--error svg { color: var(--accent-rose); }
.toast--warning { border-left: 3px solid var(--accent-amber); }
.toast--warning svg { color: var(--accent-amber); }
.toast--info { border-left: 3px solid var(--accent-blue); }
.toast--info svg { color: var(--accent-blue); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------------------------------------------------------------- */
/* Confirm modal (replaces window.confirm)                           */
/* ---------------------------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 10001;
}

.modal-panel {
  width: 100%;
  max-width: 400px;
  background: var(--card-bg-elevated);
  border: 1px solid var(--border-color-strong);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
  animation: toast-in var(--transition-normal);
}

.modal-panel h3 { margin-bottom: 8px; }
.modal-panel p { color: var(--text-secondary); margin-bottom: 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- */
/* Responsive: mobile-first shell collapse                           */
/* ---------------------------------------------------------------- */

@media (max-width: 900px) {
  body { display: block; }

  .menu-toggle { display: inline-flex; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100dvh;
    z-index: 9000;
    transform: translateX(-100%);
    transition: transform var(--transition-normal);
    box-shadow: var(--shadow-md);
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(4, 6, 12, 0.55);
    z-index: 8999;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
  }

  .sidebar-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
  }

  .main-wrapper { min-height: 100dvh; }

  .topbar { padding: 12px 16px; }

  .content { padding: 20px 16px; }
}

@media (max-width: 480px) {
  .card { padding: 18px; }
  .card-title { font-size: var(--font-size-h4); text-transform: none; letter-spacing: normal; }
}
