/* ============================================================
   Truck Energy — Inspección de Herramientas
   Paleta: Blanco · Negro · Verde corporativo
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --green-dark:    #1a6b2b;
  --green-mid:     #27ae60;
  --green-light:   #e8f7ed;
  --green-border:  #b2dfbb;

  --black:         #111111;
  --gray-800:      #2d2d2d;
  --gray-600:      #555555;
  --gray-400:      #888888;
  --gray-200:      #e5e5e5;
  --gray-100:      #f5f5f5;
  --white:         #ffffff;

  --red:           #c0392b;
  --red-light:     #fdecea;
  --red-border:    #f5c6c2;

  --radius-sm:     4px;
  --radius:        8px;
  --radius-lg:     12px;

  --shadow-sm:     0 1px 4px rgba(0,0,0,.08);
  --shadow:        0 2px 12px rgba(0,0,0,.10);
  --shadow-lg:     0 4px 24px rgba(0,0,0,.14);

  --transition:    .18s ease;
}

/* ── Reset / Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--gray-100);
  color: var(--black);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--green-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* ── Layout ─────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px;
}

.main-content {
  flex: 1;
  padding-top: 28px;
  padding-bottom: 48px;
}

/* ── Header ─────────────────────────────────────────────────── */
.site-header {
  background: var(--green-dark);
  box-shadow: 0 2px 8px rgba(0,0,0,.22);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 64px;
}

/* Logo */
.logo-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.site-logo {
  height: 42px;
  width: auto;
  object-fit: contain;
  filter: brightness(0) invert(1);  /* Hace el logo blanco */
}

.logo-text-fallback {
  display: flex;
  align-items: center;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--white);
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* Nav */
.site-nav {
  display: flex;
  gap: 4px;
}

.nav-link {
  color: rgba(255,255,255,.85);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
}

.nav-link:hover,
.nav-link.active {
  background: rgba(255,255,255,.15);
  color: var(--white);
  text-decoration: none;
}

/* ── Footer ─────────────────────────────────────────────────── */
.site-footer {
  background: var(--gray-800);
  color: var(--gray-400);
  text-align: center;
  padding: 18px 16px;
  font-size: .82rem;
  margin-top: auto;
}

/* ── Page Header ────────────────────────────────────────────── */
.page-header {
  margin-bottom: 24px;
}

.page-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--black);
  line-height: 1.2;
}

.page-subtitle {
  color: var(--gray-600);
  margin-top: 4px;
  font-size: .95rem;
}

/* ── Breadcrumb ─────────────────────────────────────────────── */
.breadcrumb {
  margin-bottom: 16px;
}

.breadcrumb-link {
  font-size: .9rem;
  color: var(--green-dark);
  font-weight: 500;
}

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: .93rem;
}

.alert-icon {
  font-size: 1.1rem;
  margin-top: 1px;
  flex-shrink: 0;
}

.alert-success {
  background: var(--green-light);
  border: 1px solid var(--green-border);
  color: var(--green-dark);
}

.alert-success a { color: var(--green-dark); font-weight: 600; }

.alert-error {
  background: var(--red-light);
  border: 1px solid var(--red-border);
  color: var(--red);
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin-bottom: 24px;
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-100);
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--black);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-icon { font-size: 1rem; }

.card-body {
  padding: 22px;
}

.badge-count {
  background: var(--green-dark);
  color: var(--white);
  font-size: .78rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: .3px;
}

