/* ===========================================
   ARMADOR PWA - Estilos unificados
   Basado en bootstrap 5 + custom overrides
   =========================================== */

/* === VARIABLES === */
:root {
  --primary: #1a237e;
  --primary-light: #7986cb;
  --primary-dark: #0d1442;
  --primary-bg: #e8eaf6;
  --danger: #c62828;
  --danger-hover: #e53935;
  --bg-body: #f2f2f7;
  --bg-card: #ffffff;
  --bg-input: #f8f9fc;
  --border-color: #e0e0e0;
  --text-primary: #333333;
  --text-secondary: #666666;
  --text-muted: #999999;
  --radius: 10px;
  --radius-lg: 16px;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
}

/* === BASE === */
body {
  font-family: var(--font-family);
  background: var(--bg-body);
  min-height: 100vh;
}

/* === CARD PRINCIPAL (formularios) === */
.app-card {
  width: 100%;
  max-width: 500px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
  overflow: hidden;
}

/* === HEADER COMPARTIDO === */
.app-header {
  background: var(--primary);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.app-header .header-icon {
  color: #fff;
  font-size: 20px;
  width: 32px;
  text-align: center;
}
.app-header .header-title {
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin: 0;
  flex: 1;
}
.app-header .header-back {
  color: rgba(255,255,255,0.85);
  font-size: 18px;
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background 0.2s;
}
.app-header .header-back:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
}
.app-header .header-action {
  color: rgba(255,255,255,0.85);
  font-size: 18px;
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background 0.2s;
}
.app-header .header-action:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
}

/* === BODY DEL CONTENIDO === */
.app-body {
  padding: 24px 20px;
}

/* === FOOTER COMPARTIDO === */
.app-footer {
  background: #fff;
  border-top: 1px solid var(--border-color);
  padding: 8px 0;
}
.app-footer .nav-link {
  color: var(--text-secondary);
  font-size: 12px;
  text-align: center;
  padding: 6px 8px;
  border-radius: 8px;
  transition: all 0.2s;
}
.app-footer .nav-link i {
  display: block;
  font-size: 18px;
  margin-bottom: 2px;
}
.app-footer .nav-link:hover,
.app-footer .nav-link.active {
  color: var(--primary);
  background: var(--primary-bg);
}

