/* ====
   1. RESET BÁSICO E CONFIGURAÇÕES GLOBAIS
   ==== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

html {
    font-size: 16px;
}
body {
    font-family: 'Poppins', sans-serif;
    background-color: #1a1a2e;
    color: #e0e0e0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    line-height: 1.6;
    margin: 0;
    padding: 0;
}

/* ====
   ALERTA DE BANCO INDISPONÍVEL
   ==== */
.banco-indisponivel-alert {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    border: 2px solid #c44569;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 8px 25px rgba(255, 107, 107, 0.3);
    animation: pulse 2s infinite;
    display: flex;
    align-items: center;
    gap: 1rem;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.alert-icon {
    font-size: 2.5rem;
    color: #fff;
    background: rgba(255, 255, 255, 0.2);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.alert-content h3 {
    color: #fff;
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.alert-content p {
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 0.8rem;
    line-height: 1.5;
}

.suporte-info {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 0.8rem;
    margin-top: 0.8rem;
}

.suporte-info p {
    margin: 0.3rem 0;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.95);
}

.suporte-info strong {
    color: #fff;
}

.retry-section {
    margin-top: 1rem;
    text-align: center;
}

.retry-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.retry-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 255, 255, 0.2);
}

.retry-section small {
    display: block;
    margin-top: 0.5rem;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.8rem;
}

/* ====
   2. ESTILOS DO CABEÇALHO (HEADER) - VERSÃO ROBUSTA COM CSS GRID
   ==== */
.main-header {
    background-color: #10101a;
    padding: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    z-index: 1000;
}
.header-content {
    display: grid;
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    gap: 1rem;
    grid-template-areas:
    "logo nav"
    "search search";
    grid-template-columns: auto 1fr;
    align-items: center;
}
.header-logo {
    grid-area: logo;
    display: flex;
    align-items: center;
    text-decoration: none;
    color: #ffff;
    font-weight: 600;
    font-size: 1.1rem;
}
.header-logo img {
    height: 35px;
    margin-right: 0.5rem;
}
.header-logo span {
    display: none;
}
.search-form {
    grid-area: search;
    display: flex;
    width: 100%;
}
.main-nav {
    grid-area: nav;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
}
.main-nav a {
    color: #c0c0c0;
    text-decoration: none;
    font-weight: 500;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.25rem;
    min-width: 50px;
    text-align: center;
}
.main-nav a > i {
    font-size: 1.2rem;
    margin-bottom: 2px;
}
.main-nav a > span {
    font-size: 0.6rem;
    font-weight: 400;
}
.main-nav a.logout-btn .logout-text {
    display: none;
}
.main-nav a.logout-btn i {
    font-size: 1.4rem;
}
.search-form input {
    flex-grow: 1;
    background-color: #16213e;
    border: 1px solid #0f3460;
    color: #ffff;
    padding: 8px 12px;
    border-radius: 5px 0 0 5px;
    outline: none;
    font-size: 0.9rem;
}
.search-form button {
    background-color: #0077cc;
    border: 1px solid #0077cc;
    color: #ffff;
    padding: 8px 12px;
    border-radius: 0 5px 5px 0;
    cursor: pointer;
}

/* Layout Desktop */
@media (min-width: 768px) {
    .header-content {
    grid-template-areas: "logo search nav";
    grid-template-columns: auto 1fr auto;
    height: 75px;
    }
    .header-logo span {
    display: inline;
    }
    .search-form {
    max-width: 350px;
    justify-self: center;
    }
}
@media (min-width: 992px) {
    .header-content {
    height: 90px;
    }
    .header-logo {
    font-size: 1.2rem;
    }
    .header-logo img {
    height: 45px;
    }
    .main-nav {
    gap: 1rem;
    }
    .main-nav a {
    padding: 10px 15px;
    }
    .main-nav a > i {
    font-size: 1.8rem;
    }
    .main-nav a > span {
    font-size: 0.8rem;
    }
    .main-nav a.logout-btn .logout-text {
    display: inline;
    }
}

/* ====
   3. PÁGINA DE LOGIN (Estilos Específicos - V2)
   ==== */

/* Container principal da tela de login */
body.login-page-v2 {
    min-height: 100vh;
    padding: 2rem 1rem;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    background-attachment: fixed;
    background-size: cover;
    position: relative;
    overflow-y: auto;
    z-index: 1;
}

