/* ============================================================
   Reportes Fixser — Shared Industrial SaaS Design System
   Scoped to .app-shell (all authenticated + auth pages)
   ============================================================ */

.app-shell {
  --app-bg: #f8fafc;
  --app-surface: #ffffff;
  --app-border: #e2e8f0;
  --app-border-input: #cbd5e1;
  --app-text: #0f172a;
  --app-text-secondary: #334155;
  --app-muted: #64748b;
  --app-subtle: #94a3b8;
  --app-hover: #f8fafc;
  --app-accent-bg: #eef2ff;
  --app-shadow: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
  --app-radius: 6px;
  --app-indigo: #4f46e5;
  --app-indigo-hover: #4338ca;
  --app-indigo-ring: rgba(99, 102, 241, 0.5);

  background: var(--app-bg);
  color: var(--app-text);
}

[data-theme="dark"] .app-shell {
  --app-bg: #0f172a;
  --app-surface: #1e293b;
  --app-border: #334155;
  --app-border-input: #475569;
  --app-text: #f1f5f9;
  --app-text-secondary: #cbd5e1;
  --app-muted: #94a3b8;
  --app-subtle: #64748b;
  --app-hover: #334155;
  --app-accent-bg: rgba(79, 70, 229, 0.15);
  --app-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.2);
  --app-indigo: #818cf8;
  --app-indigo-hover: #a5b4fc;
  --app-indigo-ring: rgba(129, 140, 248, 0.35);
}

/* ---- Navbar ---- */
.app-shell .navbar {
  background: var(--app-surface);
  border-bottom: 1px solid var(--app-border);
  box-shadow: var(--app-shadow);
  backdrop-filter: none;
}

.app-shell .navbar-brand,
.app-shell .navbar-brand span {
  color: var(--app-text);
}

.app-shell .navbar-brand span span {
  color: var(--app-text-secondary);
}

.app-shell .navbar-user {
  color: var(--app-muted);
  font-size: 0.8125rem;
}

.navbar-action-form {
  display: inline-flex;
  margin: 0;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .app-shell .navbar {
    gap: 0.375rem;
    padding: 0 0.625rem;
  }

  .app-shell .navbar-brand {
    font-size: 0.875rem;
    min-width: 0;
    max-width: 6.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .app-shell .navbar-brand svg {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
  }

  .app-shell .navbar-actions {
    gap: 0.25rem;
    min-width: 0;
    flex: 1;
    justify-content: flex-end;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
  }

  .app-shell .navbar-actions::-webkit-scrollbar {
    display: none;
  }

  .app-shell .navbar-actions .btn,
  .app-shell .navbar-actions .theme-toggle {
    flex-shrink: 0;
  }

  .app-shell .navbar-actions .btn:has(svg) span:not(.badge) {
    display: none;
  }

  .app-shell .navbar-actions .btn:has(svg) {
    padding: 0;
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }

  .app-shell .navbar-actions .btn svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
  }

  .app-shell .navbar-actions .nav-icon-logout {
    width: 22px;
    height: 22px;
    stroke-width: 2.25;
  }
}

@media (max-width: 480px) {
  .report-view-page .navbar-brand,
  .form-page--admin .navbar-brand {
    max-width: 4.75rem;
  }
}

/* ---- Layout ---- */
.app-shell .main-content {
  padding: 1.25rem 1rem 3.5rem;
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
}

.app-shell .main-content--narrow {
  max-width: 520px;
}

.app-shell .main-content--wide {
  max-width: min(100%, 1400px);
}

@media (min-width: 640px) {
  .app-shell .main-content {
    padding: 1.5rem 1.25rem 4rem;
  }
}

/* ---- Page headers ---- */
.app-shell .page-title,
.app-shell .app-page-title {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--app-text);
  letter-spacing: -0.02em;
  margin: 0 0 0.25rem;
}

.app-shell .page-subtitle,
.app-shell .app-page-subtitle {
  font-size: 0.875rem;
  color: var(--app-muted);
  margin: 0 0 1.25rem;
}

@media (min-width: 769px) {
  .app-shell .page-title,
  .app-shell .app-page-title {
    font-size: 1.875rem;
  }
}

