/* =====================================================
   CSS UNIVERSAL TOTALMENTE RESPONSIVO - SISTEMA BIOTÉRIO
   Compatível com TODAS as telas: 320px até 4K
   ===================================================== */

/* ===== VARIÁVEIS GLOBAIS ===== */
:root {
    --verde-principal: rgba(64, 122, 53, 0.819);
    --verde-escuro: rgba(44, 81, 36, 0.819);
    --amarelo-principal: #ffc107;
    --amarelo-escuro: #e0a800;
    --cinza-fundo: rgb(225, 225, 228);
    --cinza-texto: rgb(60, 59, 59);
    --border-radius-principal: 15px;
    --border-radius-pequeno: 8px;
    --sombra-principal: 5px 5px 50px rgba(90, 90, 90, 0.392);
    --transicao-padrao: all 0.3s ease;
}

/* ===== RESET GLOBAL ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: Georgia, 'Times New Roman', Times, serif;
    color: var(--cinza-texto);
    line-height: 1.6;
    min-height: 100vh;
    width: 100%;
    overflow-x: hidden;
    background: radial-gradient(circle, rgba(173, 199, 205, 1) 0%, rgba(169, 189, 165, 1) 31%, var(--verde-principal) 85%);
}

/* ===== CONTAINERS RESPONSIVOS ===== */
.container,
.main-container,
.content-container {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: clamp(10px, 3vw, 30px);
}

.content-container {
    max-width: 1400px;
    background-color: var(--cinza-fundo);
    border-radius: var(--border-radius-principal);
    box-shadow: var(--sombra-principal);
}

/* ===== HEADERS RESPONSIVOS ===== */
.header,
#header_inicial,
#header_secundario {
    width: 100%;
    padding: clamp(10px, 2vw, 20px) clamp(15px, 3vw, 30px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: clamp(10px, 2vw, 20px);
}

.header {
    background: linear-gradient(135deg, var(--verde-principal) 0%, var(--verde-escuro) 100%);
    color: white;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(64, 122, 53, 0.3);
}

.header.empresa {
    background: linear-gradient(135deg, var(--amarelo-principal) 0%, var(--amarelo-escuro) 100%);
    box-shadow: 0 4px 15px rgba(255, 193, 7, 0.3);
}

/* ===== TÍTULOS RESPONSIVOS ===== */
h1, h2, h3, h4, h5, h6 {
    line-height: 1.2;
    margin-bottom: clamp(10px, 2vw, 20px);
}

h1 {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    font-weight: 700;
}

h2 {
    font-size: clamp(1.3rem, 3.5vw, 2rem);
}

h3 {
    font-size: clamp(1.1rem, 3vw, 1.5rem);
}

h4 {
    font-size: clamp(1rem, 2.5vw, 1.2rem);
}

/* ===== BOTÕES RESPONSIVOS ===== */
.btn,
.btns_inicio,
button[type="submit"],
button[type="button"] {
    padding: clamp(8px, 1.5vw, 15px) clamp(15px, 3vw, 30px);
    border: none;
    border-radius: var(--border-radius-pequeno);
    font-size: clamp(0.875rem, 2vw, 1rem);
    font-family: inherit;
    cursor: pointer;
    transition: var(--transicao-padrao);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: clamp(5px, 1vw, 10px);
    text-decoration: none;
    font-weight: bold;
    white-space: nowrap;
    min-height: 44px; /* Acessibilidade mobile */
}

.btn-primary {
    background: linear-gradient(135deg, var(--verde-principal) 0%, var(--verde-escuro) 100%);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--verde-escuro) 0%, var(--verde-principal) 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(64, 122, 53, 0.3);
}

.btn-secondary {
    background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
    color: white;
}

.btn-warning {
    background: linear-gradient(135deg, #fd7e14 0%, #e56b03 100%);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
}

.btn-empresa {
    background: linear-gradient(135deg, var(--amarelo-principal) 0%, var(--amarelo-escuro) 100%);
    color: white;
}

/* ===== FORMULÁRIOS RESPONSIVOS ===== */
.form-group {
    margin-bottom: clamp(15px, 2vw, 25px);
}

label {
    display: block;
    margin-bottom: clamp(5px, 1vw, 8px);
    font-size: clamp(0.875rem, 2vw, 1rem);
    font-weight: bold;
    color: var(--cinza-texto);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="time"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: clamp(10px, 1.5vw, 15px);
    border: 2px solid #ddd;
    border-radius: var(--border-radius-pequeno);
    font-size: clamp(0.875rem, 2vw, 1rem);
    font-family: inherit;
    transition: var(--transicao-padrao);
    background-color: rgb(240, 240, 240);
    min-height: 44px; /* Acessibilidade mobile */
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--verde-principal);
    background-color: rgb(250, 250, 250);
    box-shadow: 0 0 0 3px rgba(64, 122, 53, 0.1);
}