/* Classe adicionada quando clica em unidade */
body.login-page-v2.unidade-selecionada {
    padding-top: 5rem; /* Desce um pouco para mostrar o logo */
}

.login-container {
    width: 100%;
    max-width: 960px; /* Tamanho normal para 2 colunas */
    background: rgba(16, 16, 26, 0.6);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: visible;
    margin: 2rem auto; /* Espaço no topo, centralizado horizontalmente */
    position: relative;
    z-index: 1000;
    transition: max-width 0.3s ease; /* Transição suave ao expandir */
}

@media (min-width: 992px) {
    .login-container {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        max-width: 960px;
        align-items: stretch;
    }
    
    /* Quando não tem painel de detalhes: 50/50 */
    .login-branding-panel,
    .login-form-panel {
        flex: 1 1 50% !important;
        min-width: 300px;
        max-width: 50%;
    }
    
    /* Layout com painel de detalhes visível - expande container para 3 colunas */
    .login-container.tres-colunas {
        max-width: 1200px;
    }
    
    .login-container.tres-colunas .login-branding-panel,
    .login-container.tres-colunas .login-detalhes-panel,
    .login-container.tres-colunas .login-form-panel {
        flex: 1 1 33.333% !important;
        min-width: 250px;
        max-width: 33.333%;
    }
    
    .login-detalhes-panel.show {
        display: flex;
    }
}

/* Painel da Esquerda (Branding/Unidades) */
.login-branding-panel {
    padding: 2.5rem;
    text-align: center;
    display: flex;
    flex-direction: column;
}

.login-logo-img {
    max-width: 100px;
    height: auto;
    margin-bottom: 1rem;
    margin-left: auto;
    margin-right: auto;
    display: block;
    flex-shrink: 0; /* Não deixa o logo encolher */
}

.welcome-title {
    font-size: 1.8rem;
    font-weight: 600;
    color: #ffff;
}

.welcome-subtitle {
    font-size: 1rem;
    color: #c0c0c0;
    margin-bottom: 2rem;
}

.unidades-title {
    font-size: 1rem;
    font-weight: 500;
    color: #e0e0e0;
    margin-bottom: 1rem;
    border-top: 1px solid #16213e;
    padding-top: 1.5rem;
}

/* ====
   3.1 GRID DE UNIDADES COM SCROLL AJUSTADO PARA 3 COLUNAS E SEM SOBREPOSIÇÃO
   ==== */
.unidades-panel {
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
}

.unidades-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important; /* 2 colunas */
    grid-template-rows: auto !important;
    gap: 1rem;
    padding: 10px;
    margin-bottom: 1rem;
    box-sizing: border-box;
}


/* Itens individuais das unidades - estilo original */
.unidade-item {
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid #16213e;
    border-radius: 8px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100px;
    width: 100%;
    box-sizing: border-box;
}

.unidade-item:hover {
    background-color: #16213e;
    border-color: #00aaff;
}

.unidade-item.active {
    background-color: #0077cc;
    border-color: #00aaff;
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 170, 255, 0.3);
}

.unidade-item img {
    height: 35px;
    margin-bottom: 0.5rem;
}

.unidade-item span {
    font-size: 0.8rem;
    font-weight: 500;
    color: #e0e0e0;
}

