@import url("https://fonts.googleapis.com/css2?family=Nunito:wght@400;700;800&display=swap");

:root {
  --primary-color: #4d2d7b;
  --secondary-color: #25b34b;
  --light-color: #f2edf7;
  --white-color: #ffffff;
  --text-color: #333;
  --highlight-color: #25b34b;
}

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

body {
  font-family: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  background-color: var(--light-color);
  color: var(--text-color);
  overflow: hidden;
}

.grid-container {
  display: grid;
  grid-template-columns: 2fr 1fr;
  grid-template-rows: auto 1fr auto;
  grid-template-areas: "header header" "main sidebar" "footer footer";
  height: 100vh;
  width: 100vw;
}

.header,
.tv-area,
.sidebar,
.footer {
  transition: filter 0.5s ease;
}

.header {
  grid-area: header;
  background-color: var(--white-color);
  padding: 8px 20px;
  display: flex;
  justify-content: space-between; /* Alinha o logo e o usuário */
  align-items: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  z-index: 10;
}
.logo {
  height: 40px;
  width: auto;
}

/* Header User Info */
.header-user {
  display: flex;
  align-items: center;
  gap: 15px;
}

#user-name {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-color);
  display: flex;
  align-items: center;
  line-height: 1; /* Adicionado para um alinhamento mais preciso */
}

.btn-logout {
  background-color: var(--secondary-color);
  color: var(--white-color);
  border: none;
  padding: 8px 15px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
  font-family: "Nunito", sans-serif;
  transition: background-color 0.3s ease;
}

.btn-logout:hover {
  background-color: #1e8e3a;
}

/* Hamburger Menu */
.hamburger-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 24px;
  z-index: 1001;
  color: var(--primary-color);
  display: flex;
  align-items: center;
}

.hamburger-btn .close-icon {
  display: none;
}

.side-menu {
  position: fixed;
  top: 0;
  right: -280px; /* Start off-screen */
  width: 250px;
  height: 100%;
  background-color: var(--white-color);
  box-shadow: -2px 0 5px rgba(0, 0, 0, 0.1);
  padding: 20px;
  transition: right 0.3s ease-in-out;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.side-menu.open {
  right: 0; /* Slide in */
}

.side-menu .btn-logout {
  width: 100%;
}

/* Configuração de Logo no Menu */
.menu-section {
  border-bottom: 1px solid #e0e0e0;
  padding-bottom: 15px;
}

.menu-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary-color);
  margin: 0 0 10px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.logo-selector {
  width: 100%;
  padding: 10px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background-color: white;
  cursor: pointer;
  transition: all 0.3s ease;
}

.logo-selector:hover {
  border-color: var(--primary-color);
}

.logo-selector:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.4);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
  z-index: 999;
}

.menu-overlay.open {
  opacity: 1;
  visibility: visible;
}

.tv-area {
  grid-area: main;
  padding: 20px;
  display: flex;
  overflow: hidden; /* Evita que o vídeo quebre o layout */
}

.video-placeholder {
  width: 100%;
  height: 100%;
  max-height: 100%; /* Limita altura ao container */
  background-color: transparent;
  color: white;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 12px;
  overflow: hidden; /* Evita overflow do vídeo */
}

#tv-player {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain; /* Mantém proporção do vídeo sem cortar */
  border-radius: 12px;
  display: block;
  margin: auto; /* Centraliza o vídeo */
}

.sidebar {
  grid-area: sidebar;
  background-color: var(--white-color);
  padding: 10px 20px 20px;
  border-left: 1px solid #eee;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#password-list {
  list-style: none;
  padding: 0;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  gap: 15px;
}

#password-list li {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 1rem;
  border-radius: 12px;
  background-color: var(--light-color);
  font-weight: 800;
  transition: all 0.3s ease;
  flex-grow: 1;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.history-senha {
  font-size: clamp(1.5rem, 5vw, 2.5rem);
  display: flex;
  justify-content: center;
  align-items: center;
  flex-grow: 1;
  width: 100%;
  text-align: center;
}
.history-local {
  font-size: clamp(1.2rem, 4.5vw, 2.2rem);
  opacity: 0.8;
}

#password-list li.latest {
  background-color: var(--highlight-color);
  color: var(--white-color);
  flex-grow: 1.5;
  box-shadow: 0 8px 20px rgba(37, 179, 75, 0.3);
  gap: 10px;
}

.latest .latest-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.latest .latest-label {
  font-size: clamp(0.8rem, 2vw, 1.2rem);
  font-weight: 700;
  opacity: 0.9;
}
.latest .latest-value {
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
}
.latest .latest-value.password {
  font-size: clamp(3rem, 9vw, 5rem);
}
.latest .latest-value.patient {
  font-size: clamp(2.5rem, 7vw, 4.5rem);
}
.latest .latest-value.location {
  font-size: clamp(2.5rem, 7vw, 4.5rem);
}


