/* Control Horario Plugin - Estils (admin + public) */
/* Scope: només classes ch-* per evitar afectar el tema */

.ch-admin-panel,
.ch-employee-panel,
.ch-login-form,
.ch-summary-card,
#ch-employee-times {
  --ch-text: #0f172a;
  --ch-muted: #475569;
  --ch-border: rgba(15, 23, 42, 0.12);
  --ch-border-strong: rgba(15, 23, 42, 0.18);
  --ch-surface: #ffffff;
  --ch-surface-2: #f8fafc;
  --ch-accent: #0f172a;
  --ch-accent-hover: #111827;
  --ch-danger: #b91c1c;
  --ch-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  color: var(--ch-text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  box-sizing: border-box;
}

.ch-admin-panel *,
.ch-employee-panel *,
.ch-login-form *,
.ch-summary-card *,
#ch-employee-times * {
  box-sizing: border-box;
}

.ch-admin-panel,
.ch-employee-panel,
.ch-login-form {
  width: min(820px, calc(100% - 32px));
  margin: 24px auto;
  padding: 22px;
  background: var(--ch-surface);
  border: 1px solid var(--ch-border);
  border-radius: 16px;
  box-shadow: var(--ch-shadow);
}

.ch-title,
.ch-admin-panel h2,
.ch-employee-panel h2,
.ch-login-form h2,
#ch-employee-times h3,
#ch-employee-times h4 {
  margin: 0 0 14px 0;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ch-text);
}

.ch-admin-panel h2,
.ch-employee-panel h2,
.ch-login-form h2,
.ch-title {
  font-size: 22px;
}

.ch-admin-panel h3,
#ch-employee-times h3 {
  margin: 18px 0 12px;
  font-size: 16px;
  font-weight: 700;
  color: var(--ch-text);
}

.ch-admin-panel h4,
#ch-employee-times h4 {
  margin: 16px 0 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ch-text);
}

.ch-note {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--ch-muted);
  line-height: 1.45;
}

.ch-warning {
  width: min(820px, calc(100% - 32px));
  margin: 18px auto;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.14);
  color: #7c2d12;
  font-weight: 600;
}

/* Formularis */
.ch-form,
.ch-admin-panel form,
.ch-login-form form {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
}

.ch-form label,
.ch-admin-panel label,
.ch-login-form label {
  display: grid;
  gap: 6px;
  font-weight: 600;
  color: var(--ch-text);
}

.ch-form input[type="text"],
.ch-form input[type="email"],
.ch-form input[type="password"],
.ch-admin-panel input[type="text"],
.ch-admin-panel input[type="email"],
.ch-admin-panel input[type="password"],
.ch-login-form input[type="text"],
.ch-login-form input[type="email"],
.ch-login-form input[type="password"],
.ch-admin-panel input[type="time"],
.ch-admin-panel input[type="date"],
#nfc-url {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--ch-border-strong);
  background: var(--ch-surface-2);
  color: var(--ch-text);
  outline: none;
}

.ch-form input:focus,
.ch-admin-panel input:focus,
.ch-login-form input:focus {
  border-color: rgba(15, 23, 42, 0.35);
  box-shadow: 0 0 0 4px rgba(15, 23, 42, 0.08);
  background: #ffffff;
}

/* Botons */
.ch-admin-panel button,
.ch-login-form button,
.ch-employee-panel button,
.ch-month-navigation button,
.ch-change-month,
.ch-change-month-public,
.ch-add-manual {
  appearance: none;
  border: 1px solid var(--ch-accent);
  background: var(--ch-accent);
  color: #ffffff;
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.04s ease, filter 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.ch-admin-panel button:hover,
.ch-login-form button:hover,
.ch-employee-panel button:hover,
.ch-month-navigation button:hover,
.ch-change-month:hover,
.ch-change-month-public:hover,
.ch-add-manual:hover {
  background: var(--ch-accent-hover);
  border-color: var(--ch-accent-hover);
  filter: brightness(1.03);
}

.ch-admin-panel button:active,
.ch-login-form button:active,
.ch-employee-panel button:active,
.ch-month-navigation button:active,
.ch-change-month:active,
.ch-change-month-public:active,
.ch-add-manual:active {
  transform: translateY(1px);
}

#ch-logout {
  background: transparent;
  color: var(--ch-text);
  border-color: var(--ch-border-strong);
}

