:root {
  /* Colors */
  --color-black: #000;
  --color-white: #fff;
  --color-gray-100: #f9f9f9;
  --color-gray-200: #f5f5f5;
  --color-gray-300: #f0f0f0;
  --color-gray-400: #eee;
  --color-gray-500: #e6e6e6;
  --color-gray-600: #ddd;
  --color-gray-700: #ccc;
  --color-gray-800: #999;
  --color-gray-850: #888;
  --color-gray-900: #666;
  --color-gray-950: #333;
  --color-blue: #0066cc;
  --color-blue-dark: #004499;
  --color-red: #ff6b6b;
  --color-red-dark: #ff3333;
  --color-red-border: #991b1b;
  --color-border: var(--color-gray-500);

  /* Spacing: 4px grid, the number is the multiple of 4 */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
  --space-20: 80px;

  /* Sizing */
  --size-icon: 18px;
  --size-icon-lg: 20px;
  --size-icon-sm: 16px;
  --size-btn-icon: 32px;      /* every round icon button */
  --control-height: 40px;     /* inputs and text buttons */
  --control-height-lg: 48px;  /* main touch buttons on the vote page */

  /* Radius */
  --radius-sm: 4px;    /* inputs, small tags */
  --radius-md: 8px;    /* cards, table, modals */
  --radius-lg: 16px;   /* large showcase blocks (home) */
  --radius-full: 999px;

  /* Typography: 5 sizes, 2 weights, 3 line heights */
  --font-size-sm: 12px;    /* meta, labels, captions */
  --font-size-base: 14px;  /* UI text */
  --font-size-md: 16px;    /* inputs (no iOS zoom), list titles */
  --font-size-lg: 20px;    /* page and dialog titles */
  --font-size-xl: 24px;    /* poll title */
  --font-weight-regular: 400;
  --font-weight-bold: 600;
  --line-height-tight: 1;
  --line-height-snug: 1.25;
  --line-height-base: 1.5;

  /* Shadows */
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);

  /* Transitions */
  --transition-fast: 0.2s ease;
  --transition-medium: 0.3s ease;
}

/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* iOS Safari enlarges some text in landscape (footer, paragraphs): keep the sizes set here */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  color: var(--color-black);
  overflow-x: visible;
}

/* Form controls use the page font instead of the browser default (Arial 13.33px) */
button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

h1,
h2,
h3 {
  font-weight: var(--font-weight-bold);
}

.container {
  max-width: 800px;
  margin: 0 auto;
  min-height: 100vh;
  /* Mobile browsers: 100vh counts the area under the address bar, which forced a scroll to reach the footer */
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: visible;
}

