/* ============================================
   AGILENT CALENDAR - Mobile First CSS
   ============================================ */

:root {
  --primary: #1976D2;
  --primary-dark: #1565C0;
  --primary-light: #BBDEFB;
  --accent: #0288D1;
  --bg: #F5F7FA;
  --surface: #FFFFFF;
  --border: #E0E0E0;
  --text: #212121;
  --text-secondary: #757575;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(0,0,0,0.10);

  /* Colores PRL */
  --color-green: #4CAF50;
  --color-orange: #FF9800;
  --color-yellow: #FFC107;
  --color-blue: #2196F3;
  --color-grey: #9E9E9E;
  --color-red: #F44336;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  min-height: 100vh;
}

/* ============================================
   HEADER / NAV
   ============================================ */
.app-header {
  background: var(--primary);
  color: white;
  padding: 0 16px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.app-header h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.app-header .user-info {
  font-size: 13px;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-logout {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.2s;
}
.btn-logout:hover { background: rgba(255,255,255,0.25); }

/* ============================================
   LOGIN
   ============================================ */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1565C0 0%, #0288D1 100%);
  padding: 16px;
}

.login-card {
  background: white;
  border-radius: 16px;
  padding: 36px 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo h2 {
  color: var(--primary);
  font-size: 22px;
  font-weight: 700;
  margin-top: 8px;
}

.login-logo p {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 4px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  color: var(--text);
  background: white;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}

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

.btn-primary {
  width: 100%;
  background: var(--primary);
  color: white;
  border: none;
  padding: 14px;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 8px;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  background: white;
  color: var(--primary);
  border: 1.5px solid var(--primary);
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-secondary:hover { background: var(--primary-light); }

.btn-danger {
  background: #ffebee;
  color: var(--color-red);
  border: 1.5px solid var(--color-red);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}

.error-msg {
  color: var(--color-red);
  font-size: 13px;
  margin-top: 8px;
  text-align: center;
}

/* ============================================
   LAYOUT PRINCIPAL
   ============================================ */
.main-content {
  padding: 16px;
  max-width: 900px;
  margin: 0 auto;
}

.main-content.wide {
  max-width: 1400px;
}

/* ============================================
   WEEK NAVIGATION
   ============================================ */
.week-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.week-nav h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  flex: 1;
}

.btn-nav {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--primary);
  padding: 4px 10px;
  border-radius: 8px;
  transition: background 0.2s;
}
.btn-nav:hover { background: var(--primary-light); }

/* ============================================
   SELECTOR DE TÉCNICO (coordinador)
   ============================================ */
.technician-selector {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 12px;
}

.technician-selector label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

.technician-selector select {
  flex: 1;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  -webkit-appearance: none;
}

/* ============================================
   CALENDARIO SEMANAL
   ============================================ */
.calendar-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.day-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.day-header {
  background: var(--primary);
  color: white;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.day-header .day-name {
  font-weight: 600;
  font-size: 14px;
  text-transform: capitalize;
}

.day-header .day-date {
  font-size: 13px;
  opacity: 0.85;
}

.day-header.weekend {
  background: #78909C;
}

.day-entries {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 52px;
}

/* Entrada de cliente en el calendario */
.entry-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #F5F5F5;
  border-left: 4px solid var(--color-grey);
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  margin-top: 5px;
}

.entry-chip:active { transform: scale(0.98); }

.entry-chip .entry-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: 3px;
}

.entry-chip .entry-info {
  flex: 1;
  min-width: 0;
}

