/* =========================================================
   SRLS Corporation — Estilos del sistema de Contrato/Factura
   ========================================================= */

:root {
  --azul: #0284c7;
  --azul-oscuro: #0369a1;
  --gris-900: #0f172a;
  --gris-700: #334155;
  --gris-500: #64748b;
  --gris-300: #cbd5e1;
  --gris-200: #e2e8f0;
  --gris-100: #f1f5f9;
  --gris-50: #f8fafc;
  --rojo: #dc2626;
  --rojo-oscuro: #b91c1c;
  --verde: #16a34a;
  --sombra: 0 4px 16px rgba(15, 23, 42, 0.08);
  --sombra-suave: 0 1px 3px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(180deg, #eef2f7 0%, #e2e8f0 100%);
  color: var(--gris-900);
  min-height: 100vh;
}

/* ---------- Estructura general ---------- */

.page {
  max-width: 860px;
  margin: 0 auto;
  padding: 30px 20px 60px;
}

.card {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: var(--sombra);
  padding: 32px 36px 40px;
  border: 1px solid var(--gris-200);
}

/* ---------- Encabezado / navegación ---------- */

.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--gris-200);
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--gris-100);
}

.header p {
  margin: 2px 0;
  color: var(--gris-500);
  font-size: 14px;
}

.badge {
  background: #e0f2fe;
  color: var(--azul-oscuro);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

/* ---------- Tipografía ---------- */

h1 {
  font-size: 28px;
  margin: 0 0 4px;
  color: var(--gris-900);
}

h2 {
  font-size: 18px;
  color: var(--gris-900);
  margin: 32px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--gris-200);
}

.card > form > h2:first-of-type,
form h2:first-child {
  margin-top: 8px;
}

.hint {
  color: var(--gris-500);
  font-size: 13px;
  margin: -6px 0 16px;
}

/* ---------- Formularios ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px 20px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--gris-700);
  margin-bottom: 14px;
}

.grid > label {
  margin-bottom: 0;
}

input,
select,
textarea {
  font-family: inherit;
  font-size: 14px;
  font-weight: 400;
  color: var(--gris-900);
  padding: 10px 12px;
  border: 1px solid var(--gris-300);
  border-radius: 8px;
  background: #ffffff;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  width: 100%;
}

input::placeholder,
textarea::placeholder {
  color: #a3adc2;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--azul);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

textarea {
  resize: vertical;
  min-height: 70px;
}

small {
  color: var(--gris-500);
  font-size: 12px;
  font-weight: 400;
}

/* ---------- Login ---------- */

.page .card h1 + form,
.card form:only-child {
  margin-top: 10px;
}

body:has(main.page > .card > h1:only-child ~ form) .card,
main.page .card form label {
  font-weight: 600;
}

/* Tarjeta de login más angosta y centrada verticalmente */
main.page:has(#contractForm) {
  align-items: flex-start;
}

/* ---------- Servicios ---------- */

.services {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}

.service-row {
  display: grid;
  grid-template-columns: 1.4fr 1.3fr 0.9fr;
  gap: 10px;
  align-items: center;
  background: var(--gris-50);
  border: 1px solid var(--gris-200);
  border-radius: 8px;
  padding: 10px 14px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.service-row:hover {
  border-color: var(--gris-300);
  background: #ffffff;
}

.service-row:has(input[type="checkbox"]:checked) {
  border-color: var(--azul);
  background: #f0f9ff;
}

label.check {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--gris-900);
  margin-bottom: 0;
}

label.check input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--azul);
  cursor: pointer;
  flex-shrink: 0;
}

.service-row input[type="text"],
.service-row input[type="number"] {
  font-size: 13px;
  padding: 8px 10px;
}

/* ---------- Firma digital ---------- */

.signature-container {
  border: 2px dashed var(--gris-300);
  border-radius: 8px;
  background: var(--gris-50);
  padding: 12px;
  margin-top: 10px;
  margin-bottom: 20px;
  text-align: center;
}

.signature-pad-wrapper {
  position: relative;
  width: 100%;
  height: 200px;
  background: #ffffff;
  border: 1px solid var(--gris-300);
  border-radius: 6px;
}

.signature-pad-wrapper canvas {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  border-radius: 6px;
  cursor: crosshair;
}

.signature-actions {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.btn-clear {
  background: var(--gris-200);
  color: var(--gris-700);
  border: none;
  padding: 7px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: background 0.15s ease;
}

.btn-clear:hover {
  background: var(--gris-300);
}

.error-msg {
  color: var(--rojo);
  font-size: 13px;
  margin-top: 5px;
  display: none;
}

/* ---------- Total / resumen ---------- */

.total-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  padding: 14px 18px;
  margin: 24px 0;
}

.total-box span {
  font-size: 14px;
  font-weight: 600;
  color: var(--gris-700);
}

.total-box strong {
  font-size: 20px;
  color: var(--verde);
}

/* ---------- Botones ---------- */

button[type="submit"] {
  display: block;
  width: 100%;
  background: var(--azul);
  color: #ffffff;
  border: none;
  padding: 14px 20px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
  letter-spacing: 0.2px;
}

button[type="submit"]:hover {
  background: var(--azul-oscuro);
}

button[type="submit"]:active {
  transform: translateY(1px);
}

.btn-contracts {
  background: var(--azul);
  color: #ffffff;
  padding: 8px 14px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  transition: background 0.15s ease;
}

.btn-contracts:hover {
  background: var(--azul-oscuro);
}

/* ---------- Contratos guardados (ver_contratos.php) ---------- */

.nav-links {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}

.table-container {
  margin-top: 20px;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  background: #ffffff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--sombra-suave);
}

th, td {
  padding: 12px 15px;
  text-align: left;
  border-bottom: 1px solid var(--gris-200);
  font-size: 14px;
}

th {
  background-color: var(--gris-50);
  color: var(--gris-700);
  font-weight: 700;
}

tr:hover {
  background-color: var(--gris-50);
}

.btn-action {
  display: inline-block;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  margin-right: 6px;
  transition: background 0.15s ease;
}

.btn-view {
  background: var(--azul);
  color: #ffffff;
}

.btn-view:hover {
  background: var(--azul-oscuro);
}

.btn-delete {
  background: var(--rojo);
  color: #ffffff;
}

.btn-delete:hover {
  background: var(--rojo-oscuro);
}

.alert-success {
  background: #dcfce7;
  color: #166534;
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 15px;
  font-size: 14px;
  font-weight: 600;
}

/* ---------- Responsive ---------- */

/* ---------- Página de acceso (login) ---------- */

.page-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.card-login {
  max-width: 380px;
  width: 100%;
}

.card-login h1 {
  font-size: 22px;
  margin-bottom: 18px;
  text-align: center;
}

.card-login form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card-login button[type="submit"] {
  margin-top: 6px;
}

@media (max-width: 700px) {
  .page {
    padding: 16px 12px 40px;
  }

  .card {
    padding: 22px 18px 28px;
  }

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

  .service-row {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 22px;
  }

  .header {
    flex-direction: column;
  }
}
