* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* input/textarea precisam de selecao normal para o usuario digitar/editar texto */
input,
textarea {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

html, body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #061428;
}

body {
  background-image: linear-gradient(rgba(6, 20, 40, 0.28), rgba(6, 20, 40, 0.46)), url("/img/fundo.jpg");
  background-size: cover;
  background-position: center;
  color: #f2f6fb;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

.app {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 2.2vh 2.4vw;
  gap: 1.8vh;
}

/* Header */
.app-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.4vh 2vw;
  background: rgba(10, 28, 52, 0.38);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  backdrop-filter: blur(10px);
}

.room-label {
  font-size: clamp(22px, 3.4vw, 42px);
  font-weight: 700;
  letter-spacing: 0.5px;
}

.clock-group {
  display: flex;
  align-items: center;
  gap: 0.8vw;
}

.country-flag {
  display: flex;
  align-items: center;
  /* Fallback de texto (ex: quando o SVG da bandeira nao existe para o codigo). */
  font-size: clamp(16px, 1.8vw, 22px);
  font-weight: 700;
  opacity: 0.85;
  line-height: 1;
}

.country-flag-img {
  display: block;
  width: clamp(28px, 3.2vw, 40px);
  height: auto;
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18);
  /* NUNCA aplicar transform/scaleY/rotate aqui — os SVGs em public/img/flags/
     ja vem na orientacao correta; espelhar isso quebraria qualquer bandeira. */
}

.clock {
  font-size: clamp(18px, 2.4vw, 30px);
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
}

/* Error banner */
.error-banner {
  flex: 0 0 auto;
  background: rgba(234, 179, 8, 0.16);
  border: 1px solid rgba(234, 179, 8, 0.55);
  color: #ffe9a8;
  padding: 1vh 1.6vw;
  border-radius: 12px;
  font-size: clamp(13px, 1.4vw, 17px);
  text-align: center;
}

/* Main grid */
.main-grid {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 38% 62%;
  gap: 1.8vw;
}

/* Status panel */
.status-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 2vh;
  padding: 2.4vh 2vw;
  background: rgba(10, 28, 52, 0.38);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 22px;
  backdrop-filter: blur(10px);
}

.status-badge {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1vw;
  padding: 3vh 1vw;
  border-radius: 18px;
  font-weight: 800;
  transition: background-color 0.4s ease;
}

.status-badge.livre {
  background: rgba(34, 197, 94, 0.22);
  border: 2px solid #22c55e;
  color: #baf5cd;
}

.status-badge.ocupada {
  background: rgba(239, 68, 68, 0.22);
  border: 2px solid #ef4444;
  color: #ffc9c9;
}

.status-badge.indisponivel {
  background: rgba(148, 163, 184, 0.18);
  border: 2px solid #94a3b8;
  color: #e2e8f0;
}

.status-dot {
  width: clamp(16px, 1.8vw, 22px);
  height: clamp(16px, 1.8vw, 22px);
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 14px currentColor;
}

.status-text {
  font-size: clamp(24px, 3.6vw, 44px);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.current-meeting {
  flex: 0 0 auto;
  padding: 1.4vh 1.2vw;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 14px;
  font-size: clamp(15px, 1.7vw, 20px);
  line-height: 1.4;
}

.current-meeting .cm-subject {
  font-weight: 700;
  display: block;
  margin-bottom: 4px;
}

.current-meeting .cm-time {
  opacity: 0.8;
  font-size: 0.85em;
}

.quick-book {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 1.2vh;
}

.quick-book-label {
  margin: 0;
  font-size: clamp(14px, 1.5vw, 18px);
  opacity: 0.75;
  font-weight: 600;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 1vh 1vw;
}

.chip {
  flex: 1 1 28%;
  padding: 1.8vh 0.6vw;
  font-size: clamp(14px, 1.6vw, 19px);
  font-weight: 700;
  color: #f2f6fb;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 14px;
  cursor: pointer;
  transition: background-color 0.12s ease, transform 0.12s ease;
}

.chip:active {
  transform: scale(0.96);
  background: rgba(255, 255, 255, 0.22);
}

.chip:disabled:active {
  transform: none;
}

.chip:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.quick-book-hint {
  margin: 0;
  font-size: clamp(12px, 1.3vw, 15px);
  opacity: 0.65;
  min-height: 1.4em;
}

.btn-other-day {
  width: 100%;
  text-align: center;
}

/* Agenda panel */
.agenda-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 2.4vh 2vw;
  background: rgba(10, 28, 52, 0.38);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 22px;
  backdrop-filter: blur(10px);
}

