/* ============ Variables ============ */
:root {
  --primary: #1565c0;
  --primary-dark: #0d47a1;
  --primary-light: #bbdefb;
  --accent: #e53935;
  --bg: #f5f5f5;
  --surface: #ffffff;
  --weekend-bg: #eceff1;
  --weekend-header-bg: #455a64;
  --available: #4caf50;
  --booked: #e53935;
  --cell-h: 42px;
  --cell-w: 110px;
}

* {
  box-sizing: border-box;
}

body {
  font-family: "Roboto", sans-serif;
  background: var(--bg);
  margin: 0;
  -webkit-user-select: none;
  user-select: none;
}

/* ============ Login ============ */
.login-screen {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: linear-gradient(135deg, #0d47a1 0%, #1565c0 50%, #1976d2 100%);
}
.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 40px 36px;
  text-align: center;
  max-width: 420px;
  width: 90%;
}
.login-icon {
  font-size: 3.5rem;
  color: var(--primary);
  margin-bottom: 8px;
}
.login-card h5 {
  margin: 8px 0 4px;
  font-weight: 700;
}
.login-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 24px;
}
.login-btn {
  width: 100%;
  text-transform: none !important;
  font-size: 1rem !important;
  height: 44px;
  line-height: 44px;
}
.input-field.pin-field {
  position: relative;
}
.pin-field input[type="password"],
.pin-field input[type="text"] {
  padding-right: 40px !important;
}
.pin-toggle {
  position: absolute;
  right: 4px;
  bottom: 8px;
  cursor: pointer;
  color: #888;
  user-select: none;
  font-size: 22px;
  padding: 4px;
}
.pin-toggle:hover {
  color: var(--primary);
}

/* ============ Nav ============ */
.nav-bar {
  background: var(--primary) !important;
}
.nav-bar .brand-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 16px !important;
  font-size: 1.3rem;
  font-weight: 500;
}
.badge-admin {
  background: #ff9800;
  color: #fff;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ============ Toolbar ============ */
.toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  position: sticky;
  top: 0;
  z-index: 50;
}
.toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.month-title {
  font-size: 1.25rem;
  font-weight: 500;
  min-width: 200px;
  text-align: center;
}

/* ============ Legend ============ */
.legend-bar {
  display: flex;
  gap: 16px;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid #e0e0e0;
  font-size: 0.85rem;
  flex-wrap: wrap;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}
.legend-swatch {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  border: 1px solid #ccc;
}

/* ============ Planning Grid ============ */
.planning-wrapper {
  overflow-x: auto;
  padding: 12px 8px;
}

.planning-table {
  border-collapse: collapse;
  font-size: 0.85rem;
  width: 100%;
}

.planning-table th,
.planning-table td {
  border: 1px solid #cfd8dc;
  text-align: center;
  vertical-align: top;
  padding: 4px 2px;
}

/* Day column headers */
.day-col {
  min-width: var(--cell-w);
  max-width: 160px;
  width: var(--cell-w);
}

.day-header {
  background: var(--primary);
  color: #fff;
  font-weight: 500;
  font-size: 0.82rem;
  padding: 6px 4px;
}
.day-header.saturday,
.day-header.sunday,
.day-header.holiday {
  background: var(--weekend-header-bg);
}
.day-num-header {
  font-size: 0.95rem;
  font-weight: 700;
}

/* Slot cells container */
.slots-cell {
  min-height: 60px;
  padding: 4px !important;
  vertical-align: top !important;
  background: var(--surface);
}
.slots-cell.saturday,
.slots-cell.sunday,
.slots-cell.holiday {
  background: var(--weekend-bg);
}