/* === FORMULARIOS === */
.form-label-custom {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.form-label-custom i {
  color: var(--primary);
  font-size: 15px;
  width: 18px;
}
.field-row {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 10px 14px;
  transition: border-color 0.2s;
  min-height: 44px;
}
.field-row:focus-within {
  border-color: var(--primary);
}
.field-row input,
.field-row select {
  border: none;
  background: transparent;
  font-size: 15px;
  color: var(--text-primary);
  width: 100%;
  outline: none;
  font-family: inherit;
}
.field-row .value-text {
  font-size: 15px;
  color: var(--text-primary);
  flex: 1;
}
.field-row .value-text.placeholder {
  color: var(--text-muted);
}
.field-row .chevron {
  color: var(--text-muted);
  font-size: 14px;
  margin-left: 8px;
}
.selector-field {
  cursor: pointer;
}
.field-group {
  margin-bottom: 20px;
}

/* === BOTONES === */
.btn-primary-custom {
  width: 100%;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  font-family: inherit;
}
.btn-primary-custom:hover { background: #283593; }
.btn-primary-custom:disabled { background: var(--primary-light); cursor: not-allowed; }

.btn-danger-custom {
  width: 100%;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  font-family: inherit;
}
.btn-danger-custom:hover { background: var(--danger-hover); }
.btn-danger-custom:disabled { background: #ef9a9a; cursor: not-allowed; }

.btn-outline-custom {
  width: 100%;
  background: var(--primary-bg);
  color: var(--primary);
  border: none;
  border-radius: var(--radius);
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  font-family: inherit;
}
.btn-outline-custom:hover { background: #c5cae9; }

.btn-submit .spinner { display: none; }
.btn-submit.loading .spinner { display: inline-block; margin-right: 8px; }
.btn-submit.loading .btn-text { opacity: 0.7; }

/* === TOGGLES === */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 0;
  cursor: pointer;
}
.toggle-row .checkbox-icon {
  width: 28px;
  text-align: center;
  font-size: 20px;
  color: var(--text-muted);
}
.toggle-row .checkbox-icon.checked { color: var(--primary); }
.toggle-row .toggle-label {
  font-size: 13px;
  color: #444;
  line-height: 1.4;
  flex: 1;
}

/* === SELECTOR SWITCH (login) === */
.switch-track {
  width: 48px;
  height: 26px;
  background: #d6d6d6;
  border-radius: 13px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.switch-track.active { background: var(--primary-light); }
.switch-thumb {
  width: 22px;
  height: 22px;
  background: #f3f3f3;
  border-radius: 11px;
  position: absolute;
  top: 2px; left: 2px;
  transition: left 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.switch-track.active .switch-thumb {
  left: 24px;
  background: var(--primary);
}

/* === TRIPULACION === */
.tripulacion-section {
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-input);
}
.tripulacion-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
}
.tripulacion-header span { font-size: 15px; color: var(--text-primary); }
.tripulacion-header .count { color: var(--text-secondary); font-size: 13px; }
.tripulacion-body { padding: 12px 14px; }
.tripulante-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid #eee;
  font-size: 14px;
}
.tripulante-item:last-child { border-bottom: none; }
.tripulante-item .remove-btn {
  background: none; border: none;
  color: var(--danger); cursor: pointer;
  font-size: 16px; padding: 2px 6px;
}
.add-tripulante-form { display: flex; gap: 8px; margin-top: 10px; }
.add-tripulante-form input {
  flex: 1; padding: 8px 12px;
  border: 1px solid #ddd; border-radius: 8px;
  font-size: 13px; outline: none; font-family: inherit;
}
.add-tripulante-form input:focus { border-color: var(--primary); }
.add-tripulante-form button {
  background: var(--primary); color: #fff;
  border: none; border-radius: 8px;
  padding: 8px 14px; font-size: 13px;
  cursor: pointer; white-space: nowrap;
}

/* === DIVISOR === */
.divider {
  height: 1px;
  background: #e8e8ed;
  margin: 20px 0;
}

/* === VESSEL CARD === */
.vessel-card {
  text-align: center;
  padding: 16px 0;
  margin-bottom: 8px;
}
.vessel-card .vessel-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}
.vessel-card .vessel-reg { font-size: 14px; color: var(--text-secondary); }

/* === INFO BOX === */
.info-box {
  background: #fff3e0;
  border: 1px solid #ffe0b2;
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 20px;
  font-size: 13px;
  color: #e65100;
  line-height: 1.5;
}
.info-box i { color: #ef6c00; margin-right: 6px; }

/* === MODAL === */
.modal-overlay {
  display: none;
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.4);
  z-index: 1060;
  justify-content: center;
  align-items: center;
  padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal-box {
  background: #fff;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 420px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 20px;
}
.modal-box h2 { font-size: 18px; color: var(--text-primary); margin-bottom: 12px; }
.modal-box .option-item {
  padding: 12px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  color: var(--text-primary);
  transition: background 0.15s;
}
.modal-box .option-item:hover { background: #f0f0f5; }
.modal-box .option-item.selected { background: var(--primary-bg); color: var(--primary); font-weight: 600; }
.modal-close-btn {
  background: none; border: none;
  font-size: 14px; color: var(--text-secondary);
  cursor: pointer; float: right; padding: 4px 8px;
}
.modal-box .add-new-option {
  margin-top: 12px; padding-top: 12px;
  border-top: 1px solid #eee;
}
.modal-box .add-new-option input {
  width: 100%; padding: 10px 12px;
  border: 1px solid #ddd; border-radius: 8px;
  font-size: 14px; outline: none; font-family: inherit;
}
.modal-box .add-new-option input:focus { border-color: var(--primary); }
.modal-box .add-new-option button {
  margin-top: 8px; background: var(--primary);
  color: #fff; border: none; border-radius: 8px;
  padding: 8px 16px; font-size: 13px;
  cursor: pointer; width: 100%; font-family: inherit;
}

/* === LOGIN === */
.login-page {
  background: var(--primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  overflow: hidden;
}
.login-body { padding: 32px 24px; }
.logo-area { text-align: center; margin-bottom: 24px; }
.logo-circle {
  width: 120px; height: 120px;
  background: var(--primary-bg);
  border-radius: 60px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  color: var(--primary);
}
.login-links { text-align: center; margin-top: 16px; }
.login-links .link-row { margin: 8px 0; font-size: 14px; color: #888; }
.login-links .link-row a {
  color: var(--primary); font-weight: 600;
  text-decoration: none; cursor: pointer;
}
.login-links .link-row a:hover { text-decoration: underline; }
.password-toggle {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  padding: 6px; font-size: 16px;
}
.password-toggle:hover { color: var(--text-primary); }
.version-text {
  text-align: right;
  margin-top: 20px;
  font-size: 12px;
  color: #aaa;
}

/* === UTILITARIOS === */
.description {
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 24px;
  line-height: 1.5;
}

/* === FLATPICKR === */
.flatpickr-calendar { border-radius: var(--radius) !important; }
