:root {
  --bg: #f0f2f5;
  --surface: #ffffff;
  --primary: #2c3e50;
  --accent: #3498db;
  --accent-hover: #2980b9;
  --danger: #e74c3c;
  --success: #27ae60;
  --warning: #f39c12;
  --text: #2c3e50;
  --text-light: #7f8c8d;
  --border: #dcdde1;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
  --radius: 8px;
  --bar-color: #e74c3c;
  --salle-color: #3498db;
  --cuisine-color: #2ecc71;
  --morning-bg: #ebf5fb;
  --evening-bg: #fdf2e9;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

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

header {
  background: var(--primary);
  color: white;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

header h1 {
  font-size: 1.1rem;
  font-weight: 600;
}

header nav {
  display: flex;
  gap: 0.5rem;
}

header nav a, header nav button {
  color: white;
  text-decoration: none;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius);
  background: rgba(255,255,255,0.15);
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.2s;
}

header nav a:hover, header nav button:hover {
  background: rgba(255,255,255,0.25);
}

header nav a.active {
  background: rgba(255,255,255,0.35);
}

.badge {
  background: var(--danger);
  color: white;
  border-radius: 10px;
  padding: 0.1rem 0.4rem;
  font-size: 0.7rem;
  margin-left: 0.25rem;
}

.week-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.week-nav button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85rem;
}

.week-nav button:hover { background: var(--accent-hover); }
.week-nav button:disabled { opacity: 0.5; cursor: default; }

.week-nav .week-label {
  font-weight: 600;
  font-size: 0.95rem;
  min-width: 180px;
  text-align: center;
}

.week-nav .btn-today {
  background: var(--success);
}

.week-nav .btn-export {
  background: #8e44ad;
  margin-left: auto;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

.schedule-grid {
  display: grid;
  grid-template-columns: 100px 1fr 1fr;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.schedule-grid > div {
  background: var(--surface);
  padding: 0.5rem;
  min-height: 48px;
}

.schedule-grid .corner-cell {
  background: var(--primary);
}

.schedule-grid .header-cell {
  background: var(--primary);
  color: white;
  font-weight: 700;
  font-size: 0.85rem;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 0.3rem;
}

.schedule-grid .day-label {
  background: var(--primary);
  color: white;
  font-weight: 700;
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: 0.4rem 0.6rem;
  gap: 2px;
  line-height: 1.2;
}

.day-label .day-name {
  font-size: 0.85rem;
}

.day-label .day-date {
  font-weight: 400;
  font-size: 0.7rem;
  opacity: 0.8;
}

.day-label.today {
  background: #1a5276;
  border-left: 3px solid var(--accent);
}

.day-label.closed {
  background: #922b21;
}

.closed-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #922b21;
  font-size: 0.85rem;
  background: #fdedec !important;
  text-transform: uppercase;
  letter-spacing: 2px;
  cursor: default;
}

.btn-toggle-closure {
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.3);
  color: white;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 1px 4px;
  border-radius: 3px;
  margin-left: auto;
  flex-shrink: 0;
  line-height: 1;
}

.btn-toggle-closure:hover {
  background: rgba(255,255,255,0.35);
}

.schedule-cell {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  padding: 0.4rem;
  min-height: 48px;
  align-content: flex-start;
}

.schedule-cell:nth-child(6n+2),
.schedule-cell:nth-child(6n+3) {
  /* morning column pattern if needed */
}

.schedule-cell:hover {
  background: #f8f9fa;
}