/* Individual slot chip */
.slot-chip {
  display: block;
  margin: 2px 0;
  padding: 6px 4px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition:
    transform 0.1s,
    box-shadow 0.1s;
  line-height: 1.3;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.slot-chip:hover {
  transform: scale(1.03);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Available slot */
.slot-chip.available {
  opacity: 0.95;
}
.slot-chip.available::after {
  content: "Disponible";
  display: block;
  font-size: 0.65rem;
  font-weight: 400;
  opacity: 0.85;
  margin-top: 2px;
}

/* Booked slot */
.slot-chip.booked {
  background: var(--booked) !important;
  opacity: 1;
}
.slot-chip.booked .slot-booker {
  display: block;
  font-size: 0.65rem;
  font-weight: 400;
  margin-top: 2px;
}

/* Pending remote — someone else is booking */
.slot-chip.pending-remote {
  background: #ff9800 !important;
  opacity: 1;
  animation: pulse-pending 1.5s ease-in-out infinite;
}
.slot-chip.pending-remote .pending-warning {
  display: block;
  font-size: 0.6rem;
  font-weight: 500;
  margin-top: 2px;
  color: #fff;
}
@keyframes pulse-pending {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

/* Admin delete button on slot */
.slot-delete-btn {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #333;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 12px;
  line-height: 18px;
  text-align: center;
  cursor: pointer;
  display: none;
  padding: 0;
}
.slot-chip-wrapper {
  position: relative;
  display: block;
}
.slot-chip-wrapper:hover .slot-delete-btn {
  display: block;
}

/* ============ Add Slot Calendar ============ */
.add-slot-calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-top: 8px;
}
.add-slot-calendar .cal-header {
  text-align: center;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 4px;
  color: #666;
}
.add-slot-calendar .cal-day {
  text-align: center;
  padding: 10px 4px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  border: 2px solid transparent;
  transition: all 0.15s;
  background: #f5f5f5;
}
.add-slot-calendar .cal-day:hover {
  background: #e3f2fd;
}
.add-slot-calendar .cal-day.selected {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary-dark);
}
.add-slot-calendar .cal-day.empty {
  visibility: hidden;
}
.add-slot-calendar .cal-day.weekend {
  color: #999;
}
.add-slot-calendar .cal-day.holiday {
  color: #e53935;
}

.selected-days-display {
  margin-top: 8px;
  font-size: 0.9rem;
  color: #555;
}
.selected-days-display .chip {
  margin: 2px;
}

/* Slot type selector */
.slot-type-selector {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.slot-type-btn {
  padding: 8px 16px;
  border-radius: 20px;
  border: 2px solid #ccc;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s;
  color: #333;
  background: #fff;
}
.slot-type-btn:hover {
  border-color: var(--primary);
}
.slot-type-btn.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

/* ============ Indicator row ============ */
.indicator-row td {
  padding: 0 !important;
  border-top: 2px solid #cfd8dc;
}
.indicator-cell {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 2px !important;
  text-align: center;
  height: 22px;
}
.indicator-empty {
  background: #fafafa;
  color: #bbb;
}
.indicator-free {
  background: #e8f5e9;
  color: #388e3c;
}
.indicator-partial {
  background: #fff3e0;
  color: #ef6c00;
}
.indicator-full {
  background: #ffebee;
  color: #c62828;
}

/* ============ Inscrits section (admin) ============ */
.inscrits-wrapper {
  padding: 16px;
  margin: 0 8px 16px;
  background: var(--surface);
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}
.inscrits-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}
.inscrits-header h6 {
  margin: 0;
  font-weight: 600;
  font-size: 1.05rem;
}
#inscrits-table {
  font-size: 0.85rem;
}
#inscrits-table th {
  background: var(--primary);
  color: #fff;
  padding: 8px 10px;
  font-weight: 500;
}
#inscrits-table td {
  padding: 6px 10px;
}

/* ============ Stats ============ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: #f5f5f5;
  border-radius: 10px;
  padding: 20px;
  text-align: center;
}
.stat-card .stat-value {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--primary);
}
.stat-card .stat-label {
  font-size: 0.9rem;
  color: #666;
  margin-top: 4px;
}
.stats-table {
  margin-top: 16px;
}
.stats-table th {
  background: var(--primary);
  color: #fff;
  padding: 8px 12px;
}
.stats-table td {
  padding: 8px 12px;
}

/* ============ Settings slot type rows ============ */
.slot-type-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.slot-type-row input[type="text"] {
  flex: 1;
  margin: 0 !important;
  height: 2.5rem;
}
.slot-type-row input[type="color"] {
  width: 40px;
  height: 36px;
  border: none;
  cursor: pointer;
  padding: 0;
}
.slot-type-row .btn-flat {
  padding: 0 8px;
}

/* ============ Modals ============ */
.modal {
  border-radius: 10px !important;
}
.modal-large {
  width: 80% !important;
  max-width: 900px;
  max-height: 85vh;
}
.modal .modal-content h5 {
  font-weight: 600;
  margin-bottom: 16px;
}

/* ============ Responsive ============ */
@media (max-width: 768px) {
  .toolbar {
    padding: 8px;
  }
  .month-title {
    min-width: 140px;
    font-size: 1.05rem;
  }
  .legend-bar {
    padding: 6px 8px;
    gap: 10px;
  }
  .planning-wrapper {
    padding: 8px 4px;
  }
  :root {
    --cell-w: 90px;
  }
  .modal-large {
    width: 95% !important;
  }
  .login-card {
    padding: 24px 20px;
  }
}

/* ============ Info section (notes + documents) ============ */
.info-section {
  margin: 0 8px 16px;
}
.info-wrapper {
  padding: 16px;
  background: var(--surface);
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}
.info-wrapper h6 {
  margin: 0 0 12px;
  font-weight: 600;
  font-size: 1.05rem;
}
.info-notes-content {
  padding: 12px;
  background: #f5f5f5;
  border-radius: 6px;
  line-height: 1.6;
  margin-bottom: 16px;
}
.info-notes-content ul,
.info-notes-content ol {
  padding-left: 24px;
  margin: 8px 0;
}
.info-notes-content li {
  list-style: disc;
  margin-bottom: 4px;
}
.info-notes-content ol li {
  list-style: decimal;
}
#info-docs .collection {
  margin: 0;
  border: none;
}
#info-docs .collection-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
}
.doc-link {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
}

/* ============ Notes editor ============ */
.notes-toolbar {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
  padding: 4px 0;
  border-bottom: 1px solid #e0e0e0;
}
.notes-toolbar .btn-flat {
  padding: 0 8px;
  min-width: 36px;
}
.notes-editor {
  min-height: 200px;
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 12px;
  outline: none;
  background: #fff;
  line-height: 1.6;
}
.notes-editor:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

/* ============ Admin docs table ============ */
#admin-docs-table {
  font-size: 0.85rem;
}
#admin-docs-table th {
  background: var(--primary);
  color: #fff;
  padding: 8px 10px;
  font-weight: 500;
}
#admin-docs-table td {
  padding: 6px 10px;
}
