/**
 * CSS Responsivo Global
 * Garante que todas as páginas sejam visíveis e nada fique cortado
 * Funciona em telefone, tablet e desktop
 */

/* Reset e Base */
* {
    box-sizing: border-box;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    margin: 0;
    padding: 0;
    position: relative;
}

/* Viewport e Zoom Responsivo */
@media screen and (max-width: 480px) {
    html {
        font-size: 14px;
    }
    
    body {
        zoom: 0.9;
        -webkit-text-size-adjust: 90%;
    }
}

@media screen and (min-width: 481px) and (max-width: 768px) {
    html {
        font-size: 15px;
    }
    
    body {
        zoom: 0.95;
        -webkit-text-size-adjust: 95%;
    }
}

@media screen and (min-width: 769px) and (max-width: 1024px) {
    html {
        font-size: 16px;
    }
}

@media screen and (min-width: 1025px) {
    html {
        font-size: 16px;
    }
}

/* Container Responsivo */
.container,
.admin-container,
.main-content,
.content {
    width: 100%;
    max-width: 100%;
    padding: 10px;
    margin: 0 auto;
    overflow-x: hidden;
}

@media screen and (min-width: 1200px) {
    .container {
        max-width: 1200px;
        padding: 20px;
    }
}

/* Prevenir Overflow Horizontal */
* {
    max-width: 100%;
}

img, video, iframe, embed, object {
    max-width: 100%;
    height: auto;
}

table {
    width: 100%;
    max-width: 100%;
    table-layout: auto;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Cards e Grids Responsivos */
.card,
.service-card,
.stat-card,
.result-card {
    width: 100%;
    max-width: 100%;
    margin: 10px 0;
    padding: 15px;
    box-sizing: border-box;
}

@media screen and (min-width: 768px) {
    .card,
    .service-card,
    .stat-card,
    .result-card {
        margin: 15px;
        padding: 20px;
    }
}

/* Grid Responsivo */
.grid,
.services-grid,
.results-grid,
.stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    width: 100%;
    max-width: 100%;
    padding: 10px;
    box-sizing: border-box;
}

@media screen and (min-width: 600px) {
    .grid,
    .services-grid,
    .results-grid,
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
}

@media screen and (min-width: 1024px) {
    .grid,
    .services-grid,
    .results-grid,
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 25px;
    }
}