.agenda-title {
  flex: 0 0 auto;
  margin: 0 0 1.4vh 0;
  font-size: clamp(17px, 2vw, 24px);
  font-weight: 700;
  opacity: 0.9;
}

.agenda-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.9vh;
  padding-right: 4px;

  scrollbar-width: none;
  -ms-overflow-style: none;
}

.agenda-list::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.agenda-empty {
  opacity: 0.6;
  font-size: clamp(14px, 1.6vw, 18px);
  text-align: center;
  margin-top: 2vh;
}

.agenda-row {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 1.2vw;
  padding: 1.3vh 1.2vw;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border-left: 4px solid rgba(255, 255, 255, 0.25);
}

.agenda-row.busy {
  border-left-color: #ef4444;
}

.agenda-row.busy.past {
  opacity: 0.45;
}

.agenda-row.free {
  border-left-color: #22c55e;
  background: rgba(34, 197, 94, 0.08);
  cursor: pointer;
  transition: background-color 0.12s ease, transform 0.12s ease;
}

.agenda-row.free:active {
  background: rgba(34, 197, 94, 0.18);
  transform: scale(0.98);
}

.agenda-time {
  flex: 0 0 auto;
  width: 12vw;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: clamp(13px, 1.5vw, 18px);
  opacity: 0.9;
}

.agenda-info {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.agenda-subject {
  font-size: clamp(14px, 1.6vw, 19px);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agenda-organizer {
  font-size: clamp(11px, 1.2vw, 14px);
  opacity: 0.65;
}

.agenda-plus {
  flex: 0 0 auto;
  font-size: clamp(18px, 2vw, 24px);
  font-weight: 700;
  color: #86efac;
}

/* Empty state (no roomId) */
.empty-state {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1vh;
  background: rgba(6, 20, 40, 0.92);
  font-size: clamp(16px, 2vw, 22px);
  text-align: center;
}

.empty-state-title {
  font-size: 1.3em;
  font-weight: 700;
  margin: 0;
}

.empty-state-subtitle {
  margin: 0 0 1vh 0;
  font-size: 0.6em;
  opacity: 0.65;
}

.room-picker {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.4vh 1.4vw;
  max-width: 80vw;
}

.room-picker-hint {
  font-size: 0.7em;
  opacity: 0.65;
}

.room-picker-btn {
  padding: 2.2vh 2.4vw;
  min-width: 14vw;
  font-size: clamp(16px, 1.8vw, 22px);
  font-weight: 700;
  color: #f2f6fb;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 16px;
  cursor: pointer;
  transition: background-color 0.12s ease, transform 0.12s ease;
}

.room-picker-btn:active {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(0.96);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal {
  width: min(60vw, 560px);
  max-height: 88vh;
  overflow: hidden;
  background: #0e2440;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  padding: 2.4vh 2.2vw;
  display: flex;
  flex-direction: column;
  gap: 1.6vh;
}

.modal h3 {
  margin: 0;
  font-size: clamp(18px, 2.2vw, 26px);
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 0.6vh;
  font-size: clamp(13px, 1.4vw, 16px);
  opacity: 0.85;
}

.modal-field input {
  font-size: clamp(15px, 1.8vw, 20px);
  padding: 1.2vh 1vw;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #f2f6fb;
  /* Sem isso, o Chrome/Edge desenha o icone nativo de calendario/relogio
     assumindo tema claro, criando uma caixa mal encaixada atras do icone
     que parece um segundo icone sobreposto ao do campo escuro. */
  color-scheme: dark;
}

.modal-field input[type="date"]::-webkit-calendar-picker-indicator,
.modal-field input[type="time"]::-webkit-calendar-picker-indicator {
  filter: invert(0.9);
  cursor: pointer;
}

.modal-time-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.4vw;
}

.modal-time-row .modal-field {
  flex: 1 1 0;
  min-width: 120px;
}

.modal-error {
  margin: 0;
  color: #ffb4b4;
  font-size: clamp(12px, 1.3vw, 15px);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 1vw;
  margin-top: 0.6vh;
}

.btn {
  padding: 1.4vh 1.8vw;
  font-size: clamp(14px, 1.6vw, 18px);
  font-weight: 700;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.btn:active {
  transform: scale(0.96);
  opacity: 0.85;
}

.btn:disabled:active {
  transform: none;
  opacity: 1;
}

.btn.primary {
  background: #22c55e;
  color: #06210f;
}

.btn.secondary {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
  color: #f2f6fb;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 4vh;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #f2f6fb;
  padding: 1.6vh 2.4vw;
  border-radius: 14px;
  font-size: clamp(14px, 1.6vw, 18px);
  z-index: 60;
  max-width: 80vw;
  text-align: center;
}

.hidden {
  display: none !important;
}