/* Layout components */
.header {
  padding: var(--space-4);
  background-color: var(--color-white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}

.header-title {
  font-size: var(--font-size-xl);
  line-height: var(--line-height-tight);
  font-weight: var(--font-weight-bold);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.header-title.clickable {
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.header-title.clickable:hover {
  opacity: 0.7;
}

/* Brand name (brand_name() in i18n.php): the three l's of "Pollls" are rounded bars, yes green, no gray, yes green,
   with the favicon's proportions (6 wide, 26 tall, 3 apart) at the height of a letter l.
   The letters stay in the markup, transparent, for copy and screen readers */
.brand-name {
  white-space: nowrap;
}

.brand-lll {
  display: inline-block;
  margin: 0 0.03em;
}

.brand-lll i {
  display: inline-block;
  overflow: hidden;
  width: 0.163em;
  height: 0.705em;
  margin: 0 0.0405em;
  border-radius: 0.163em;
  background: #1AB75B;
  color: transparent;
  font-style: normal;
}

.brand-lll i:nth-child(2) {
  background: #99A1AF;
}

.header-title .logo {
  width: var(--size-icon-lg);
  height: var(--size-icon-lg);
  color: var(--color-black);
}

.header-title-container,
.header-buttons {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.header-buttons {
  gap: var(--space-4);
}

.header-user-info {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
}

/* Button styles */
.btn-text {
  font-size: var(--font-size-base);
  color: var(--color-gray-900);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
}

.btn-primary {
  background-color: var(--color-black);
  color: var(--color-white);
  padding: var(--space-2) var(--space-4);
  line-height: var(--space-6);
  border: none;
  border-radius: var(--radius-full);
  min-width: 100px;
  font-size: var(--font-size-base);
  cursor: pointer;
  display: inline-block;
}

.btn-primary:hover {
  background-color: var(--color-gray-950);
}

.btn-primary:disabled {
  background-color: var(--color-gray-800);
}

.btn-secondary {
  background-color: var(--color-gray-200);
  color: var(--color-gray-950);
  padding: calc(var(--space-2) - 1px) var(--space-4);
  line-height: var(--space-6);
  border: 1px solid var(--color-gray-600);
  border-radius: var(--radius-full);
  font-size: var(--font-size-base);
  cursor: pointer;
  display: inline-block;
}

.btn-secondary:hover {
  background-color: var(--color-gray-400);
}

/* Content areas */
.tab-content {
  display: none;
  flex-direction: column;
  flex: 1;
}

.tab-content.active {
  display: flex;
}

.list-container,
.input-container,
.form-container {
  background-color: var(--color-white);
  border: 1px solid var(--color-border);
  position: relative;
  overflow: visible;
  z-index: 1;
}

.list-container {
  flex: 1;
  border-left: 1px solid var(--color-border);
  border-right: 1px solid var(--color-border);
}

.input-container {
  padding: var(--space-8) var(--space-4);
  border-bottom: none;
}

/* Center button when input-container contains only a button (polls page) */
.input-container:has(.btn-new-poll) {
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Fallback for browsers that don't support :has() */
#pollsListContent .input-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: var(--space-3);
}

/* Account offer under the new-poll button (only when PAYMENT_REQUIRED is on) */
.plan-line {
  font-size: var(--font-size-sm);
  color: var(--color-gray-900);
  text-align: center;
}

.plan-line a {
  color: inherit;
}

/* Ensure drop-area takes full width in files page */
.input-container .drop-area {
  width: 100%;
}

.form-container {
  padding: var(--space-6) var(--space-4);
  flex: 1;
}

.list-item {
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-border);
  position: relative;
}

.list-item:last-child {
  border-bottom: none;
}

.list-item-meta,
.time-option {
  color: var(--color-gray-850);
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-1);
}

.time-option {
  margin-top: var(--space-2);
  margin-bottom: 0;
}

/* Vote table header: lowercase weekday, then day and month on one line */
.date-day {
  text-transform: lowercase;
}

.date-line {
  white-space: nowrap;
}

.list-item-content {
  white-space: pre-wrap;
  overflow-wrap: break-word;
  padding-right: 60px;
}

.list-item-info {
  color: var(--color-black);
  font-size: var(--font-size-sm);
  padding-right: 60px;
  margin-top: var(--space-1);
}

.poll-title-link {
  font-size: var(--font-size-md);
  color: var(--color-black);
  text-decoration: none;
}

.poll-title-link:hover {
  color: var(--color-gray-950);
  text-decoration: underline;
}

.poll-title-link:visited {
  color: var(--color-black);
}

.list-item-url {
  color: var(--color-blue);
  font-size: var(--font-size-sm);
  margin-top: var(--space-1);
  word-break: break-all;
  padding-right: 60px;
}

/* Shown once on the list after creating a poll: the link to send */
.share-banner {
  background-color: var(--color-gray-100);
}

.share-banner-text {
  font-size: var(--font-size-md);
  margin-bottom: var(--space-3);
}

.share-banner-row {
  display: flex;
  gap: var(--space-2);
}

.share-banner-url {
  flex: 1;
  min-width: 0;
  background-color: var(--color-white);
  font-size: var(--font-size-base);
}

.share-banner-copy {
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .share-banner-row {
    flex-direction: column;
  }
}

/* Form elements */
.textarea-note {
  width: 100%;
  height: 110px;
  margin-bottom: var(--space-4);
  border: none;
  outline: none;
  resize: none;
  font-size: var(--font-size-md);
  font-family: inherit;
  background-color: transparent;
}

.btn-save {
  position: absolute;
  right: var(--space-4);
  bottom: var(--space-4);
}

.form-container h2 {
  font-size: var(--font-size-lg);
  line-height: var(--line-height-snug);
  margin-bottom: var(--space-6);
  color: var(--color-black);
}

.form-group {
  margin-bottom: var(--space-6);
}

.form-group label {
  display: block;
  margin-bottom: var(--space-2);
  color: var(--color-gray-850);
  font-size: var(--font-size-sm);
}

.form-group label.checkbox-label {
  color: var(--color-black);
  font-size: var(--font-size-base);
}

.form-input,
.login-input,
.date-option input[type="date"],
.date-option .date-input,
.date-option input[type="time"],
.date-option .time-input {
  height: var(--control-height);
  padding: 0 var(--space-3);
  border: 1px solid var(--color-gray-600);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-md);
  font-family: inherit;
}

.form-input,
.login-input {
  width: 100%;
}

.form-input:focus,
.login-input:focus,
.date-option .date-input:focus,
.date-option .time-input:focus,
.date-option input[type="date"]:focus,
.date-option input[type="time"]:focus {
  outline: none;
  border-color: var(--color-black);
}

.login-input {
  margin-bottom: var(--space-4);
}

/* Date options */
.date-options {
  margin-bottom: var(--space-4);
}

.date-option {
  display: flex;
  gap: var(--space-1);
  margin-bottom: var(--space-2);
  align-items: center;
}

.date-option .inputs-group {
  display: flex;
  gap: var(--space-1);
  align-items: center;
}

.date-option input[type="date"],
.date-option .date-input {
  width: 140px;
}

.date-option input[type="time"],
.date-option .time-input {
  width: 120px;
}

/* Logged out on /new: email and consent for the light account (Lot 4) */
.form-hint {
  margin: var(--space-2) 0 var(--space-4);
  color: var(--color-gray-900);
  font-size: var(--font-size-sm);
}

.form-group label.guest-consent {
  display: flex;
  gap: var(--space-2);
  align-items: baseline;
  font-size: var(--font-size-sm);
}

.guest-consent a {
  color: inherit;
}

/* Lot 5b: answer emails checkbox on the new and edit forms, its hint right under it */
.form-group label.notify-owner {
  display: flex;
  gap: var(--space-1);
  align-items: baseline;
  margin-bottom: 0;
}

.form-group .notify-hint {
  margin: var(--space-1) 0 0;
}

/* Honeypot field: off screen, out of the tab order */
.hp-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.form-actions {
  display: flex;
  gap: var(--space-4);
  align-items: center;
  margin-top: var(--space-8);
  justify-content: flex-end;
}

/* Drop area for files */
.drop-area {
  height: 150px;
  margin: 0;
  border: 2px dashed var(--color-gray-700);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
  transition: background-color var(--transition-medium);
}

.drop-area p {
  margin-bottom: var(--space-4);
  margin-top: 0;
}

.drop-area.highlight {
  background-color: var(--color-gray-300);
}

.file-input {
  display: none;
}

.upload-progress {
  margin-top: var(--space-2);
  font-size: var(--font-size-base);
  color: var(--color-gray-900);
  position: absolute;
  bottom: var(--space-2);
  left: 0;
  right: 0;
  text-align: center;
  height: var(--space-6);
}

/* Action buttons */
.action-buttons {
  display: flex;
  gap: var(--space-2);
}

.list-item .action-buttons {
  position: absolute;
  top: var(--space-2);
  right: var(--space-4);
}

.participant-actions-cell {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  width: var(--size-btn-icon);
  height: var(--size-btn-icon);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--transition-fast);
}