.entry-chip .entry-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entry-chip .entry-meta {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entry-chip .entry-badge {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 10px;
  color: white;
  white-space: nowrap;
  flex-shrink: 0;
  align-self: flex-start;
}

.entry-chip .btn-remove {
  background: none;
  border: none;
  color: #BDBDBD;
  font-size: 18px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.2s;
}
.entry-chip .btn-remove:hover { color: var(--color-red); }

/* Botón agregar cliente al día */
.btn-add-entry {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: none;
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  width: 100%;
  transition: all 0.2s;
}
.btn-add-entry:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

/* ============================================
   COLORES DE ESTADO PRL
   ============================================ */
.prl-not-required  { border-left-color: var(--color-green) !important; }
.prl-pending       { border-left-color: var(--color-orange) !important; }
.prl-in-progress   { border-left-color: var(--color-yellow) !important; }
.prl-completed     { border-left-color: var(--color-blue) !important; }
.prl-basic         { border-left-color: var(--color-grey) !important; }

.badge-not-required { background: var(--color-green); }
.badge-pending      { background: var(--color-orange); }
.badge-in-progress  { background: var(--color-yellow); color: #333 !important; }
.badge-completed    { background: var(--color-blue); }
.badge-basic        { background: var(--color-grey); }

/* ============================================
   LEYENDA DE COLORES
   ============================================ */
.legend {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.legend h3 {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 10px;
  letter-spacing: 0.5px;
}

.legend-items {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ============================================
   MODAL
   ============================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: white;
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  overflow-x: visible;
  padding: 20px;
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 17px;
  font-weight: 600;
}

.btn-close {
  background: #F5F5F5;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

.modal-section {
  margin-bottom: 16px;
}

.modal-section h4 {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.modal-section p {
  font-size: 14px;
  line-height: 1.5;
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.info-item label {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.info-item span {
  font-size: 14px;
  font-weight: 500;
}

/* Selector de color en modal */
.color-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

.color-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}

.color-btn:hover { transform: scale(1.15); }
.color-btn.selected { border-color: var(--text); transform: scale(1.1); }

/* ============================================
   MODAL AGREGAR CLIENTE
   ============================================ */
.client-search-wrapper {
  position: relative;
}

.client-dropdown {
  position: fixed;
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  max-height: min(220px, 40vh);
  overflow-y: auto;
  z-index: 1000;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  display: none;
}

.client-dropdown.active { display: block; }

.client-option {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid #F5F5F5;
  transition: background 0.1s;
}
.client-option:hover { background: var(--primary-light); }
.client-option:last-child { border-bottom: none; }

.client-option .opt-name { font-size: 14px; font-weight: 500; }
.client-option .opt-meta { font-size: 12px; color: var(--text-secondary); }

.client-option .opt-new {
  color: var(--primary);
  font-size: 14px;
  font-weight: 500;
}

/* ============================================
   FORMULARIO NUEVO CLIENTE
   ============================================ */
.new-client-form {
  background: #F8F9FA;
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 12px;
  display: none;
}
.new-client-form.active { display: block; }
.new-client-form h4 { margin-bottom: 12px; font-size: 14px; color: var(--text-secondary); }

/* ============================================
   VISTA COORDINADOR - Tabs de técnicos
   ============================================ */
.tech-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 16px;
  scrollbar-width: none;
}
.tech-tabs::-webkit-scrollbar { display: none; }

.tech-tab {
  background: white;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  color: var(--text-secondary);
}
.tech-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* ============================================
   LOADING / EMPTY STATE
   ============================================ */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
  font-size: 14px;
}

.empty-state {
  text-align: center;
  padding: 20px;
  color: #BDBDBD;
  font-size: 13px;
}

/* ============================================
   TOAST NOTIFICATION
   ============================================ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #323232;
  color: white;
  padding: 12px 20px;
  border-radius: 24px;
  font-size: 14px;
  z-index: 500;
  transition: transform 0.3s ease;
  pointer-events: none;
  white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--color-green); }
.toast.error   { background: var(--color-red); }

/* ============================================
   RESPONSIVE - Tablet y desktop
   ============================================ */
@media (min-width: 600px) {
  .main-content { padding: 20px; }

  .calendar-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
  }

  .modal {
    border-radius: 16px;
    max-height: 80vh;
    margin: auto;
    animation: fadeIn 0.2s ease;
  }

  .modal-overlay {
    align-items: center;
  }

  @keyframes fadeIn {
    from { opacity: 0; transform: scale(0.96); }
    to   { opacity: 1; transform: scale(1); }
  }
}

@media (min-width: 900px) {
  .app-header h1 { font-size: 20px; }
  .main-content { padding: 24px; }
}

/* ============================================
   DAY BLOCKS
   ============================================ */
.day-block {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  margin-top: 5px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: white;
}
.day-block.vacaciones { background: #26A69A; }
.day-block.curso      { background: #7E57C2; }
.day-block.baja       { background: #EF5350; }
.day-block.festivo    { background: #FF7043; }
.day-block.otro       { background: #78909C; }

.btn-block-day {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 7px 10px;
  margin-top: 4px;
  background: none;
  border: 1.5px dashed #BDBDBD;
  border-radius: 10px;
  color: #9E9E9E;
  font-size: 13px;
  cursor: pointer;
}
.btn-block-day:hover { border-color: #9E9E9E; color: #616161; }