/* ── Form ───────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 18px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: .88rem;
  font-weight: 600;
  color: var(--gray-800);
}

.required { color: var(--red); }

.form-control {
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: .93rem;
  font-family: inherit;
  color: var(--black);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}

.form-control:focus {
  outline: none;
  border-color: var(--green-mid);
  box-shadow: 0 0 0 3px rgba(39,174,96,.15);
}

.form-control.input-error {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(192,57,43,.12);
}

textarea.form-control { resize: vertical; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 20px;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  transition: background var(--transition), border-color var(--transition),
              box-shadow var(--transition), transform var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); text-decoration: none; }
.btn:active { transform: translateY(0); }

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

.btn-primary:hover {
  background: #145520;
  border-color: #145520;
}

.btn-secondary {
  background: var(--white);
  color: var(--gray-800);
  border-color: var(--gray-200);
}

.btn-secondary:hover {
  background: var(--gray-100);
  border-color: var(--gray-400);
}

.btn-outline {
  background: transparent;
  color: var(--green-dark);
  border-color: var(--green-dark);
}

.btn-outline:hover {
  background: var(--green-light);
}

.btn-pdf {
  background: #1a1a2e;
  color: var(--white);
  border-color: #1a1a2e;
}

.btn-pdf:hover {
  background: #111;
  border-color: #111;
}

.btn-lg {
  padding: 13px 28px;
  font-size: 1rem;
}

.btn-sm {
  padding: 5px 12px;
  font-size: .82rem;
}

.btn-icon { font-size: 1em; }

.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 8px;
}

/* ── Tools List ─────────────────────────────────────────────── */
.tools-list {
  border-top: 1px solid var(--gray-200);
}

.tool-row {
  border-bottom: 1px solid var(--gray-200);
  transition: background var(--transition);
}

.tool-row:last-child { border-bottom: none; }

.tool-row:hover { background: rgba(26,107,43,.02); }

.tool-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 22px 10px;
}

.tool-number {
  min-width: 30px;
  height: 30px;
  background: var(--green-dark);
  color: var(--white);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 800;
  flex-shrink: 0;
}

.tool-name {
  font-size: .97rem;
  font-weight: 700;
  color: var(--black);
  flex: 1;
}

/* Badge de estado */
.tool-badge {
  font-size: .75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.badge-ok      { background: var(--green-light); color: var(--green-dark); }
.badge-no      { background: var(--gray-200);    color: var(--gray-600);   }
.badge-damaged { background: var(--red-light);   color: var(--red);        }

/* Campos de cada herramienta */
.tool-field {
  padding: 8px 22px 8px 66px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.tool-field-indent {
  padding-left: 82px;
  border-left: 3px solid var(--green-border);
  margin-left: 66px;
  padding-left: 16px;
}

.field-label {
  font-size: .83rem;
  font-weight: 600;
  color: var(--gray-600);
  white-space: nowrap;
  min-width: 180px;
  padding-top: 8px;
}

.optional {
  font-weight: 400;
  color: var(--gray-400);
  font-size: .78rem;
}

/* ── Radio Cards ────────────────────────────────────────────── */
.radio-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 4px 0;
}

.radio-card {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  user-select: none;
  background: var(--white);
}

.radio-card input[type="radio"] { display: none; }

.radio-label {
  font-size: .85rem;
  font-weight: 600;
  color: var(--gray-800);
}

.radio-card:hover {
  border-color: var(--green-mid);
  background: var(--green-light);
}

.radio-card:has(input:checked) {
  border-color: var(--green-dark);
  background: var(--green-light);
}

/* Variantes de radio */
.radio-yes:has(input:checked)  { border-color: var(--green-dark); background: var(--green-light); }
.radio-no:has(input:checked)   { border-color: var(--gray-600);   background: var(--gray-100);    }
.radio-good:has(input:checked) { border-color: var(--green-dark); background: var(--green-light); }
.radio-bad:has(input:checked)  { border-color: var(--red);        background: var(--red-light);   }

/* ── Damage Section ─────────────────────────────────────────── */
.damage-section {
  background: var(--red-light);
  border-top: 1px dashed var(--red-border);
  border-bottom: 1px dashed var(--red-border);
  padding: 12px 0 6px;
}

.damage-section .tool-field {
  padding-left: 66px;
}

.damage-section .tool-field-indent {
  margin-left: 56px;
  padding-left: 18px;
  border-color: var(--red-border);
}

.damage-section .form-control:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(192,57,43,.12);
}

/* ── File Upload ────────────────────────────────────────────── */
.file-upload {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}

.file-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  background: var(--white);
  border: 2px solid var(--gray-400);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .85rem;
  font-weight: 600;
  transition: border-color var(--transition), background var(--transition);
}

.file-btn:hover {
  border-color: var(--green-dark);
  background: var(--green-light);
}

.file-name-display {
  font-size: .82rem;
  color: var(--gray-600);
  font-style: italic;
}

/* ── Utility ────────────────────────────────────────────────── */
.hidden { display: none !important; }

.text-muted { color: var(--gray-400); font-size: .85rem; }

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
  white-space: nowrap;
}