/* Common hover background for neutral buttons */
.btn-icon:hover,
.btn-copy:hover,
.btn-download:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.btn-icon.btn-edit {
  color: var(--color-gray-800);
}

.btn-icon.btn-edit:hover {
  color: var(--color-black);
}

/* Common delete button styles */
.btn-delete,
.btn-icon.btn-delete-confirm,
.date-option .btn-remove {
  color: var(--color-red);
}

.btn-delete:hover,
.btn-icon.btn-delete-confirm:hover,
.date-option .btn-remove:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.btn-delete:hover .icon-delete,
.btn-icon.btn-delete-confirm:hover .icon-delete,
.date-option .btn-remove:hover .icon-delete {
  filter: brightness(0) saturate(100%) invert(21%) sepia(100%) saturate(3582%) hue-rotate(348deg) brightness(88%) contrast(93%);
}

.btn-view {
  color: var(--color-blue);
}

.btn-view:hover {
  color: var(--color-blue-dark);
  background-color: rgba(0, 102, 204, 0.1);
}

.btn-edit {
  color: var(--color-gray-900);
}

.btn-edit:hover {
  color: var(--color-gray-950);
  background-color: rgba(102, 102, 102, 0.1);
}


.btn-copy,
.btn-download {
  color: var(--color-gray-800);
}

.btn-copy:hover,
.btn-download:hover {
  color: var(--color-black);
}

.date-option .btn-remove,
.date-option .btn-duplicate {
  background: none;
  border: none;
  cursor: pointer;
  width: var(--size-btn-icon);
  height: var(--size-btn-icon);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
}


.date-option .btn-duplicate {
  color: var(--color-gray-900);
}

.date-option .btn-duplicate:hover {
  background-color: rgba(102, 102, 102, 0.1);
}

/* Icons */
.icon {
  width: var(--size-icon);
  height: var(--size-icon);
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  pointer-events: none;
}

.icon-view {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='currentColor'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M15 12a3 3 0 11-6 0 3 3 0 016 0z' /%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z' /%3E%3C/svg%3E");
}

.icon-edit {
  background-image: url("assets/svg/edit.svg");
}

.icon-delete,
.date-option .btn-remove .icon-delete {
  background-image: url("assets/svg/trash.svg");
}

.icon-check {
  background-image: url("assets/svg/check.svg");
}

