/* adminpanel.css - Mobile First Refactor */

/* --- RESET & VARS --- */
:root {
  --roxo: #4A148C;
  --roxo-claro: #7c43bd;
  --roxo-bg: #f5f1fa;
  --roxo-borda: #e3d0f3;
  --branco: #ffffff;
  --texto: #30135c;
  --cinza: #666;
  --cinza-claro: #f1f1f1;
  --erro: #d32f2f;
  --sucesso: #2e7d32;
}

body, html {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--roxo-bg);
  color: var(--texto);
  height: 100%;
  overflow: hidden; /* Previne scroll no body */
}

* {
  box-sizing: border-box;
}

/* --- ESTRUTURA PRINCIPAL (MOBILE) --- */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding-bottom: 60px; /* Espaço para a barra de navegação inferior */
}

.view {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

.app-header {
  background: var(--branco);
  padding: 0.8rem 1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  position: relative; /* Contexto para posicionamento dos filhos */
}

.app-header h1 {
  margin: 0;
  font-size: 1.2rem;
  color: var(--roxo);
  text-align: center;
  flex-grow: 1;
}

.detail-header {
    gap: 1rem; /* Espaço entre os itens */
}

.detail-header h2 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--roxo);
    text-align: center;
    flex-grow: 1;
    /* Evita que o nome quebre ou empurre os botões */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-logout {
  background: none;
  border: 1px solid #ccc;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  flex-shrink: 0; /* Impede que o botão encolha */
}

.btn-back {
  background: none;
  border: none;
  font-size: 1.5rem;
  font-weight: bold;
  cursor: pointer;
  color: var(--roxo);
  padding: 0;
  line-height: 1;
  flex-shrink: 0; /* Impede que o botão encolha */
}


.search-container {
  padding: 1rem;
  background-color: var(--branco);
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
}

#search-user {
  width: 100%;
  padding: 0.8rem;
  font-size: 1rem;
  border-radius: 8px;
  border: 1px solid #ccc;
}

.add-client-container-desktop {
    display: none; /* Oculto no mobile por padrão */
}

.user-list-container {
  flex-grow: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

.user-card {
  background: var(--branco);
  padding: 1rem;
  margin-bottom: 0.5rem;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  cursor: pointer;
  transition: background-color 0.2s, box-shadow 0.2s;
  border-left: 4px solid transparent;
}

.user-card:hover {
  background-color: #f8f5fd;
}

.user-card.selected {
  background-color: #f0eaff;
  border-left-color: var(--roxo);
  box-shadow: 0 2px 8px rgba(74, 20, 140, 0.1);
}

.user-card h3 {
  margin: 0 0 0.25rem 0;
  font-size: 1.1rem;
}

.user-card p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--cinza);
  word-break: break-all;
}

.client-detail-container {
  flex-grow: 1;
  overflow-y: auto;
  padding: 1rem;
}

.list-placeholder {
    text-align: center;
    padding: 2rem;
    color: var(--cinza);
}

/* --- NAVEGAÇÃO INFERIOR (MOBILE) --- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  height: 60px;
  background: var(--branco);
  box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
  z-index: 20;
}

.nav-button {
  flex: 1;
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--cinza);
  cursor: pointer;
  font-size: 0.8rem;
  transition: color 0.2s;
}

.nav-button.active {
  color: var(--roxo);
  font-weight: bold;
}

/* --- ACCORDION (DETALHES DO CLIENTE) --- */
.accordion-item {
  background: var(--branco);
  border-radius: 8px;
  margin-bottom: 1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  overflow: hidden;
  border: 1px solid #eee;
}

.accordion-header {
  padding: 1rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: bold;
  font-size: 1.1rem;
  background: #fdfcff;
}

.accordion-header::after {
  content: '▼';
  transition: transform 0.2s;
  font-size: 0.8rem;
}

.accordion-item.active .accordion-header::after {
  transform: rotate(180deg);
}

.accordion-content {
  padding: 1rem;
  display: none;
  animation: fadeIn 0.3s;
  border-top: 1px solid #eee;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.accordion-item.active .accordion-content {
  display: block;
}

/* --- ESTILOS DE FORMULÁRIOS E TABELAS --- */
.form-group, .profile-form-grid .form-group {
  margin-bottom: 1rem;
}

.profile-form-grid {
    display: grid;
    gap: 0 1.5rem;
}
@media (min-width: 600px) {
    .profile-form-grid {
        grid-template-columns: 1fr 1fr;
    }
}

label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}
input[type="text"], input[type="email"], input[type="date"], input[type="number"], select, textarea {
  width: 100%;
  padding: 0.8rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 1rem;
  background: #fff;
}
textarea {
  resize: vertical;
}
.checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.checkbox input {
  width: auto;
}

