/* Japanizer - styles partages, theme sombre par defaut + theme clair */

:root,
[data-theme="dark"] {
  --bg: #0f1216;
  --bg-elevated: #161b22;
  --bg-card: #1b212a;
  --bg-hover: #232a35;
  --border: #2a323d;
  --text: #e6e9ef;
  --text-muted: #9aa4b2;
  --accent: #4f8cff;
  --accent-hover: #6fa1ff;
  --accent-text: #ffffff;
  --success: #35c98f;
  --danger: #ff6a6a;
  --warning: #f5a623;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --radius: 10px;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f5f6f8;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #eef1f5;
  --border: #dde2e8;
  --text: #1a1f27;
  --text-muted: #5b6472;
  --accent: #2f6fed;
  --accent-hover: #245ed1;
  --accent-text: #ffffff;
  --success: #1a9b6c;
  --danger: #d84343;
  --warning: #b9790a;
  --shadow: 0 8px 24px rgba(20, 25, 35, 0.08);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background-color 0.15s ease, color 0.15s ease;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

button, input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
}

button {
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
  background: var(--bg-hover);
  color: var(--text);
  padding: 10px 16px;
  transition: background-color 0.15s ease, transform 0.05s ease;
}
button:hover { background: var(--border); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

button.primary {
  background: var(--accent);
  color: var(--accent-text);
}
button.primary:hover { background: var(--accent-hover); }

button.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}
button.danger:hover { background: var(--danger); color: #fff; }

button.ghost {
  background: transparent;
  border: 1px solid var(--border);
}

input[type="text"], input[type="email"], input[type="password"], input[type="date"],
input[type="time"], input[type="url"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}

label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 600;
}

.field { margin-bottom: 16px; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 2px);
  box-shadow: var(--shadow);
  padding: 24px;
}

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  font-weight: 700;
  font-size: 20px;
}
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }

.hint { color: var(--text-muted); font-size: 13px; margin-top: 16px; text-align: center; }

.error-box {
  background: color-mix(in srgb, var(--danger) 15%, var(--bg-card));
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.error-box.visible { display: block; }

.success-box {
  background: color-mix(in srgb, var(--success) 15%, var(--bg-card));
  border: 1px solid var(--success);
  color: var(--success);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.success-box.visible { display: block; }

.password-req {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.5;
}
.password-req ul { margin: 4px 0 0 0; padding-left: 18px; }
.password-req li.ok { color: var(--success); }

/* App shell */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .brand { margin-bottom: 0; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.user-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px; background: var(--bg-hover);
  font-size: 13px; color: var(--text-muted);
}
.user-pill .root-badge {
  background: var(--warning); color: #1a1f27; font-weight: 700;
  font-size: 10px; padding: 2px 6px; border-radius: 999px; letter-spacing: 0.03em;
}

.theme-toggle {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px;
}

main.container {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

.toolbar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.toolbar-group { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab-btn {
  background: transparent; border-radius: var(--radius) var(--radius) 0 0;
  padding: 10px 18px; color: var(--text-muted); border-bottom: 2px solid transparent;
}
.tab-btn.active { color: var(--text); border-bottom-color: var(--accent); background: var(--bg-hover); }

.week-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(140px, 1fr));
  gap: 10px;
  overflow-x: auto;
}
.day-col {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.day-col.today { border-color: var(--accent); }
.day-col-header { font-weight: 700; font-size: 13px; display: flex; justify-content: space-between; }
.day-col-header .date-num { color: var(--text-muted); font-weight: 400; }

.event-item, .reservation-item {
  background: var(--bg-hover);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12.5px;
  border-left: 3px solid var(--accent);
  cursor: pointer;
}
.event-item .time { color: var(--text-muted); font-size: 11px; }
.event-item .owner { color: var(--text-muted); font-size: 11px; }
.reservation-item { border-left-color: var(--success); }
.reservation-item a { display: block; word-break: break-all; }

.empty-state { color: var(--text-muted); font-size: 13px; text-align: center; padding: 40px 0; }

.day-list {
  display: flex; flex-direction: column; gap: 10px; max-width: 640px;
}
.day-list .event-item, .day-list .reservation-item { font-size: 14px; padding: 12px 14px; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal-backdrop.hidden { display: none; }
.modal { width: 100%; max-width: 480px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-header h2 { margin: 0; font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.modal-actions .spacer { flex: 1; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 600; }
select.perm-select { width: auto; padding: 6px 10px; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
  background: var(--bg-hover); color: var(--text-muted);
}
.badge.root { background: var(--warning); color: #1a1f27; }

.section-title { font-size: 15px; font-weight: 700; margin: 28px 0 12px; }
.section-title:first-child { margin-top: 0; }

@media (max-width: 720px) {
  .week-grid { grid-template-columns: repeat(7, minmax(120px, 1fr)); }
  main.container { padding: 14px; }
  .topbar { padding: 12px 14px; }
}