.icon-copy,
.icon-duplicate {
  background-image: url("assets/svg/copy.svg");
}

.icon-download {
  background-image: url("assets/svg/download.svg");
}

/* Lot 6a: duplication and export on /admin; dimmed for a free account (full offer) */
.icon-duplicate-poll {
  background-image: url("assets/svg/duplicate-poll.svg");
}

.icon-export {
  background-image: url("assets/svg/export.svg");
}

.btn-icon.is-locked .icon {
  opacity: 0.35;
}

.poll-export {
  text-align: center;
  font-size: var(--font-size-sm);
  margin-top: var(--space-4);
}

.poll-export a {
  color: var(--color-gray-900);
}

/* Lot 5c: on the vote page, the zone the times are shown in when it is not the organizer's */
.timezone-note {
  max-width: 480px;
  margin: 0 auto var(--space-4);
  text-align: center;
  font-size: var(--font-size-sm);
  color: var(--color-gray-850);
}

/* Lot 5c: the zone of the times on the new and edit forms, small, under the times checkbox */
.form-group label.timezone-label {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: baseline;
  margin-bottom: 0;
}

.timezone-select {
  max-width: 100%;
  padding: 2px var(--space-1);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: transparent;
  font-size: var(--font-size-sm);
}

.form-group .timezone-hint {
  margin: var(--space-1) 0 0;
}

/* Lot 5a: the organizer is told what the pencil does on other people's answers */
.poll-owner-hint {
  max-width: 480px;
  margin: var(--space-4) auto 0;
  text-align: center;
  font-size: var(--font-size-sm);
  color: var(--color-gray-850);
}

.full-offer-tag {
  display: inline-block;
  margin-left: var(--space-1);
  padding: 0 6px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: 0.85em;
  text-decoration: none;
}

/* Status messages */
.message {
  padding: var(--space-4);
}

.message-loading {
  color: var(--color-black);
}

.message-error {
  color: var(--color-red-dark);
}

/* Copy button needs relative positioning to contain the message */
.btn-copy {
  position: relative;
}

.message-copy {
  position: absolute;
  top: 50%;
  right: 100%;
  transform: translateY(-50%) translateX(-8px);
  color: var(--color-black);
  font-size: var(--font-size-sm);
  opacity: 0;
  transition: all var(--transition-fast);
  pointer-events: none;
  white-space: nowrap;
}

.message-copy.visible {
  opacity: 1;
  transform: translateY(-50%) translateX(-8px);
}

/* Login overlay */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--color-gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.login-container {
  background-color: var(--color-white);
  padding: var(--space-8);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  width: 90%;
  max-width: 350px;
  position: relative;
  padding-bottom: var(--space-12);
}

.login-title {
  margin-bottom: var(--space-6);
  text-align: center;
  font-size: var(--font-size-lg);
  line-height: var(--line-height-snug);
}

/* Language switch in the top right corner of the box (login and account pages) */
.login-lang {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
}

.remember-me-container {
  display: flex;
  align-items: center;
  margin-bottom: var(--space-4);
}

.remember-me-container input[type="checkbox"] {
  margin-right: var(--space-2);
  cursor: pointer;
  width: var(--size-icon-sm);
  height: var(--size-icon-sm);
  position: relative;
  top: -1px;
}

.remember-me-container label {
  font-size: var(--font-size-base);
  color: var(--color-gray-900);
  cursor: pointer;
}

.pay-text {
  margin-bottom: var(--space-2);
}

.pay-features {
  margin: 0 0 var(--space-4);
  padding-left: var(--space-6);
  text-align: left;
  font-size: var(--font-size-sm);
  line-height: 1.5;
  color: var(--color-gray-900);
}

.pay-consent {
  align-items: flex-start;
  text-align: left;
}

.pay-consent input[type="checkbox"] {
  flex-shrink: 0;
  top: 2px;
}

.pay-consent label {
  font-size: var(--font-size-sm);
  line-height: 1.4;
}

.btn-login {
  display: block;
  width: fit-content;
  margin: 0 auto;
}

.login-text {
  margin-bottom: var(--space-4);
  font-size: var(--font-size-base);
  color: var(--color-gray-900);
}

a.btn-login {
  text-decoration: none;
}

.btn-login.btn-danger,
.btn-login.btn-danger:hover {
  background: var(--color-red-border);
  border-color: var(--color-red-border);
}

.login-links {
  padding-top: var(--space-3);
  text-align: center;
  font-size: var(--font-size-base);
}

.login-links a {
  color: var(--color-gray-900);
}

.login-error {
  color: var(--color-red-dark);
  font-size: var(--font-size-base);
  text-align: center;
  position: absolute;
  bottom: var(--space-4);
  left: 0;
  right: 0;
  padding: 0 var(--space-8);
  transition: opacity var(--transition-medium);
  opacity: 0;
  height: var(--space-6);
}