/* ===== CARDS E GRIDS RESPONSIVOS ===== */
.appointments-grid,
.stats,
.quick-links,
.data-grid {
    display: grid;
    gap: clamp(10px, 2vw, 20px);
    margin-bottom: clamp(15px, 2vw, 30px);
}

.appointments-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
}

.stats {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr));
}

.appointment-card,
.stat-card,
.data-section {
    background: white;
    border-radius: clamp(8px, 1.5vw, 15px);
    padding: clamp(12px, 2vw, 20px);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.1);
    transition: var(--transicao-padrao);
}

.appointment-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

/* ===== CALENDÁRIO RESPONSIVO ===== */
.calendar-container {
    background: white;
    border-radius: var(--border-radius-principal);
    padding: clamp(15px, 2vw, 25px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: clamp(15px, 2vw, 25px);
    overflow-x: auto;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: clamp(2px, 0.5vw, 8px);
    min-width: 280px;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: clamp(4px, 0.8vw, 8px);
    font-size: clamp(0.75rem, 1.5vw, 1rem);
    font-weight: bold;
    cursor: pointer;
    transition: var(--transicao-padrao);
    min-height: clamp(30px, 5vw, 45px);
}

.calendar-month-year {
    font-size: clamp(1rem, 2.5vw, 1.25rem);
    font-weight: bold;
    text-align: center;
}

/* ===== HORÁRIOS RESPONSIVOS ===== */
.horarios-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 80px), 1fr));
    gap: clamp(8px, 1.5vw, 15px);
}

.horario-label {
    padding: clamp(8px, 1.5vw, 12px);
    text-align: center;
    border: 2px solid #ddd;
    border-radius: var(--border-radius-pequeno);
    font-size: clamp(0.75rem, 1.5vw, 0.875rem);
    cursor: pointer;
    transition: var(--transicao-padrao);
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== POPUPS RESPONSIVOS ===== */
.custom-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    padding: clamp(10px, 2vw, 20px);
}

.custom-popup {
    background-color: var(--cinza-fundo);
    border-radius: var(--border-radius-principal);
    padding: clamp(20px, 3vw, 30px);
    max-width: min(90%, 500px);
    width: 100%;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-height: 90vh;
    overflow-y: auto;
}

.popup-icon {
    font-size: clamp(2.5rem, 6vw, 3.5rem);
    margin-bottom: clamp(15px, 2vw, 20px);
}

.popup-title {
    font-size: clamp(1.2rem, 3vw, 1.5rem);
    margin-bottom: clamp(10px, 2vw, 15px);
}

.popup-message {
    font-size: clamp(0.875rem, 2vw, 1rem);
    margin-bottom: clamp(20px, 3vw, 25px);
    line-height: 1.5;
}

.popup-buttons {
    display: flex;
    gap: clamp(10px, 2vw, 15px);
    justify-content: center;
    flex-wrap: wrap;
}

/* ===== TABELAS RESPONSIVAS ===== */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: clamp(0.75rem, 1.5vw, 0.875rem);
}

@media (max-width: 768px) {
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}

/* ===== MEDIA QUERIES ESPECÍFICAS ===== */

/* Smartphones pequenos (320px - 480px) */
@media (max-width: 480px) {
    body {
        font-size: 14px;
    }
    
    .header {
        flex-direction: column;
        text-align: center;
        position: relative;
    }
    
    .header-left,
    .header-actions {
        width: 100%;
        justify-content: center;
    }
    
    .btn-lg {
        width: 100%;
        max-width: 280px;
    }
    
    .appointments-grid,
    .stats {
        grid-template-columns: 1fr;
    }
    
    .calendar-grid {
        gap: 1px;
    }
    
    .calendar-day {
        font-size: 0.7rem;
        min-height: 28px;
    }
    
    .horarios-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .action-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .popup-buttons {
        flex-direction: column;
        width: 100%;
    }
    
    .popup-btn {
        width: 100%;
    }
    
    /* Ajuste específico para forms */
    .tabs {
        flex-direction: column;
    }
    
    .tab {
        width: 100%;
        padding: 12px;
    }
}

/* Smartphones médios (481px - 768px) */
@media (min-width: 481px) and (max-width: 768px) {
    .appointments-grid {
        grid-template-columns: 1fr;
    }
    
    .stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .horarios-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .calendar-day {
        font-size: 0.8rem;
        min-height: 35px;
    }
}