#ch-logout:hover {
  background: rgba(15, 23, 42, 0.06);
  border-color: rgba(15, 23, 42, 0.24);
}

#ch-edit-cancel {
  background: transparent;
  color: var(--ch-text);
  border-color: var(--ch-border-strong);
}

#ch-edit-cancel:hover {
  background: rgba(15, 23, 42, 0.06);
}

.ch-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

/* Accions (icones) */
.ch-actions {
  white-space: nowrap;
}

.ch-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--ch-border-strong);
  background: #ffffff;
  text-decoration: none;
  margin-right: 8px;
}

.ch-action:hover {
  background: rgba(15, 23, 42, 0.05);
}

/* Taules */
.ch-admin-table,
.ch-times-table,
.ch-monthly-table {
  width: 100%;
  margin: 14px 0 0;
  border: 1px solid var(--ch-border);
  border-radius: 14px;
  overflow: hidden;
  border-collapse: separate;
  border-spacing: 0;
  background: #ffffff;
}

.ch-admin-table thead th,
.ch-times-table thead th,
.ch-monthly-table thead th {
  background: var(--ch-surface-2);
  color: var(--ch-text);
  text-align: left;
  font-weight: 800;
  padding: 12px 12px;
  border-bottom: 1px solid var(--ch-border);
  font-size: 13px;
}

.ch-admin-table tbody td,
.ch-times-table tbody td,
.ch-monthly-table tbody td {
  padding: 12px 12px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.07);
  font-size: 13px;
  color: var(--ch-text);
}

.ch-admin-table tbody tr:hover,
.ch-times-table tbody tr:hover,
.ch-monthly-table tbody tr:hover {
  background: rgba(15, 23, 42, 0.03);
}

.ch-admin-table tbody tr:last-child td,
.ch-times-table tbody tr:last-child td,
.ch-monthly-table tbody tr:last-child td {
  border-bottom: none;
}


/* Panell de fitxatges (AJAX) */
#ch-employee-times {
  width: min(980px, calc(100% - 32px));
  margin: 18px auto 0;
}

.ch-times-panel {
  padding: 18px;
  background: var(--ch-surface);
  border: 1px solid var(--ch-border);
  border-radius: 16px;
  box-shadow: var(--ch-shadow);
}

/* Enllaços (mapa / imprimir) */
.ch-times-panel a,
.ch-summary-card a {
  color: var(--ch-accent) !important;
  text-decoration: underline !important;
  font-weight: 700;
}

.ch-map-link {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  color: var(--ch-accent) !important;
  text-decoration: underline !important;
}

.ch-map-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--ch-border-strong);
  background: rgba(15, 23, 42, 0.04);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none !important;
}

.ch-ip {
  color: var(--ch-muted);
  font-weight: 700;
}

/* Files especials de la taula */
.ch-day-total td {
  font-weight: 900;
  background: var(--ch-surface-2);
}

.ch-manual-row td {
  background: #ffffff;
}

/* Resums i navegacio mesos */
.ch-summary-card {
  width: min(820px, calc(100% - 32px));
  margin: 18px auto 0;
  padding: 16px;
  background: var(--ch-surface);
  border: 1px solid var(--ch-border);
  border-radius: 16px;
  box-shadow: var(--ch-shadow);
}

.ch-month-navigation {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

/* Modals */
#ch-edit-employee-modal {
  background: rgba(15, 23, 42, 0.45);
}

.ch-modal-content {
  background: #ffffff;
  margin: 6vh auto;
  padding: 18px;
  width: min(720px, calc(100% - 32px));
  border-radius: 16px;
  border: 1px solid var(--ch-border);
  box-shadow: var(--ch-shadow);
  position: relative;
}

#ch-print-modal .ch-modal-content {
  margin: 6vh auto;
}

/* Ajustos responsive */
@media (max-width: 640px) {
  .ch-admin-panel,
  .ch-employee-panel,
  .ch-login-form {
    width: calc(100% - 20px);
    padding: 16px;
    border-radius: 14px;
  }

  .ch-action {
    width: 36px;
    height: 36px;
  }

  .ch-admin-table thead th,
  .ch-times-table thead th,
  .ch-monthly-table thead th,
  .ch-admin-table tbody td,
  .ch-times-table tbody td,
  .ch-monthly-table tbody td {
    padding: 10px 10px;
  }
}