/* Formulários Responsivos */
form {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Não aplicar max-width: 100% em form-groups específicos do login */
.form-group:not(.login-form-group):not(.cadastro-form-group) {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.input-group {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Inputs gerais - mas permitir override em páginas específicas */
input[type="text"]:not(.login-input):not(.cadastro-input),
input[type="email"]:not(.login-input):not(.cadastro-input),
input[type="password"]:not(.login-input):not(.cadastro-input),
input[type="number"]:not(.login-input):not(.cadastro-input),
input[type="tel"]:not(.login-input):not(.cadastro-input),
input[type="date"]:not(.login-input):not(.cadastro-input),
textarea:not(.login-textarea):not(.cadastro-textarea),
select:not(.login-select):not(.cadastro-select) {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    font-size: 16px; /* Previne zoom no iOS */
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
}

/* Botões Responsivos */
button,
.btn,
.upload-btn,
.download-btn,
.logout-btn {
    width: 100%;
    max-width: 100%;
    padding: 12px 20px;
    font-size: 16px;
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media screen and (min-width: 480px) {
    button,
    .btn,
    .upload-btn,
    .download-btn,
    .logout-btn {
        width: auto;
        min-width: 120px;
    }
}

/* Tabelas Responsivas */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    display: block;
}

table {
    width: 100%;
    min-width: 600px; /* Largura mínima para tabelas grandes */
}

/* Sidebar Responsivo (Admin) */
.sidebar {
    width: 100%;
    max-width: 100%;
    position: relative;
    height: auto;
    overflow-y: visible;
}

@media screen and (min-width: 768px) {
    .sidebar {
        width: 280px;
        position: fixed;
        height: 100vh;
        overflow-y: auto;
    }
    
    .main-content {
        margin-left: 280px;
    }
}

/* Menu Mobile */
.mobile-menu-toggle {
    display: block;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1001;
    background: #667eea;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 5px;
    font-size: 20px;
    cursor: pointer;
}

@media screen and (min-width: 768px) {
    .mobile-menu-toggle {
        display: none;
    }
}

/* Modais Responsivos */
.modal,
.modal-content {
    width: 95%;
    max-width: 500px;
    margin: 20px auto;
    padding: 20px;
    box-sizing: border-box;
}

@media screen and (max-width: 480px) {
    .modal,
    .modal-content {
        width: 100%;
        margin: 10px;
        padding: 15px;
    }
}

/* Texto Responsivo */
h1 {
    font-size: 1.8rem;
    line-height: 1.2;
}

h2 {
    font-size: 1.5rem;
    line-height: 1.3;
}

h3 {
    font-size: 1.3rem;
    line-height: 1.4;
}

p, span, div {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

@media screen and (max-width: 480px) {
    h1 {
        font-size: 1.5rem;
    }
    
    h2 {
        font-size: 1.3rem;
    }
    
    h3 {
        font-size: 1.1rem;
    }
}

/* Prevenir Scroll Horizontal */
body, html {
    overflow-x: hidden;
    width: 100%;
    position: relative;
}

/* Fix para elementos que podem causar overflow */
* {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

pre, code {
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

/* Imagens Responsivas */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Vídeos Responsivos */
video {
    max-width: 100%;
    height: auto;
}

/* Iframes Responsivos */
iframe {
    max-width: 100%;
    width: 100%;
    height: auto;
    min-height: 200px;
}

/* Área de Upload Responsiva */
.upload-area,
.upload-card {
    width: 100%;
    max-width: 100%;
    padding: 20px;
    box-sizing: border-box;
    margin: 10px 0;
}

@media screen and (max-width: 480px) {
    .upload-area,
    .upload-card {
        padding: 15px;
    }
}

/* Cards de Resultado Responsivos */
.results-section {
    width: 100%;
    max-width: 100%;
    padding: 15px;
    box-sizing: border-box;
}

.result-card {
    width: 100%;
    margin: 10px 0;
    padding: 15px;
    box-sizing: border-box;
}

@media screen and (min-width: 768px) {
    .result-card {
        width: calc(50% - 20px);
        margin: 10px;
        display: inline-block;
        vertical-align: top;
    }
}

/* Header Responsivo */
.header,
.topbar {
    width: 100%;
    max-width: 100%;
    padding: 15px;
    box-sizing: border-box;
    flex-wrap: wrap;
}

@media screen and (max-width: 768px) {
    .header,
    .topbar {
        padding: 10px;
    }
    
    .header-actions {
        float: none;
        margin-top: 10px;
        width: 100%;
    }
}

/* Footer Responsivo */
.footer {
    width: 100%;
    max-width: 100%;
    padding: 15px;
    box-sizing: border-box;
    text-align: center;
}

/* Utilitários */
.hide-mobile {
    display: none;
}

@media screen and (min-width: 768px) {
    .hide-mobile {
        display: block;
    }
    
    .show-mobile {
        display: none;
    }
}

.show-mobile {
    display: block;
}

@media screen and (min-width: 768px) {
    .show-mobile {
        display: none;
    }
}

/* Ajustes para telas muito pequenas */
@media screen and (max-width: 360px) {
    html {
        font-size: 12px;
    }
    
    body {
        zoom: 0.85;
        -webkit-text-size-adjust: 85%;
    }
    
    .container,
    .main-content {
        padding: 8px;
    }
}

/* Ajustes para telas grandes */
@media screen and (min-width: 1920px) {
    .container {
        max-width: 1400px;
    }
}

/* Prevenir problemas de zoom no iOS */
@supports (-webkit-touch-callout: none) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    textarea,
    select {
        font-size: 16px !important;
    }
}

/* Scrollbar personalizada (opcional) */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ============================================
   ESTILOS MOBILE BONITOS E MODERNOS
   Aplicados automaticamente em TODAS as páginas
   ============================================ */

/* Base Mobile-First Melhorada */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.6;
}

/* Cards Modernos e Bonitos */
.card,
.service-card,
.stat-card,
.result-card,
.content-card,
.admin-card {
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 20px;
    margin: 15px 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

@media (max-width: 768px) {
    .card,
    .service-card,
    .stat-card,
    .result-card,
    .content-card,
    .admin-card {
        padding: 15px;
        margin: 10px 0;
        border-radius: 15px;
    }
}

.card:hover,
.service-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    background: rgba(255, 255, 255, 0.15);
}

/* Headers Modernos */
.header,
.page-header,
.admin-header,
.content-header {
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(10px);
    padding: 20px;
    border-radius: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

@media (max-width: 768px) {
    .header,
    .page-header,
    .admin-header,
    .content-header {
        padding: 15px;
        border-radius: 15px;
        margin-bottom: 15px;
    }
    
    .header h1,
    .page-header h1,
    .admin-header h1 {
        font-size: 1.5rem !important;
    }
}

/* Botões Modernos e Visíveis */
button,
.btn,
.btn-primary,
.btn-secondary,
.btn-danger,
.btn-success,
.upload-btn,
.download-btn,
.logout-btn,
.submit-btn {
    padding: 12px 24px;
    border-radius: 25px;
    font-weight: 600;
    font-size: 16px;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px; /* Tamanho mínimo para toque fácil */
}

@media (max-width: 768px) {
    button,
    .btn {
        width: 100%;
        margin: 5px 0;
    }
}

button:active,
.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.btn-danger {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, #2ed573 0%, #1e90ff 100%);
    color: white;
}

/* Formulários Modernos */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.95rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="date"],
textarea,
select {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 16px;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

input::placeholder,
textarea::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #667eea;
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

/* Tabelas Responsivas Melhoradas */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.1);
    padding: 10px;
    margin: 15px 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: transparent;
}

table th,
table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
}

table th {
    background: rgba(102, 126, 234, 0.2);
    font-weight: 600;
    position: sticky;
    top: 0;
}

table tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

@media (max-width: 768px) {
    table {
        font-size: 0.85rem;
    }
    
    table th,
    table td {
        padding: 8px;
    }
}

/* Grids Responsivos Melhorados */
.grid,
.services-grid,
.results-grid,
.stats-grid,
.cards-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    padding: 10px;
}

@media (min-width: 600px) {
    .grid,
    .services-grid,
    .results-grid,
    .stats-grid,
    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
}

@media (min-width: 1024px) {
    .grid,
    .services-grid,
    .results-grid,
    .stats-grid,
    .cards-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 25px;
    }
}