/* Tablets (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        max-width: 95%;
    }
    
    .appointments-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stats {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .horarios-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Desktops (1025px - 1440px) */
@media (min-width: 1025px) and (max-width: 1440px) {
    .container {
        max-width: 1200px;
    }
    
    .appointments-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .stats {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Desktops grandes e 4K (1441px+) */
@media (min-width: 1441px) {
    html {
        font-size: 18px;
    }
    
    .container {
        max-width: 1400px;
    }
    
    .appointments-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .stats {
        grid-template-columns: repeat(6, 1fr);
    }
}

/* Ultra-wide e 4K (2560px+) */
@media (min-width: 2560px) {
    html {
        font-size: 20px;
    }
    
    .container {
        max-width: 2000px;
    }
    
    .appointments-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* ===== ORIENTAÇÃO LANDSCAPE PARA MOBILE ===== */
@media (max-height: 500px) and (orientation: landscape) {
    .header {
        padding: 8px 15px;
        position: relative;
    }
    
    .content-container {
        max-height: calc(100vh - 60px);
        overflow-y: auto;
    }
    
    h1 {
        font-size: 1.2rem;
    }
    
    .btn {
        padding: 6px 12px;
        min-height: 36px;
    }
}

/* ===== ACESSIBILIDADE E PERFORMANCE ===== */

/* Reduzir animações para usuários com preferência */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Modo escuro (se implementado) */
@media (prefers-color-scheme: dark) {
    /* Adicionar variáveis de cores escuras aqui se necessário */
}

/* Impressão */
@media print {
    .header,
    .btn,
    .action-buttons {
        display: none !important;
    }
    
    body {
        background: white;
        color: black;
    }
    
    .content-container {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* ===== UTILIDADES RESPONSIVAS ===== */
.text-center {
    text-align: center;
}

.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.d-none {
    display: none !important;
}

.d-block {
    display: block !important;
}

.d-flex {
    display: flex !important;
}

.flex-wrap {
    flex-wrap: wrap !important;
}

.justify-content-center {
    justify-content: center !important;
}

.align-items-center {
    align-items: center !important;
}

.gap-1 {
    gap: clamp(5px, 1vw, 10px) !important;
}

.gap-2 {
    gap: clamp(10px, 2vw, 20px) !important;
}

.gap-3 {
    gap: clamp(15px, 3vw, 30px) !important;
}

.mb-0 {
    margin-bottom: 0 !important;
}

.mb-1 {
    margin-bottom: clamp(5px, 1vw, 10px) !important;
}

.mb-2 {
    margin-bottom: clamp(10px, 2vw, 20px) !important;
}

.mb-3 {
    margin-bottom: clamp(15px, 3vw, 30px) !important;
}

.p-1 {
    padding: clamp(5px, 1vw, 10px) !important;
}

.p-2 {
    padding: clamp(10px, 2vw, 20px) !important;
}

.p-3 {
    padding: clamp(15px, 3vw, 30px) !important;
}

/* ===== SCROLL SUAVE E BARRAS PERSONALIZADAS ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--verde-principal) 0%, var(--verde-escuro) 100%);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, var(--verde-escuro) 0%, var(--verde-principal) 100%);
}

/* Para empresas */
.empresa ::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--amarelo-principal) 0%, var(--amarelo-escuro) 100%);
}

/* ===== OTIMIZAÇÕES FINAIS ===== */

/* Prevenir zoom indesejado em iOS */
@supports (-webkit-touch-callout: none) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="date"],
    input[type="time"],
    input[type="number"],
    select,
    textarea {
        font-size: 16px !important;
    }
}

/* Container responsivo com altura dinâmica */
.responsive-height {
    min-height: calc(100vh - 120px);
    max-height: calc(100vh - 60px);
}

@media (max-width: 768px) {
    .responsive-height {
        min-height: calc(100vh - 140px);
        max-height: none;
    }
}

/* ===== ANIMAÇÕES RESPONSIVAS ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(clamp(10px, 2vw, 20px));
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

/* Aplicar animações com delay reduzido em mobile */
.animate-fadeIn {
    animation: fadeIn 0.3s ease-out;
}

@media (max-width: 768px) {
    .animate-fadeIn {
        animation-duration: 0.2s;
    }
}

/* ===== FIXES ESPECÍFICOS PARA EDGE CASES ===== */

/* Fix para Safari iOS */
@supports (-webkit-appearance: none) {
    .btn {
        -webkit-appearance: none;
    }
}

/* Fix para Firefox */
@-moz-document url-prefix() {
    input[type="date"],
    input[type="time"] {
        line-height: normal;
    }
}

/* Fix para IE11 (se ainda necessário) */
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
    .flex-container {
        display: table;
        width: 100%;
    }
}