.employee-tag {
  display: inline-block;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: white;
  cursor: pointer;
  transition: transform 0.1s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.employee-tag:hover {
  transform: scale(1.05);
}

.btn-remove-schedule {
  background: rgba(0,0,0,0.3);
  color: white;
  border: none;
  padding: 0 4px;
  margin-left: 2px;
  cursor: pointer;
  font-size: 0.8rem;
  border-radius: 2px;
  line-height: 1;
}

.btn-remove-schedule:hover {
  background: rgba(0,0,0,0.5);
}

.hint-text {
  color: #ccc;
  font-size: 0.7rem;
  pointer-events: none;
}

.position-badge {
  display: inline-block;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  margin-right: 2px;
}

.position-bar { background: var(--bar-color); color: white; }
.position-salle { background: var(--salle-color); color: white; }
.position-cuisine { background: var(--cuisine-color); color: white; }

.leave-indicator {
  background: #fadbd8;
  color: #c0392b;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  font-size: 0.65rem;
  font-weight: 600;
  border-left: 3px solid var(--danger);
}

.leave-indicator.leave-pending {
  background: #fef9e7;
  color: #7d6608;
  border-left-color: var(--warning);
}

.legend {
  display: flex;
  gap: 1rem;
  padding: 0.5rem 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8rem;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.validation-panel {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.validation-panel h3 {
  margin-bottom: 0.5rem;
  font-size: 1rem;
}

.issue {
  padding: 0.5rem;
  margin-bottom: 0.3rem;
  border-radius: 4px;
  font-size: 0.85rem;
}

.issue.error {
  background: #fadbd8;
  color: #c0392b;
  border-left: 4px solid var(--danger);
}

.issue.warning {
  background: #fef9e7;
  color: #7d6608;
  border-left: 4px solid var(--warning);
}

.issue.success {
  background: #d5f5e3;
  color: #1e8449;
  border-left: 4px solid var(--success);
}

.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.modal h2 {
  margin-bottom: 1rem;
  font-size: 1.2rem;
}

.modal label {
  display: block;
  margin-bottom: 0.3rem;
  font-weight: 600;
  font-size: 0.85rem;
}

.modal input, .modal select, .modal textarea {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.9rem;
  margin-bottom: 0.8rem;
  font-family: inherit;
}

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

.modal .btn-row {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
}

.btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: background 0.2s;
}

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #c0392b; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #219a52; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { background: #f0f0f0; }
.btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1rem;
}

.tab {
  padding: 0.6rem 1.2rem;
  cursor: pointer;
  border: none;
  background: none;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-light);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}

.tab:hover { color: var(--text); }
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.5rem;
  box-shadow: var(--shadow);
}

.employee-list, .leave-list, .message-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.employee-row, .leave-row, .message-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.employee-color {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
}

.employee-info { flex: 1; }
.employee-info .name { font-weight: 600; }
.employee-info .positions { font-size: 0.8rem; color: var(--text-light); }

.actions {
  display: flex;
  gap: 0.3rem;
}

.status-badge {
  padding: 0.2rem 0.5rem;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
}
.status-pending { background: #fef9e7; color: #7d6608; }
.status-approved { background: #d5f5e3; color: #1e8449; }
.status-rejected { background: #fadbd8; color: #c0392b; }

.message-row { flex-direction: column; align-items: flex-start; }
.message-row.unread { border-left: 4px solid var(--accent); }
.message-header { display: flex; justify-content: space-between; width: 100%; }
.message-subject { font-weight: 600; }
.message-meta { font-size: 0.75rem; color: var(--text-light); }
.message-content { font-size: 0.85rem; margin-top: 0.3rem; }

.filter-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--text-light);
}

.toast {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  color: white;
  font-weight: 600;
  z-index: 300;
  animation: slideIn 0.3s ease;
  max-width: 350px;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@media (max-width: 768px) {
  .schedule-grid {
    grid-template-columns: 80px 1fr 1fr;
    font-size: 0.7rem;
  }
  .schedule-grid .header-cell { font-size: 0.7rem; }
  .day-label { font-size: 0.7rem; }
  .employee-tag { font-size: 0.65rem; padding: 0.15rem 0.3rem; }
  .week-nav { flex-wrap: wrap; gap: 0.25rem; }
  .week-nav .week-label { min-width: auto; font-size: 0.8rem; }
  header h1 { font-size: 0.95rem; }
  header nav a { padding: 0.3rem 0.5rem; font-size: 0.75rem; }
}

.export-a4 {
  width: 1122px;
  padding: 20px;
  background: white;
  font-size: 12px;
}

.export-a4 .schedule-grid-h {
  display: grid;
  width: 100%;
  grid-template-columns: 90px repeat(6, 1fr);
  gap: 1px;
  background: #999;
  border: 1px solid #999;
}

.export-a4 .schedule-grid-h > div {
  background: white;
  min-height: 52px;
  padding: 6px 8px;
}

.export-a4 .schedule-grid-h .header-cell {
  background: #2c3e50;
  color: white;
  font-weight: 700;
  font-size: 0.85rem;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 4px;
}

.export-a4 .schedule-grid-h .shift-label {
  background: #2c3e50;
  color: white;
  font-weight: 700;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
}

.export-a4 .employee-tag {
  font-size: 0.75rem;
  padding: 3px 6px;
}

.export-a4 .position-badge {
  font-size: 0.65rem;
  padding: 1px 4px;
}

.export-title {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 700;
  color: #2c3e50;
  margin-bottom: 12px;
}

@media print {
  header, .week-nav, .validation-panel, .tabs, .btn-export, .btn-print { display: none; }
  .container { max-width: none; padding: 0; }
  .schedule-grid { border: 1px solid #000; }
  body { background: white; }
}