.login-error.visible {
  opacity: 1;
}

/* Footer */
/* Language switcher (FR / EN pill), same look on admin and guest pages */
.lang-switch {
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-3);
  font-size: var(--font-size-base);
  line-height: var(--line-height-tight);
}

.lang-switch a {
  padding: var(--space-1) 0;
  color: var(--color-gray-900);
  text-decoration: none;
}

.lang-switch a:hover {
  color: var(--color-black);
  text-decoration: underline;
}

.lang-switch a.active {
  color: var(--color-black);
  font-weight: var(--font-weight-bold);
  pointer-events: none;
}

.lang-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-2) 0;
}

.lang-bar-brand {
  color: inherit;
  text-decoration: none;
}

.lang-bar + .poll-title-container {
  margin-top: var(--space-2);
}

.footer {
  padding: var(--space-20) var(--space-4) var(--space-4);
  margin-top: auto;
  text-align: center;
  font-size: var(--font-size-base);
  color: var(--color-gray-900);
  background-color: var(--color-white);
}

.footer-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-4);
}

.footer-links a {
  color: inherit;
}

/* Logged-in pages footer (footer.php), same layout as the home page footer:
   account on the left, legal links on the right, brand line below */
.footer-admin {
  padding: 0 var(--space-4) 28px;
  text-align: left;
}

/* Gap above the rule; the footer keeps margin-top: auto to sit at the bottom */
.footer-admin::before {
  content: '';
  display: block;
  height: var(--space-12);
  margin: 0 calc(-1 * var(--space-4)) 20px;
  border-bottom: 1px solid var(--color-border);
}

.footer-admin nav {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 20px;
}

.footer-admin nav > div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
}

.footer-admin a {
  color: inherit;
  white-space: nowrap;
}

.footer-brand {
  margin-top: var(--space-3);
}

/* Participant counter styles */
.participant-counter {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--font-size-sm);
  color: var(--color-gray-700);
  margin-top: var(--space-2);
  justify-content: center;
}

.user-icon {
  width: var(--size-icon-sm);
  height: var(--size-icon-sm);
}

/* Highlight winning options */
.participant-counter.highest-votes {
  color: black;
}

/* Voting table wrapper for shadow positioning */
.voting-table-wrapper {
  position: relative;
  margin: var(--space-2);
}

/* Voting table styles */
.voting-table-container {
  overflow-x: auto;
  overflow-y: visible;
  background-color: var(--color-white);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  position: relative;
  contain: layout;
}

/* Allow tooltips to overflow when hovering table buttons */
.voting-table-container:has([data-original-title]:hover) {
  overflow-y: visible;
  contain: layout;
}

/* Fallback for browsers without :has() support */
.voting-table-container {
  overflow-x: auto;
  overflow-y: visible;
}

/* Force visibility for tooltip containers during hover */
.edit-actions:hover,
.participant-name:hover {
  z-index: 999999999;
}

.voting-table {
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed !important;
  width: auto !important;
  min-width: auto !important;
}

.voting-table th,
.voting-table td {
  border-left: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-2) var(--space-1);
  text-align: center;
  vertical-align: middle;
  width: 60px !important;
  min-width: 60px !important;
  max-width: 60px !important;
  box-sizing: border-box !important;
}

/* Date columns keep a fixed width, whatever the number of dates */
.voting-table th:not(.participant-name),
.voting-table td:not(.participant-name) {
  width: var(--date-col-min) !important;
  min-width: var(--date-col-min) !important;
  max-width: var(--date-col-min) !important;
  flex: none !important;
}

.voting-table-wrapper {
  --date-col-min: 60px;
  --name-col: 140px;
  --name-w: var(--name-col);
  --scroll-shadow-color: rgba(0, 0, 0, 0.32);
}

.voting-table tr {
  border-right: 1px solid var(--color-border);
}

.voting-table th:last-child,
.voting-table td:last-child {
  border-right: 1px solid var(--color-border);
}

.voting-table th:first-child:not(.participant-name),
.voting-table td:first-child:not(.participant-name) {
  border-left: none;
}

.voting-table th.participant-name + th,
.voting-table td.participant-name + td {
  border-left: none;
}


.voting-table thead tr:first-child th {
  border-top: none;
}

.voting-table th {
  background-color: rgb(249, 250, 251);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-snug);
  padding-top: var(--space-3);
  padding-bottom: var(--space-3);
}