.data-table th {
  padding: 11px 14px;
  text-align: left;
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--white);
  background: var(--green-dark);
  border-bottom: 2px solid #145520;
}

.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-200);
  color: var(--black);
  vertical-align: middle;
}

.data-table tbody tr:hover { background: var(--green-light); }

.data-table .col-id     { width: 44px; color: var(--gray-400); }
.data-table .col-date   { width: 110px; }
.data-table .col-action { width: 110px; text-align: center; }
.data-table .col-center { text-align: center; }
.data-table .col-photos { min-width: 80px; }

/* Row states in view */
.row-no      { background: var(--gray-100); }
.row-no td   { color: var(--gray-400); }
.row-damaged { background: #fff8f8; }

/* ── Pills ──────────────────────────────────────────────────── */
.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .3px;
}

.pill-ok  { background: var(--green-light); color: var(--green-dark); }
.pill-no  { background: var(--gray-200);    color: var(--gray-600);   }
.pill-bad { background: var(--red-light);   color: var(--red);        }

/* ── Summary Grid ───────────────────────────────────────────── */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.summary-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px 14px;
  text-align: center;
  border-top: 4px solid var(--gray-400);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.summary-card-ok      { border-top-color: var(--green-dark); }
.summary-card-no      { border-top-color: var(--gray-600); }
.summary-card-damaged { border-top-color: var(--red); }

.summary-num {
  font-size: 2rem;
  font-weight: 800;
  color: var(--black);
  line-height: 1;
}

.summary-lbl {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--gray-600);
  font-weight: 600;
}

/* ── Detail List (view.php) ─────────────────────────────────── */
.detail-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}

.detail-item dt {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--gray-600);
  margin-bottom: 3px;
}

.detail-item dd {
  font-size: .97rem;
  color: var(--black);
  font-weight: 500;
}

/* ── Photo Gallery ──────────────────────────────────────────── */
.photo-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.gallery-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  max-width: 160px;
}

.gallery-img {
  width: 150px;
  height: 120px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 2px solid var(--gray-200);
  transition: transform var(--transition), border-color var(--transition);
}

.gallery-img:hover {
  transform: scale(1.04);
  border-color: var(--green-mid);
}

.gallery-item figcaption {
  font-size: .75rem;
  text-align: center;
  color: var(--gray-600);
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-thumb-link { display: inline-block; }

.photo-thumb {
  width: 48px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--gray-200);
  vertical-align: middle;
  transition: transform var(--transition);
}

.photo-thumb:hover { transform: scale(1.1); }

/* ── Empty State ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--gray-600);
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.empty-state h2 { font-size: 1.4rem; color: var(--gray-800); margin-bottom: 8px; }
.empty-state p  { margin-bottom: 24px; }

/* ── Pagination ─────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 18px;
  border-top: 1px solid var(--gray-200);
}

.page-info {
  font-size: .85rem;
  color: var(--gray-600);
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 640px) {

  .header-inner { height: 56px; }

  .site-logo { height: 34px; }

  .nav-link {
    padding: 5px 8px;
    font-size: .82rem;
  }

  .page-title { font-size: 1.3rem; }

  .form-grid { grid-template-columns: 1fr; }

  .tool-field {
    padding-left: 18px;
    flex-direction: column;
    gap: 6px;
  }

  .tool-field-indent {
    margin-left: 14px;
  }

  .field-label {
    min-width: unset;
    padding-top: 0;
  }

  .radio-group { gap: 6px; }

  .tool-header { padding: 12px 14px 8px; }

  .card-header { padding: 12px 14px; }
  .card-body   { padding: 16px 14px; }

  .damage-section .tool-field { padding-left: 14px; }
  .damage-section .tool-field-indent { margin-left: 0; }

  .form-actions { flex-direction: column; }
  .btn-lg { width: 100%; justify-content: center; }

  .summary-grid { grid-template-columns: repeat(2, 1fr); }

  .detail-list { grid-template-columns: 1fr; }

  .data-table { font-size: .8rem; }
  .data-table th,
  .data-table td { padding: 8px 10px; }
}

@media (max-width: 400px) {
  .radio-card { padding: 6px 10px; }
  .radio-label { font-size: .8rem; }
}