/* Modais e Popups Modernos */
.modal,
.modal-content,
.popup,
.dialog {
    background: rgba(26, 26, 46, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-width: 90%;
    margin: 20px auto;
}

@media (max-width: 768px) {
    .modal,
    .modal-content,
    .popup,
    .dialog {
        padding: 20px;
        border-radius: 15px;
        max-width: 95%;
        margin: 10px auto;
    }
}

/* Alertas e Mensagens Modernos */
.alert,
.message,
.notification,
.success-message,
.error-message {
    padding: 15px 20px;
    border-radius: 15px;
    margin: 15px 0;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.alert-success,
.success-message {
    background: rgba(46, 213, 115, 0.2);
    border: 1px solid rgba(46, 213, 115, 0.5);
    color: #2ed573;
}

.alert-error,
.error-message {
    background: rgba(255, 107, 107, 0.2);
    border: 1px solid rgba(255, 107, 107, 0.5);
    color: #ff6b6b;
}

.alert-info {
    background: rgba(102, 126, 234, 0.2);
    border: 1px solid rgba(102, 126, 234, 0.5);
    color: #667eea;
}

.alert-warning {
    background: rgba(255, 193, 7, 0.2);
    border: 1px solid rgba(255, 193, 7, 0.5);
    color: #ffc107;
}

/* Badges e Tags Modernos */
.badge,
.tag,
.label {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    background: rgba(102, 126, 234, 0.2);
    color: #667eea;
    border: 1px solid rgba(102, 126, 234, 0.3);
}

/* Loading e Spinners Modernos */
.loading,
.spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Ícones Melhorados */
.icon,
.fa-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    border-radius: 12px;
    background: rgba(102, 126, 234, 0.2);
    color: #667eea;
    font-size: 1.5rem;
}

@media (max-width: 768px) {
    .icon,
    .fa-icon {
        width: 45px;
        height: 45px;
        font-size: 1.3rem;
    }
}

/* Navegação Mobile Melhorada */
.nav,
.navigation,
.menu {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 15px;
    border-radius: 15px;
    margin-bottom: 20px;
}

.nav-item,
.menu-item {
    padding: 12px 18px;
    border-radius: 12px;
    margin: 5px 0;
    transition: all 0.3s ease;
    cursor: pointer;
}

.nav-item:hover,
.menu-item:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateX(5px);
}

/* Breadcrumbs Modernos */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 0;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
    flex-wrap: wrap;
}

.breadcrumb a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: color 0.3s ease;
}

.breadcrumb a:hover {
    color: #667eea;
}

/* Tooltips Modernos */
.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 12px;
    background: rgba(26, 26, 46, 0.95);
    color: white;
    border-radius: 8px;
    font-size: 0.85rem;
    white-space: nowrap;
    z-index: 1000;
    margin-bottom: 5px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

/* Separadores Modernos */
.divider,
.separator {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    margin: 20px 0;
}

/* Scroll Suave */
html {
    scroll-behavior: smooth;
}

/* Animações Suaves */
* {
    transition: background-color 0.3s ease, color 0.3s ease, transform 0.3s ease;
}

/* Melhorias de Acessibilidade */
button:focus,
a:focus,
input:focus,
textarea:focus,
select:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Espaçamento Consistente */
.section {
    margin: 30px 0;
    padding: 20px;
}

@media (max-width: 768px) {
    .section {
        margin: 20px 0;
        padding: 15px;
    }
}

/* Container Principal Melhorado */
.main-container,
.page-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

@media (max-width: 768px) {
    .main-container,
    .page-container {
        padding: 15px;
    }
}

/* Utilitários Adicionais */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mt-1 { margin-top: 10px; }
.mt-2 { margin-top: 20px; }
.mt-3 { margin-top: 30px; }

.mb-1 { margin-bottom: 10px; }
.mb-2 { margin-bottom: 20px; }
.mb-3 { margin-bottom: 30px; }

.p-1 { padding: 10px; }
.p-2 { padding: 20px; }
.p-3 { padding: 30px; }

/* Fix para elementos fixos em mobile */
.fixed-element,
.sticky-element {
    position: fixed;
    z-index: 1000;
}

@media (max-width: 768px) {
    .fixed-element,
    .sticky-element {
        position: relative;
    }
}