.voting-table th.participant-name,
.voting-table td.participant-name {
  position: sticky !important;
  left: 0 !important;
  z-index: 11;
  border-left: none;
  border-right: 1px solid var(--color-border);
  width: var(--name-w) !important;
  min-width: var(--name-w) !important;
  max-width: var(--name-w) !important;
  height: 56px;
  background-color: var(--color-white) !important;
  background-clip: padding-box;
}



/* Scroll shadow effect */
.scroll-shadow {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--name-w); /* Width of participant-name column */
  width: 16px;
  background: linear-gradient(to right, var(--scroll-shadow-color), transparent);
  pointer-events: none;
  z-index: 12;
  opacity: 0;
  transition: opacity 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.scroll-shadow.visible {
  opacity: 1;
}

/* Right edge: the left shadow mirrored, shown while date columns remain off screen */
.scroll-shadow-right {
  left: auto;
  right: 0;
  background: linear-gradient(to left, var(--scroll-shadow-color), transparent);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}


.voting-table td {
  font-size: var(--font-size-base);
  background-color: var(--color-white);
}

.voting-table td:not(.participant-name):not(.participant-actions) {
  background-color: rgb(249, 250, 251);
}

.voting-table tbody tr:last-child td {
  border-bottom: none;
}

.voting-table .participant-name {
  text-align: left;
  background-color: var(--color-white);
  padding: 0;
  border-left: none;
  overflow: hidden;
  width: var(--name-w) !important;
  min-width: var(--name-w) !important;
  max-width: var(--name-w) !important;
  word-wrap: break-word;
  vertical-align: top;
}

.participant-row {
  position: relative;
  height: 56px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.participant-meta {
  color: var(--color-gray-850);
  font-size: var(--font-size-sm);
  line-height: var(--line-height-snug);
  padding-left: var(--space-2);
}

/* Name fades out under the pencil instead of an ellipsis */
.participant-content {
  overflow: hidden;
  white-space: nowrap;
  padding: 0 30px 0 var(--space-2);
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 42px), transparent calc(100% - 30px));
  mask-image: linear-gradient(to right, #000 calc(100% - 42px), transparent calc(100% - 30px));
}

/* Pencil: centred vertically, right of the name (same on desktop and mobile) */
.edit-actions {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  display: flex;
  gap: var(--space-1);
}

/* Row being edited: a red bin takes the pencil's place (the name stays editable by tapping it) */
.edit-actions .btn-delete-confirm .icon-delete {
  opacity: 1;
  filter: brightness(0) saturate(100%) invert(21%) sepia(100%) saturate(3582%) hue-rotate(348deg) brightness(88%) contrast(93%);
}

.participant-name-text {
  font-size: var(--font-size-base);
}

.participant-rename {
  cursor: pointer;
}

/* Row being edited: a "Rename" link in place of the date, above the name */
.participant-meta .participant-rename-link {
  padding: 2px 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--color-black);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.vote-cell {
  position: relative;
  transition: background-color var(--transition-fast);
  padding: var(--space-2);
  /* Désactive les effets de sélection sur mobile */
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.vote-cell.edit-mode {
  cursor: pointer;
}

.vote-icon {
  width: var(--size-icon-lg);
  height: var(--size-icon-lg);
  display: block;
  margin: 0 auto;
}

.size-5 {
  width: 1.25rem;
  height: 1.25rem;
}

/* Vote marks: 22px SVG icons centered in a 32px box; only "yes" gets a round halo */
.vote-halo-yes,
.vote-halo-no,
.vote-halo-unknown {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin: 0 auto;
  border-radius: var(--radius-full);
}

.vote-halo-yes .vote-icon,
.vote-halo-no .vote-icon,
.vote-halo-unknown .vote-icon {
  width: 22px;
  height: 22px;
}

.vote-halo-yes {
  background-color: #e0f8e7;
}


.vote-cell.selected {
  background-color: var(--color-white) !important;
}

/* Bounce on the icon that just changed (class added by poll-vote-standalone.js) */
.vote-pop {
  animation: vote-pop 0.34s cubic-bezier(0.3, 0.7, 0.4, 1);
}

@keyframes vote-pop {
  0% { transform: scale(0.5); opacity: 0.3; }
  45% { transform: scale(1.25); opacity: 1; }
  72% { transform: scale(0.92); }
  100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .vote-pop {
    animation: none;
  }
}


/* Row being edited: the other rows fade out, its own vote cells turn white */
body.is-editing .voting-table tbody tr:not(.is-edit-row) td > * {
  opacity: 0.15;
}

.voting-table tr.is-edit-row td.vote-cell {
  background-color: var(--color-white) !important;
}

.is-edit-row .participant-meta {
  color: var(--color-black);
}

/* Tap a name to see it in full, in a bubble under it */
.participant-name-text {
  cursor: pointer;
}

.name-bubble {
  position: fixed;
  z-index: 1000;
  max-width: calc(100vw - 16px);
  padding: var(--space-2) var(--space-3);
  background-color: var(--color-white);
  color: var(--color-black);
  font-size: var(--font-size-base);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow-wrap: anywhere;
  pointer-events: none;
  animation: name-bubble-in 0.12s ease-out;
}

/* Arrow: a white square turned 45deg, bordered on its two outer sides */
.name-bubble::before {
  content: "";
  position: absolute;
  top: -5px;
  left: 14px;
  width: 8px;
  height: 8px;
  background-color: var(--color-white);
  border-top: 1px solid var(--color-border);
  border-left: 1px solid var(--color-border);
  transform: rotate(45deg);
}

@keyframes name-bubble-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}