/* Painel do Meio (Detalhes da Unidade) */
.login-detalhes-panel {
    display: none; /* Oculto por padrão */
    padding: 2.5rem 1.5rem;
    background-color: rgba(0, 0, 0, 0.1);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.login-detalhes-panel.show {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

/* Header da unidade no painel do meio */
.unidade-header {
    display: none; /* Oculto por padrão */
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.unidade-header-logo {
    max-width: 80px;
    height: auto;
    margin-bottom: 0.5rem;
}

.unidade-header-nome {
    font-size: 1.3rem;
    font-weight: 600;
    color: #ffff;
    margin: 0;
}

/* Painel da Direita (Formulário) */
.login-form-panel {
    background-color: rgba(0, 0, 0, 0.2);
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Alinha no topo */
    padding-top: 4rem; /* Espaço no topo para alinhar com o logo */
}

.login-box h2 {
    font-size: 1.5rem;
    text-align: center;
    margin-bottom: 2rem;
    color: #ffff;
}

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

.login-form-panel .form-group label {
    font-weight: 500;
}

.btn-login-main {
    width: 100%;
    margin-top: 1.5rem;
    padding: 0.9rem;
    background-color: #0077cc;
    border: 1px solid #0077cc;
    color: #ffff;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.btn-login-main:hover {
    background-color: #005fa3;
}

/* Ajuste responsivo para ordem dos painéis na tela de login (mobile) */
@media (max-width: 991px) {
    .login-container {
      display: flex !important;
      flex-direction: column !important;
    }
    .login-form-panel {
      order: 0 !important;
      width: 100% !important;
      margin-bottom: 0 !important;
    }
    .login-branding-panel {
      order: 1 !important;
      width: 100% !important;
    }
    
    /* Painel de detalhes no mobile aparece entre branding e form */
    .login-detalhes-panel {
      order: 2 !important;
      width: 100% !important;
      padding: 1.5rem !important;
      border-left: none !important;
      border-right: none !important;
      border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
      border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
      max-height: none !important;
    }
    
    /* Mobile mantém grid original */
    .unidades-grid {
      grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)) !important;
      max-height: none !important;
    }
    
    .unidade-item {
      padding: 1rem !important;
      font-size: 0.85rem !important;
    }
    
    .unidade-item img {
      width: 30px !important;
      height: 30px !important;
    }
  }

/* ====
   4. ESTILOS PARA A ÁREA DE DETALHES DA UNIDADE (ALINHAMENTO À ESQUERDA)
   ==== */
.unidade-info {
    text-align: left;
    margin-top: 1.5rem;
    color: #e0e0e0;
}

.unidade-info-item {
    display: flex;
    align-items: flex-start;
    margin-bottom: 0.8rem;
}

.unidade-info-item i {
    margin-right: 10px;
    color: #00aaff;
    font-size: 1.1rem;
    padding-top: 3px;
}

.unidade-info-item span {
    flex-grow: 1;
    line-height: 1.4;
    word-break: break-word;
    overflow-wrap: break-word;
}

/* Link do WhatsApp no painel de detalhes */
.whatsapp-link {
    color: #25D366;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
}

.whatsapp-link:hover {
    color: #128C7E;
    text-decoration: underline;
}

.whatsapp-link::before {
    content: "\f232";
    font-family: "Font Awesome 6 Brands";
    margin-right: 6px;
    font-size: 0.9em;
}

.unidade-mapa {
    margin-top: 1.5rem;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #16213e;
}

/* Bloco MH2 no login */
.login-mh2-container {
  margin-bottom: 1.5rem;
  text-align: center;
}

.login-mh2-text {
  font-size: 1rem;
  color: #c0c0c0;
  margin-bottom: 0.5rem;
}

.login-mh2-logo {
  height: 60px;
  display: inline-block;
}

/* ====
   BOTÕES DE AÇÃO DO LOGIN
   ==== */
.login-extra-actions {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.btn-action-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.8rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #4a90e2;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    cursor: pointer;
}

.btn-action-link:hover {
    background: rgba(74, 144, 226, 0.1);
    border-color: #4a90e2;
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.2);
}

.btn-action-link i {
    font-size: 1rem;
    width: 16px;
    text-align: center;
}

/* Layout responsivo unificado - sem template mobile separado */
@media (max-width: 992px) {
    body.login-page-v2,
    body.login-page-v2.unidade-selecionada {
        padding-top: 1rem;
        padding-bottom: 1rem;
        align-items: flex-start; /* Alinha no topo em mobile */
        overflow-y: auto;
        height: auto;
        min-height: 100vh;
    }
    
    .login-container {
        display: flex !important;
        flex-direction: column !important;
        max-width: 500px;
        margin: 0 auto;
        width: 100%;
        padding: 1rem;
        height: auto;
    }
    
    .login-branding-panel {
        order: 1 !important;
        width: 100% !important;
        padding: 1.5rem !important;
        margin-bottom: 1rem;
        max-height: none; /* Remove limite de altura em mobile */
        overflow-y: visible;
    }
    
    .login-detalhes-panel {
        order: 2 !important;
        width: 100% !important;
        padding: 1.5rem !important;
        border-left: none !important;
        border-right: none !important;
        border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
        max-height: none;
    }
    
    .login-form-panel {
        order: 0 !important;
        width: 100% !important;
        padding: 1.5rem !important;
    }
    
    .login-header-mobile {
        display: block !important;
        text-align: center;
        margin-bottom: 1.5rem;
    }
    
    .login-header-mobile .login-logo-img {
        display: block;
        margin: 0 auto 1rem auto;
        max-width: 80px;
        height: auto;
    }
    
    .login-branding-panel .welcome-title,
    .login-branding-panel .welcome-subtitle,
    .login-branding-panel .login-logo-img {
        display: none !important;
    }
    
    .unidades-panel {
        margin-top: 1rem !important;
        margin-bottom: 1rem !important;
    }
    
    .unidades-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) !important;
        gap: 1rem !important;
    }
    
    .unidade-item {
        padding: 1rem !important;
        font-size: 0.9rem !important;
    }
    
    .unidade-item img {
        width: 35px !important;
        height: 35px !important;
    }
}