.footer {
  grid-area: footer;
  background-color: var(--primary-color);
  padding: 10px 20px; /* Aumentando um pouco o padding para a quebra de linha */
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px 30px;
  flex-wrap: wrap; /* Permite que os itens quebrem para a próxima linha */
}

.footer-label {
  color: var(--white-color);
  font-size: 1.6em;
  font-weight: 700;
  white-space: nowrap;
}
.footer-boxes-container {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
}
.footer-box {
  background-color: var(--white-color);
  color: var(--primary-color);
  border-radius: 8px;
  padding: 8px 35px;
  font-weight: 800;
  text-align: center;
  display: flex;
  flex-direction: column;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}
.footer-box .senha {
  font-size: 2.2em;
  flex-grow: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.footer-box .guiche {
  font-size: 1.8em; /* Aumentado */
  opacity: 0.8;
}

.flash-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(77, 45, 123, 0.95);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  color: var(--white-color);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
  padding: 1rem;
}
.flash-overlay.visible {
  opacity: 1;
  pointer-events: all;
}
.flash-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1vh;
}
.flash-content .flash-label {
  font-size: clamp(1.5rem, 4vh, 3rem);
  opacity: 0.8;
}
.flash-content .flash-value {
  font-weight: 800;
  line-height: 1.1;
}
.flash-content .flash-value.password {
  font-size: clamp(5rem, 22vh, 18rem);
  color: var(--highlight-color);
}
.flash-content .flash-value.patient {
  font-size: clamp(5rem, 15vh, 12rem);
  color: var(--highlight-color);
}
.flash-content .flash-value.location {
  font-size: clamp(4rem, 10vh, 9rem);
}

.latest-call-count {
  font-size: clamp(1rem, 2.5vw, 1.5rem);
  font-weight: 700;
  background-color: rgba(255, 255, 255, 0.2);
  padding: 5px 15px;
  border-radius: 20px;
  margin-top: 10px;
}

.flash-call-count {
  font-size: clamp(1.5rem, 4vh, 3rem);
  font-weight: 700;
  background-color: var(--highlight-color);
  padding: 10px 30px;
  border-radius: 50px;
  margin-top: 2vh;
  border: 2px solid var(--white-color);
}

/* Estilos da Tela de Login */
.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background-color: var(--light-color);
  padding: 20px;
  overflow: auto; /* Garante que o conteúdo seja rolável se a tela for pequena */
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-header .logo-image {
  max-width: 150px;
  margin-bottom: 1rem;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.login-header h1 {
  font-size: 2rem;
  color: var(--primary-color);
  margin-bottom: 0.5rem;
}

.login-header p {
  font-size: 1.1rem;
  color: var(--text-color);
}

#loginForm {
  width: 100%;
  max-width: 400px;
  padding: 2rem;
  background-color: var(--white-color);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 700;
  color: var(--text-color);
}

.form-group input {
  width: 100%;
  padding: 0.8rem 1rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 1rem;
  font-family: "Nunito", sans-serif;
  transition: border-color 0.3s ease;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(77, 45, 123, 0.2);
}

.btn-login {
  width: 100%;
  padding: 1rem;
  background-color: var(--secondary-color);
  color: var(--white-color);
  border: none;
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px; /* Altura mínima para o botão */
}

.btn-login:hover {
  background-color: #1e8e3a; /* Tom de verde mais escuro para o hover */
}

.btn-login:disabled {
  background-color: #ccc;
  cursor: not-allowed;
}

.error-message {
  background-color: #ffdddd;
  color: #d8000c;
  padding: 0.8rem;
  border-radius: 8px;
  text-align: center;
  margin-bottom: 1rem;
  display: none; /* Oculto por padrão */
}

/* Estilo do Loader */
.loader {
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: var(--white-color);
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* --- Estilos da Página de Admin --- */

body.admin-body {
  overflow-y: auto; /* Permite rolagem vertical na página de admin */
}

.admin-container {
  padding: 2rem;
  max-width: 1200px;
  margin: 2rem auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

.admin-card {
  background-color: var(--white-color);
  border-radius: 12px;
  padding: 2rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.admin-card h2 {
  font-size: 1.5rem;
  color: var(--primary-color);
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--light-color);
  padding-bottom: 0.5rem;
}

.header-title {
  flex-grow: 1;
  text-align: center;
  color: var(--primary-color);
}

.btn-nav {
  background-color: transparent;
  color: var(--primary-color);
  border: 2px solid var(--primary-color);
  padding: 8px 15px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
  font-family: 'Nunito', sans-serif;
  text-decoration: none;
  transition: all 0.3s ease;
  display: block; /* Para fazer o width: 100% funcionar */
  width: 100%;
  text-align: center;
}

.btn-nav:hover {
  background-color: var(--primary-color);
  color: var(--white-color);
}
.form-control-file {
  width: 100%;
  padding: 0.8rem 1rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 1rem;
  font-family: 'Nunito', sans-serif;
  transition: border-color 0.3s ease;
}

.form-control-file:focus {
  outline: none;
  border-color: var(--primary-color);
}

#video-list-container {
  max-height: 400px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: relative; /* Adicionado para posicionamento correto do overlay */
}

.video-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background-color: var(--light-color);
  border-radius: 8px;
}