/* Poll layouts */
.poll-title-container {
  text-align: center;
  margin: var(--space-8) var(--space-6) var(--space-2);
  position: relative;
}

.back-to-list-link {
  position: absolute;
  top: var(--space-6);
  left: var(--space-6);
  color: var(--color-gray-900);
  text-decoration: none;
  font-size: var(--font-size-sm);
  opacity: 0.7;
}

.back-to-list-link:hover {
  opacity: 1;
  text-decoration: underline;
}

.poll-title {
  font-size: var(--font-size-xl);
  line-height: var(--line-height-snug);
  color: var(--color-black);
  margin: 0;
}

.add-participant-container {
  margin: var(--space-2) var(--space-6);
  text-align: center;
}

/* Desktop: table centered on the page, buttons centered under it, kept in view while the table runs past the screen */
@media (min-width: 601px) {
  .voting-table-wrapper {
    width: fit-content;
    max-width: calc(100% - 2 * var(--space-2));
    margin-left: auto;
    margin-right: auto;
  }

  .add-participant-container {
    position: sticky;
    bottom: var(--space-6);
    z-index: 100;
    display: flex;
    justify-content: center;
    gap: var(--space-3);
    margin: 0 var(--space-2) var(--space-6);
  }

  body.is-editing .add-participant-container #addParticipantButton {
    display: none;
  }

  /* Edit mode: "Annuler" and "Enregistrer" share the width of the widest one */
  body.is-editing .add-participant-container {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
  }

  body.is-editing .add-participant-container .save-button,
  body.is-editing .add-participant-container .cancel-button {
    display: block;
  }
}

.add-participant-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background-color: var(--color-gray-100);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-gray-900);
  font-size: var(--font-size-base);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.add-participant-btn:hover {
  background-color: var(--color-gray-300);
  border-color: var(--color-gray-700);
  min-width: 200px;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  /* The same dimming beyond the backdrop: dialog.js fits it to the visible viewport on iOS,
     which leaves the page under Safari's toolbar and above the keyboard uncovered otherwise */
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

/* On phones, the dialog sits at the top from the start: centered, it jumps up when the keyboard opens */
@media (max-width: 600px) {
  .modal {
    align-items: flex-start;
    padding-top: var(--space-8);
  }
}

.modal-content {
  background-color: var(--color-white);
  padding: var(--space-8);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  width: 90%;
  max-width: 400px;
  text-align: center;
}

.modal-content h3 {
  margin-bottom: var(--space-4);
  font-size: var(--font-size-lg);
  line-height: var(--line-height-snug);
}

.modal-content p {
  margin-bottom: var(--space-6);
  color: var(--color-gray-900);
}

.name-input {
  width: 100%;
}

/* Beats .modal-content p */
.modal-content .name-error {
  min-height: 1.4em;
  margin: var(--space-2) 0 var(--space-4);
  font-size: var(--font-size-sm);
  color: var(--color-red-border);
}

.modal-actions {
  display: flex;
  gap: var(--space-4);
  justify-content: center;
}

/* Lot 5b: checkbox under a dialog's field (dialog.js check option) */
.modal-content .dialog-check {
  display: flex;
  gap: var(--space-2);
  align-items: baseline;
  justify-content: center;
  margin-bottom: var(--space-6);
  color: var(--color-gray-900);
  font-size: var(--font-size-sm);
  text-align: left;
  cursor: pointer;
}

.modal-content .form-input + .dialog-check {
  margin-top: var(--space-4);
}

/* Dialogs with a title only, or a field without an error line (assets/js/dialog.js) */
.modal-content h3 + .modal-actions,
.modal-content .form-input + .modal-actions {
  margin-top: var(--space-6);
}

/* Custom tooltips - disable native and use CSS */
/* Tooltips using data-original-title */
[data-original-title] {
  position: relative;
}

[data-original-title]:hover::before {
  content: attr(data-original-title);
  position: absolute;
  bottom: calc(100% + var(--space-2));
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--color-black);
  color: var(--color-white);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  line-height: var(--line-height-tight);
  white-space: nowrap;
  z-index: 999999;
  pointer-events: none;
}