/* --- RESPONSIVE TABLE WRAPPER --- */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch; /* Melhora a rolagem em iOS */
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 500px; /* Força a rolagem em telas menores */
}
th, td {
  padding: 0.8rem;
  text-align: left;
  border-bottom: 1px solid #eee;
  font-size: 0.9rem;
  white-space: nowrap; /* Impede a quebra de linha nas células */
}
th {
  background-color: var(--cinza-claro);
  font-weight: bold;
}
.badge {
  padding: 0.2em 0.6em;
  border-radius: 1em;
  font-size: 0.8em;
  font-weight: 600;
  color: #fff;
}
.badge-pendente { background: #FFC107; color: #533e00; }
.badge-confirmado { background: #43A047; }
.badge-cancelado { background: #D32F2F; }

/* --- MODAIS --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}
.modal-content {
  background: var(--branco);
  padding: 1.5rem;
  border-radius: 12px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-content h2.modal-title {
  margin-top: 0;
  color: var(--roxo);
}
.modal-actions {
  margin-top: 1.5rem;
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}
.modal-feedback {
  margin-top: 1rem;
  font-size: 0.9rem;
}

#existing-profile-results {
    border: 1px solid #ccc;
    border-radius: 4px;
    max-height: 150px;
    overflow-y: auto;
}
.profile-result-item {
    padding: 0.5rem;
    cursor: pointer;
}
.profile-result-item:hover {
    background-color: var(--roxo-bg);
}

/* --- BOTÕES --- */
.btn-primary, .btn-secondary {
  padding: 0.7rem 1.5rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-weight: 500;
}
.btn-primary {
  background: var(--roxo);
  color: var(--branco);
}
.btn-secondary {
  background: #eee;
  color: #333;
}
.btn-trip-details {
  background: var(--roxo-claro);
  color: white;
  padding: 0.4rem 0.8rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}

/* --- ESTILOS DO MODAL DE VIAGEM --- */
#modal-trip .modal-content {
    max-width: 700px;
    max-height: 95vh;
}
.form-row {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1rem;
}
.form-row > .form-group {
    flex: 1;
    margin-bottom: 0;
}
.date-range-inputs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.date-range-inputs input { flex: 1; }
#trip-total-value[readonly] {
    background: #f3f3f3;
    color: #666;
    border-style: dashed;
}

.trip-items-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #eee;
}
.trip-items-section h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}
.items-table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; }
.items-table th, .items-table td { padding: 0.6rem; font-size: 0.9rem; }
.items-table th { background-color: var(--cinza-claro); font-weight: bold; text-align: left; }
.items-table td { border-bottom: 1px solid #eee; }
.no-items-placeholder { color: var(--cinza); padding: 1rem; text-align: center; background-color: #f9f9f9; border-radius: 6px;}
.btn-delete-item { background: #fff1f0; color: var(--erro); border: 1px solid #ffccc7; padding: 0.2rem 0.6rem; border-radius: 4px; cursor: pointer;}

#add-item-form-container { background: #f9f9f9; padding: 1rem; border-radius: 8px; margin-top: 1rem; }
#add-item-form-inner { display: grid; grid-template-columns: 1fr 2fr 1fr auto; gap: 1rem; align-items: end; }
#add-item-form-inner .form-actions { display: flex; gap: 0.5rem; }


/* --- LAYOUT DESKTOP --- */
@media (min-width: 800px) {
  .app-container {
    display: flex;
    flex-direction: row;
    height: 100vh;
    padding-bottom: 0;
  }

  #list-view {
    flex: 0 0 350px;
    border-right: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  
  #list-view .app-header {
    position: static;
  }
  
  #list-view .search-container {
    position: static;
  }

  .add-client-container-desktop {
    display: block;
    padding: 0 1rem 1rem 1rem;
    background-color: var(--branco);
    border-bottom: 1px solid #eee;
  }

  #btn-add-client-desktop {
    width: 100%;
    padding: 0.8rem;
  }


  #detail-view {
    flex: 1 1 auto;
    display: flex !important; /* Força a exibição no desktop */
    flex-direction: column;
  }
  
  .detail-header {
      display: none; /* Esconde header de detalhe no desktop */
  }

  .bottom-nav {
    display: none;
  }
  
  .app-header .btn-back {
      display: none;
  }
  
  #list-view .app-header h1 {
    text-align: left;
  }

  .client-detail-container {
    flex-grow: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    align-items: center; /* Centraliza o conteúdo (accordion ou placeholder) */
    justify-content: center;
  }
  
  .client-detail-container > .list-placeholder {
      font-size: 1.2rem;
      color: #aaa;
  }

  .accordion {
    width: 100%;
    max-width: 900px;
  }
}

/* --- RESPONSIVIDADE ADICIONAL --- */
@media (max-width: 700px) {
    .form-row {
        flex-direction: column;
        gap: 1rem;
    }
    #add-item-form-inner {
        grid-template-columns: 1fr;
    }
}