/* ---- Alerts ---- */
.app-shell .alert {
  border-radius: var(--app-radius);
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
  border: 1px solid transparent;
}

.app-shell .alert-success {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}

.app-shell .alert-warning {
  background: #fffbeb;
  color: #b45309;
  border-color: #fde68a;
}

.app-shell .alert-error,
.app-shell .alert-danger {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

.app-shell .alert-info {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

[data-theme="dark"] .app-shell .alert-success {
  background: rgba(5, 150, 105, 0.15);
  color: #6ee7b7;
  border-color: #047857;
}

[data-theme="dark"] .app-shell .alert-warning {
  background: rgba(217, 119, 6, 0.15);
  color: #fcd34d;
  border-color: #92400e;
}

[data-theme="dark"] .app-shell .alert-error,
[data-theme="dark"] .app-shell .alert-danger {
  background: rgba(220, 38, 38, 0.15);
  color: #fca5a5;
  border-color: #991b1b;
}

[data-theme="dark"] .app-shell .alert-info {
  background: rgba(37, 99, 235, 0.15);
  color: #93c5fd;
  border-color: #1e40af;
}

/* ---- Cards ---- */
.app-shell .section-card,
.app-shell .table-card {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow);
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.app-shell .table-card {
  padding: 0;
  overflow: hidden;
}

.app-shell .section-card-title {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--app-muted);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.app-shell .section-card-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--app-border);
}

/* ---- Forms ---- */
.app-shell .form-group {
  margin-bottom: 0.75rem;
}

.app-shell .form-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--app-muted);
  margin-bottom: 0.3rem;
}

.app-shell .required {
  color: #dc2626;
}

.app-shell .form-input,
.app-shell .form-select,
.app-shell .form-textarea {
  width: 100%;
  background: var(--app-surface);
  border: 1px solid var(--app-border-input);
  border-radius: var(--app-radius);
  color: var(--app-text);
  font-family: inherit;
  font-size: 0.875rem;
  padding: 0.4375rem 0.625rem;
  line-height: 1.4;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.app-shell .form-textarea {
  min-height: 80px;
  resize: vertical;
}

.app-shell .form-input::placeholder,
.app-shell .form-textarea::placeholder {
  color: var(--app-subtle);
}

.app-shell .form-input:focus,
.app-shell .form-select:focus,
.app-shell .form-textarea:focus {
  border-color: var(--app-indigo);
  box-shadow: 0 0 0 2px var(--app-indigo-ring);
}

.app-shell .form-select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2394a3b8'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  background-size: 16px;
  padding-right: 2rem;
}

.app-shell .input-wrapper .form-input {
  padding-left: 2.5rem;
}

.app-shell .input-icon {
  color: var(--app-subtle);
}

/* ---- Buttons ---- */
.app-shell .btn {
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--app-radius);
  box-shadow: none;
}

.app-shell .btn-sm {
  font-size: 0.8125rem;
  padding: 0.375rem 0.75rem;
}

.app-shell .navbar-actions .btn.btn-sm {
  padding: 0.5rem 0.875rem;
  min-height: 36px;
  gap: 0.375rem;
}

.app-shell .navbar-actions .nav-icon-logout {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

.report-row-actions-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  align-items: center;
}

.report-delete-form {
  display: inline-flex;
  margin: 0;
}

.my-reports-page .table-card {
  overflow: hidden;
}

.my-reports-page .table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

.my-reports-page .reports-table {
  min-width: 42rem;
}

.my-reports-page .reports-table .report-row-actions {
  min-width: 11rem;
}

@media (max-width: 768px) {
  .my-reports-page .table-scroll {
    margin: 0 -0.25rem;
    padding: 0 0.25rem 0.125rem;
  }

  .my-reports-page .reports-table th,
  .my-reports-page .reports-table td {
    padding-left: 0.625rem;
    padding-right: 0.625rem;
  }

  .my-reports-page .report-row-actions-inner {
    flex-wrap: nowrap;
  }
}

.app-shell .btn-primary {
  background: var(--app-indigo);
  color: #fff;
}

.app-shell .btn-primary:hover:not(:disabled) {
  background: var(--app-indigo-hover);
  transform: none;
  box-shadow: none;
}

.app-shell .btn-secondary {
  background: var(--app-surface);
  color: var(--app-text-secondary);
  border: 1px solid var(--app-border);
}