/* Tooltip for edit buttons positioned to the left with higher specificity */
.voting-table .edit-actions [data-original-title]:hover::before {
  bottom: calc(100% + 2px);
  right: 0; /* Flush with the cell's right border, like the pencil button */
  left: auto;
  transform: none;
}

/* Let the pencil tooltip rise above the 56px name cell (the name is clipped by .participant-content) */
.voting-table td.participant-name:hover {
  overflow: visible;
}

/* Ensure table cells don't clip tooltips */
.voting-table td,
.voting-table th {
  overflow: visible;
}

.voting-table {
  overflow: visible;
}

#initialLoader {
  z-index: -1 !important;
}

.input-container,
.list-container {
  isolation: isolate;
}

/* Disable tooltips on mobile devices */
@media (hover: none) and (pointer: coarse) {
  /* Disable custom CSS tooltips */
  [data-original-title]:hover::before,
  .voting-table .edit-actions [data-original-title]:hover::before {
    display: none !important;
  }

  /* Disable any remaining native tooltips */
  [title] {
    pointer-events: auto !important;
  }

  /* Ensure no tooltip-like pseudo-elements appear */
  *:hover::before,
  *:hover::after {
    display: none !important;
  }
}

/* Bottom buttons: no border; "Supprimer" text turns red on hover */
.add-participant-container button {
  border: none;
}

.add-participant-container .cancel-button {
  background-color: var(--color-gray-500);
}

.add-participant-container .cancel-button:hover {
  background-color: var(--color-gray-600);
}


/* Bottom save/cancel buttons: hidden until a row is being edited */
.add-participant-container .save-button,
.add-participant-container .cancel-button {
  display: none;
}

/* Test: denser voting table on mobile (inspired by "Alternative à Doodle" 8a) */
@media (max-width: 600px) {
  /* Side margins aligned with the action button below */
  .voting-table-wrapper {
    margin: var(--space-2) var(--space-4);
  }

  .lang-bar {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }

  /* Table centered when narrower than the screen, its rounded frame fitted to it; full width and scrolling otherwise */
  .voting-table-container {
    width: fit-content;
    max-width: 100%;
    margin: 0 auto;
  }

  /* The frame draws the right edge */
  .voting-table th:last-child,
  .voting-table td:last-child {
    border-right: none;
  }

  .voting-table th,
  .voting-table td {
    padding-left: 0;
    padding-right: 0;
  }

  .voting-table-wrapper {
    --name-col: 124px;
  }

  /* Vote cells (colors from the "Alternative à Doodle" mockup) */
  .vote-cell {
    padding: 0;
  }

  /* Action buttons stick to the bottom of the screen, then rest above the footer */
  .add-participant-container {
    order: 1;
    position: sticky;
    bottom: 0;
    z-index: 100;
    margin: 0;
    padding: var(--space-3) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom));
    background: linear-gradient(to top, var(--color-white) 70%, rgba(255, 255, 255, 0));
  }

  .add-participant-container button {
    width: 100%;
    height: var(--control-height-lg);
    border-radius: var(--radius-full);
    font-size: var(--font-size-md);
  }

  body.is-editing .add-participant-container #addParticipantButton {
    display: none;
  }

  /* Edit mode: "Supprimer" and "Enregistrer" side by side, same width */
  body.is-editing .add-participant-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
  }

  body.is-editing .add-participant-container .save-button,
  body.is-editing .add-participant-container .cancel-button {
    display: block;
    min-width: 0;
  }

  .container .footer {
    order: 2;
    margin-top: 0;
    padding-top: 0;
  }

  .container .footer-admin {
    padding-bottom: calc(var(--space-6) + env(safe-area-inset-bottom));
  }

  .footer-admin::before {
    height: var(--space-8);
    margin-bottom: var(--space-3);
  }

  .footer-admin nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 var(--space-6);
    align-items: start;
  }

  .footer-admin nav > div {
    display: block;
  }

  .footer-admin nav a,
  .footer-account > span {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    column-gap: 0.3em;
    min-height: 40px;
  }

  .footer-account a {
    color: var(--color-black);
  }

  .footer-brand {
    padding-top: var(--space-4);
    border-top: 1px solid var(--color-border);
  }

  /* Guest vote page footer (footer-public.php): one line, links tall enough to tap */
  .footer-minimal {
    padding-bottom: calc(var(--space-2) + env(safe-area-inset-bottom));
  }

  .footer-minimal .footer-links {
    row-gap: 0;
  }

  .footer-minimal .footer-links > * {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
  }

  .voting-table-wrapper {
    margin-bottom: auto;
  }
}