@media (max-width: 768px) {
    .login-container {
        padding: 0.5rem;
    }
    
    .login-form-panel,
    .login-branding-panel,
    .login-detalhes-panel {
        padding: 1rem !important;
    }
    
    .login-box h2 {
        font-size: 1.5rem;
    }
    
    .form-group {
        margin-bottom: 1rem;
    }
    
    .btn-login-main {
        padding: 0.8rem 1.5rem;
        font-size: 1rem;
    }
    
    .btn-action-link {
        padding: 0.6rem 0.8rem;
        font-size: 0.85rem;
    }
    
    .unidades-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)) !important;
        gap: 0.8rem !important;
    }
    
    .unidade-item {
        padding: 0.8rem !important;
        font-size: 0.85rem !important;
    }
    
    .unidade-item img {
        width: 30px !important;
        height: 30px !important;
    }
}

@media (max-width: 480px) {
    .login-container {
        padding: 0;
    }
    
    .login-form-panel,
    .login-branding-panel,
    .login-detalhes-panel {
        padding: 0.8rem !important;
    }
    
    .login-box {
        padding: 1rem;
    }
    
    .login-box h2 {
        font-size: 1.3rem;
    }
    
    .form-control {
        padding: 0.8rem;
        font-size: 0.9rem;
    }
    
    .btn-login-main {
        padding: 0.7rem 1.2rem;
        font-size: 0.9rem;
    }
    
    .btn-action-link {
        padding: 0.5rem 0.7rem;
        font-size: 0.8rem;
    }
    
    .unidades-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.6rem !important;
    }
    
    .unidade-item {
        padding: 0.6rem !important;
        font-size: 0.8rem !important;
        text-align: center;
    }
    
    .unidade-item img {
        width: 25px !important;
        height: 25px !important;
        margin-bottom: 0.3rem;
    }
}

/* ===
   ESTILOS MOBILE ANTIGOS - REMOVIDOS
   ==== */
.login-header-mobile { 
    display: none; 
}

/* === ESTILOS PARA DETALHES DA UNIDADE === */
.unidade-detalhes-area {
  margin-top: 1rem;
  padding: 1.2rem;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border: 1px solid #dee2e6;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  display: none;
  animation: fadeInUp 0.3s ease-out;
  position: relative;
  z-index: 10;
}

.unidade-detalhes-area.show {
  display: block;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.unidade-info h4 {
  color: #2c3e50;
  margin: 0 0 1rem 0;
  font-size: 1.1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.unidade-info-item {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  margin-bottom: 0.8rem;
  font-size: 0.95rem;
  color: #495057;
}

.unidade-info-item i {
  color: #007bff;
  width: 16px;
  margin-top: 2px;
  flex-shrink: 0;
}

.unidade-info-item span {
  line-height: 1.4;
}

.unidade-mapa {
  margin-top: 1rem;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.unidade-mapa iframe {
  width: 100%;
  height: 200px;
  border: none;
  display: block;
}

/* === RESPONSIVIDADE PARA DETALHES DA UNIDADE === */
@media (max-width: 768px) {
  .unidade-detalhes-area {
    padding: 1rem;
    margin-top: 0.5rem;
    margin-bottom: 1rem;
  }
  
  .unidade-info h4 {
    font-size: 1rem;
  }
  
  .unidade-info-item {
    font-size: 0.9rem;
    gap: 0.6rem;
  }
  
  .unidade-mapa iframe {
    height: 160px;
  }
}

@media (max-width: 480px) {
  .unidade-detalhes-area {
    padding: 0.8rem;
    margin-top: 0.3rem;
    margin-bottom: 0.8rem;
  }
  
  .unidade-mapa iframe {
    height: 140px;
  }
}