.video-info {
  font-weight: 700;
  flex-grow: 1; /* Permite que o info ocupe o espaço restante */
  margin-left: 1rem; /* Espaçamento entre o botão e o info */
}

.video-info .region {
  font-weight: 400;
  color: #666;
  font-size: 0.9rem;
  margin-left: 10px;
}

.btn-delete {
  background-color: #d8000c;
  color: var(--white-color);
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.9rem;
  font-family: 'Nunito', sans-serif;
  transition: background-color 0.3s ease;
}

.btn-delete:hover {
  background-color: #a00009;
}

@media (max-width: 900px) {
  .admin-container {
    grid-template-columns: 1fr;
  }
}

/* --- Estilos do Rodapé do Menu Lateral --- */

.menu-footer {
  margin-top: auto; /* Empurra o rodapé para o final do menu */
  padding-top: 15px;
  border-top: 1px solid #e0e0e0;
  text-align: center;
}

#version-display {
  font-size: 0.8rem;
  color: #888;
  font-weight: 600;
}

/* --- Estilos do Modal de Pré-visualização e Notificação/Confirmação --- */
.modal {
    display: flex; /* Usa flex para centralização por padrão */
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.7); /* Fundo um pouco menos escuro */
    align-items: center;
    justify-content: center;
    
    /* Animação */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0s 0.3s;
}

.modal.modal-visible {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease;
}

.modal-content {
    background-color: var(--white-color);
    margin: auto;
    padding: 2rem;
    border-radius: 12px;
    position: relative;
    max-width: 90%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 5px 25px rgba(0,0,0,0.2);
    
    /* Animação */
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal.modal-visible .modal-content {
    transform: scale(1);
}

/* Conteúdo específico para o modal de vídeo */
.modal-content video {
    width: 100%;
    height: auto;
    max-height: 80vh;
    display: block;
    border-radius: 8px;
}

/* Estilos para os novos modais de notificação e confirmação */
#notification-modal-title, #confirmation-modal-title {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

#notification-modal-message, #confirmation-modal-message {
    font-size: 1rem;
    color: #555;
    line-height: 1.6;
    margin-top: 0.5rem;
    margin-bottom: 1.5rem;
}

/* Reutilizando classes de botões existentes para consistência */
#notification-modal-close-btn {
    min-width: 80px;
}

#confirmation-modal-confirm-btn {
    background-color: #d8000c; /* Vermelho para ações destrutivas */
}
#confirmation-modal-confirm-btn:hover {
    background-color: #a00009;
}


.close-button {
    color: var(--white-color); /* Change color for better visibility against dark overlay */
    position: absolute;
    top: 15px; 
    right: 25px; 
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    z-index: 1002;
    text-shadow: 0 0 5px rgba(0,0,0,0.7);
}

.close-button:hover,
.close-button:focus {
    color: #eee; /* Lighter on hover */
    text-decoration: none;
    cursor: pointer;
}

.video-preview-action {
    /* Estilos se você precisar de um container para o botão */
}

.btn-preview {
    background-color: var(--primary-color);
    color: var(--white-color);
    border: none;
    padding: 8px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 700;
    font-family: 'Nunito', sans-serif;
    transition: background-color 0.3s ease;
    white-space: nowrap; /* Evita que o texto do botão quebre */
}

.btn-preview:hover {
    background-color: #3b225e; /* Um tom mais escuro */
}

/* --- Estilos para Toast Notifications --- */
#top-toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000; /* Acima de tudo */
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-end;
}

.toast {
    background-color: #333;
    color: var(--white-color);
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transform: translateY(100%);
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.23, 1, 0.32, 1);
    min-width: 280px;
    max-width: 400px;
    font-size: 1rem;
    text-align: center;
}

.toast.from-top {
    transform: translateY(-150%);
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-success {
    background-color: var(--secondary-color);
}

.toast-error {
    background-color: #d8000c;
}

.toast-info {
    background-color: var(--primary-color);
}