.app-shell .btn-secondary:hover:not(:disabled) {
  background: var(--app-hover);
  filter: none;
}

.app-shell .btn-success {
  background: #059669;
  color: #fff;
}

.app-shell .btn-success:hover:not(:disabled) {
  background: #047857;
  transform: none;
  box-shadow: none;
}

.app-shell .btn-warning {
  background: #d97706;
  color: #fff;
}

.app-shell .btn-warning:hover:not(:disabled) {
  background: #b45309;
  transform: none;
}

/* ---- Badges ---- */
.app-shell .badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  border: 1px solid transparent;
}

.app-shell .badge-draft {
  background: #f1f5f9;
  color: #475569;
  border-color: #e2e8f0;
}

.app-shell .badge-pending {
  background: #fffbeb;
  color: #b45309;
  border-color: #fde68a;
}

.app-shell .badge-completed {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}

.app-shell .badge-error {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

[data-theme="dark"] .app-shell .badge-draft {
  background: #334155;
  color: #cbd5e1;
  border-color: #475569;
}

[data-theme="dark"] .app-shell .badge-pending {
  background: #422006;
  color: #fcd34d;
  border-color: #78350f;
}

[data-theme="dark"] .app-shell .badge-completed {
  background: #064e3b;
  color: #6ee7b7;
  border-color: #047857;
}

[data-theme="dark"] .app-shell .badge-error {
  background: #450a0a;
  color: #fca5a5;
  border-color: #991b1b;
}

/* ---- Tables ---- */
.app-shell .table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.app-shell .reports-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  color: var(--app-text);
}

.app-shell .reports-table thead th {
  padding: 0.5rem 0.75rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--app-muted);
  border-bottom: 1px solid var(--app-border);
  text-align: left;
  white-space: nowrap;
  background: var(--app-surface);
}

.app-shell .reports-table td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--app-border);
  vertical-align: middle;
}

.app-shell .reports-table tbody tr:hover td {
  background: var(--app-hover);
}

.app-shell .reports-table tr:last-child td {
  border-bottom: none;
}

.app-shell .text-muted {
  color: var(--app-muted);
}

.app-shell .text-center {
  text-align: center;
}

/* ---- Report detail (view_report) ---- */
.app-shell .report-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
}

.app-shell .data-item {
  margin-bottom: 0.625rem;
  border-bottom: 1px solid var(--app-border);
  padding-bottom: 0.5rem;
}

.app-shell .data-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--app-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.2rem;
}

.app-shell .data-value {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--app-text);
}

.app-shell .sig-img {
  max-width: 100%;
  border-radius: var(--app-radius);
  border: 1px solid var(--app-border);
  background: var(--app-surface);
}

[data-theme="dark"] .app-shell .sig-img {
  background: #ffffff;
}

/* ---- Auth (login) ---- */
.app-shell.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
  position: relative;
}

.app-shell .auth-theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 10;
}

.app-shell .auth-theme-toggle .btn {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  color: var(--app-text-secondary);
}

.app-shell .auth-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
}

.app-shell .auth-card {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow), 0 4px 6px -1px rgba(15, 23, 42, 0.08);
  padding: 2rem;
}

.app-shell .auth-logo {
  text-align: center;
  margin-bottom: 1.5rem;
}

.app-shell .logo-icon svg {
  width: 48px;
  height: 48px;
}

.app-shell .auth-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--app-text);
}

.app-shell .auth-title span {
  color: var(--app-text-secondary);
}

.app-shell .auth-subtitle {
  color: var(--app-muted);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.app-shell .auth-footer {
  text-align: center;
  color: var(--app-subtle);
  font-size: 0.75rem;
  margin-top: 1.5rem;
}

.app-shell .toggle-password {
  color: var(--app-subtle);
}

.app-shell .toggle-password:hover {
  color: var(--app-indigo);
}

.app-shell .theme-toggle {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  color: var(--app-muted);
}

.app-shell .theme-toggle:hover:not(:disabled) {
  background: var(--app-hover);
  color: var(--app-text);
  border-color: var(--app-border-input);
}

.app-shell .theme-toggle:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--app-indigo-ring);
  border-color: var(--app-indigo);
}
