/* ==================== RESET E CONFIGURAÇÕES GLOBAIS ==================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #f97316;
    --primary-dark: #ea580c;
    --primary-light: #ffedd5;
    --secondary: #1a237e;
    --secondary-dark: #0f1a5c;
    --secondary-light: #e8eaf6;
    --success: #10b981;
    --danger: #dc2626;
    --warning: #f59e0b;
    --info: #3b82f6;
    --purple: #8b5cf6;
    --gray-100: #f8fafc;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-600: #475569;
    --gray-800: #1e293b;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1);
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    --radius-2xl: 2rem;
}

/* BODY CORRIGIDO - MESMA COR DO LOGIN */
body {
    font-family: 'Segoe UI', 'Poppins', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #264893;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    margin: 0;
}

/* ==================== SCROLLBAR PERSONALIZADA ==================== */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--gray-200);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* ==================== SELEÇÃO DE TEXTO ==================== */

::selection {
    background: var(--primary);
    color: white;
}

/* ==================== HOME CONTAINER ==================== */

.home-container {
    background: var(--gray-100);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 1400px;
    min-height: 85vh;
    margin: 0 auto;
    overflow: hidden;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ==================== HEADER ==================== */

.header {
    background: linear-gradient(135deg, var(--secondary) 0%, var(--secondary-dark) 100%);
    padding: 20px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-logo-img {
    height: 48px;
    width: auto;
    filter: brightness(0) invert(1);
}

.header h1 {
    color: white;
    font-size: 22px;
    font-weight: 600;
    margin: 0;
}

.user-info {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
    color: white;
    font-size: 14px;
}

.role-selector {
    background: rgba(249, 115, 22, 0.2);
    border: 1px solid rgba(249, 115, 22, 0.5);
    color: white;
    padding: 8px 16px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.role-selector:hover {
    background: rgba(249, 115, 22, 0.3);
    border-color: var(--primary);
}

.role-selector option {
    background: var(--secondary);
    color: white;
}

.logout-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 8px 20px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

.logout-btn:hover {
    background: var(--danger);
    border-color: var(--danger);
    transform: translateY(-1px);
}

/* ==================== CONTENT ==================== */

.content {
    padding: 32px;
}

/* ==================== NAV BUTTONS ==================== */

.nav-buttons {
    display: flex;
    gap: 12px;
    margin-bottom: 32px;
    flex-wrap: wrap;
}

.nav-btn {
    background: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    color: var(--secondary);
    box-shadow: var(--shadow-sm);
}

.nav-btn:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -5px rgba(249, 115, 22, 0.3);
}

/* ==================== EVALUATION FORM ==================== */

.evaluation-form {
    background: white;
    padding: 28px;
    border-radius: var(--radius-xl);
    margin-bottom: 32px;
    box-shadow: var(--shadow-md);
}

.form-title {
    font-size: 20px;
    margin-bottom: 24px;
    color: var(--secondary);
    font-weight: 600;
    padding-bottom: 12px;
    border-bottom: 3px solid var(--primary);
    display: inline-block;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 24px;
}

.form-field {
    display: flex;
    flex-direction: column;
}

.form-field label {
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--gray-800);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-field input, 
.form-field select,
.form-field textarea {
    padding: 12px 14px;
    border: 2px solid var(--gray-200);
    border-radius: 10px;
    font-size: 14px;
    transition: all 0.3s;
    background: var(--gray-100);
    font-family: inherit;
}

.form-field input:focus, 
.form-field select:focus,
.form-field textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}

.form-field input[readonly] {
    background: var(--gray-200);
    cursor: default;
    border-color: var(--gray-200);
}

.form-field .full-width {
    grid-column: 1 / -1;
}

.submit-btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    padding: 14px 32px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s;
    width: 100%;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -5px rgba(249, 115, 22, 0.4);
}

/* ==================== CLIENT INFO CARD ==================== */

.client-info {
    background: linear-gradient(135deg, var(--secondary) 0%, var(--secondary-dark) 100%);
    padding: 24px;
    border-radius: var(--radius-xl);
    margin-bottom: 32px;
    color: white;
    box-shadow: var(--shadow-lg);
}

.client-info h3 {
    margin-bottom: 16px;
    color: white;
    font-size: 18px;
}

.info-card {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.info-card p {
    margin: 6px 0;
}

.info-card strong {
    opacity: 0.8;
    font-weight: 500;
}

/* ==================== CHARTS ==================== */

.charts-section {
    margin-top: 32px;
}

.chart-container {
    background: white;
    padding: 20px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    margin-bottom: 24px;
}

.chart-container h4 {
    font-size: 16px;
    margin-bottom: 16px;
    color: var(--secondary);
    font-weight: 600;
}

canvas {
    max-height: 300px;
    width: 100%;
}

/* ==================== EVALUATIONS LIST ==================== */

.client-evaluations {
    margin-top: 24px;
}

.client-evaluations h3 {
    color: var(--secondary);
    margin-bottom: 20px;
    font-size: 20px;
    font-weight: 600;
}

.evaluation-card {
    background: white;
    padding: 20px;
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
    border-left: 4px solid var(--primary);
    transition: all 0.3s;
    box-shadow: var(--shadow-sm);
}

.evaluation-card:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow-lg);
}

.evaluation-date {
    font-weight: bold;
    color: var(--primary);
    margin-bottom: 10px;
    font-size: 14px;
}

.evaluation-data {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

/* ==================== MODAL ==================== */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 32px;
    border-radius: var(--radius-2xl);
    width: 90%;
    max-width: 500px;
    position: relative;
    animation: modalSlideIn 0.3s ease;
    box-shadow: var(--shadow-xl);
    max-height: 85vh;
    overflow-y: auto;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-60px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close {
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: var(--gray-400);
    transition: color 0.2s;
}

.close:hover {
    color: var(--danger);
}

.modal-content h3 {
    color: var(--secondary);
    margin-bottom: 24px;
    font-size: 22px;
    font-weight: 600;
}

/* ==================== PERFIL BADGES ==================== */

.perfil-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.perfil-operador {
    background: var(--success);
    color: white;
}

.perfil-operador-membro {
    background: var(--warning);
    color: white;
}

.perfil-supervisor {
    background: var(--info);
    color: white;
}

.perfil-gerente {
    background: var(--purple);
    color: white;
}

.perfil-admin {
    background: var(--danger);
    color: white;
}

/* ==================== RANGE SLIDER ==================== */

input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: var(--gray-200);
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    background: var(--primary-dark);
}

/* ==================== LOADING ==================== */

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==================== RESPONSIVE ==================== */

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .home-container {
        margin: 0;
        border-radius: var(--radius-lg);
    }
    
    .header {
        flex-direction: column;
        text-align: center;
        padding: 20px;
    }
    
    .header-logo {
        flex-direction: column;
    }
    
    .header-logo-img {
        height: 40px;
    }
    
    .header h1 {
        font-size: 16px;
    }
    
    .content {
        padding: 20px;
    }
    
    .nav-buttons {
        flex-direction: column;
    }
    
    .nav-btn {
        width: 100%;
        text-align: center;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .user-info {
        justify-content: center;
    }
    
    .modal-content {
        margin: 10% auto;
        padding: 24px;
    }
    
    .evaluation-data {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .content {
        padding: 16px;
    }
    
    .evaluation-form {
        padding: 20px;
    }
    
    .client-info {
        padding: 16px;
    }
    
    .info-card {
        grid-template-columns: 1fr;
    }
}

/* ==================== PRINT STYLES ==================== */

@media print {
    .header,
    .nav-buttons,
    .logout-btn,
    .role-selector,
    .submit-btn,
    .modal {
        display: none !important;
    }
    
    .home-container {
        box-shadow: none;
        margin: 0;
        padding: 0;
    }
    
    .content {
        padding: 0;
    }
    
    .evaluation-card {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}

/* ==================== UTILITY CLASSES ==================== */

.text-center {
    text-align: center;
}

.text-primary {
    color: var(--primary);
}

.text-secondary {
    color: var(--secondary);
}

.text-success {
    color: var(--success);
}

.text-danger {
    color: var(--danger);
}

.text-warning {
    color: var(--warning);
}

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mt-5 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mb-5 { margin-bottom: 2rem; }

.hidden {
    display: none !important;
}

/* ==================== ANIMAÇÕES ==================== */

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.pulse {
    animation: pulse 2s infinite;
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-5px);
    }
    75% {
        transform: translateX(5px);
    }
}

.shake {
    animation: shake 0.3s ease;
}

/* ==================== PWA & TOUCH OPTIMIZATIONS ==================== */

/* Melhorar toque em dispositivos móveis */
button, 
.nav-btn, 
.logout-btn,
.role-selector,
.submit-btn,
.close {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Prevenir zoom em inputs em iOS */
@media (max-width: 768px) {
    input, 
    select, 
    textarea {
        font-size: 16px !important;
    }
}

/* Safe area para iPhones com notch */
@supports (padding: max(0px)) {
    .header {
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
        padding-top: max(20px, env(safe-area-inset-top));
    }
    
    .content {
        padding-bottom: max(32px, env(safe-area-inset-bottom));
    }
}

/* Melhorar performance de scroll */
.home-container {
    -webkit-overflow-scrolling: touch;
}

/* Evitar seleção acidental em elementos interativos */
.nav-btn, 
.logout-btn,
.submit-btn {
    user-select: none;
}

/* ==================== TELA DE LOGIN PROFISSIONAL ==================== */

.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #264893;
    padding: 20px;
    width: 100%;
}

.login-card {
    background: white;
    border-radius: 32px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 480px;
    padding: 56px 48px;
    animation: fadeInUp 0.5s ease;
}

.login-header {
    text-align: center;
    margin-bottom: 48px;
}

.logo-container {
    margin-bottom: 0;
}

.login-logo-img {
    max-width: 300px;
    width: 100%;
    height: auto;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
}

/* Inputs estilizados */
.input-group-custom {
    position: relative;
    display: flex;
    align-items: center;
    margin-bottom: 24px;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 16px;
    transition: all 0.3s ease;
}

.input-group-custom:focus-within {
    border-color: #f97316;
    background: white;
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}

.input-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    color: #94a3b8;
    font-size: 22px;
    transition: color 0.3s ease;
}

.input-group-custom:focus-within .input-icon {
    color: #f97316;
}

.input-field {
    flex: 1;
    position: relative;
}

.input-field input {
    width: 100%;
    padding: 22px 12px 8px 0;
    border: none;
    background: transparent;
    font-size: 16px;
    color: #1e293b;
    outline: none;
}

.input-field label {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 16px;
    pointer-events: none;
    transition: all 0.2s ease;
}

.input-field.focused label,
.input-field input:not(:placeholder-shown) + label {
    top: 10px;
    transform: translateY(0);
    font-size: 11px;
    color: #f97316;
}

.password-toggle {
    cursor: pointer;
    transition: color 0.2s;
    width: 56px;
}

.password-toggle:hover {
    color: #f97316;
}

/* Checkbox customizado */
.login-options {
    margin-bottom: 32px;
}

.checkbox-custom {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.checkbox-custom input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: relative;
    height: 20px;
    width: 20px;
    background-color: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    margin-right: 12px;
    transition: all 0.2s ease;
}

.checkbox-custom:hover input ~ .checkmark {
    border-color: #f97316;
}

.checkbox-custom input:checked ~ .checkmark {
    background-color: #f97316;
    border-color: #f97316;
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.checkbox-custom input:checked ~ .checkmark:after {
    display: block;
}

.checkbox-custom .checkmark:after {
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checkbox-text {
    font-size: 14px;
    color: #475569;
    font-weight: 500;
}

/* Botão de login */
.login-button {
    width: 100%;
    padding: 18px;
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    color: white;
    border: none;
    border-radius: 16px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.login-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -5px rgba(249, 115, 22, 0.4);
}

.login-button:active {
    transform: translateY(0);
}

.login-button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* Mensagem de erro */
.error-message-custom {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #dc2626;
    padding: 14px 18px;
    border-radius: 14px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 500;
    animation: shake 0.3s ease;
}

/* Responsivo */
@media (max-width: 480px) {
    .login-card {
        padding: 40px 28px;
        max-width: 420px;
    }
    
    .login-logo-img {
        max-width: 250px;
    }
    
    .login-header {
        margin-bottom: 36px;
    }
    
    .input-icon {
        width: 48px;
        font-size: 18px;
    }
    
    .password-toggle {
        width: 48px;
    }
    
    .input-field input {
        padding: 20px 12px 6px 0;
        font-size: 15px;
    }
    
    .login-button {
        padding: 16px;
        font-size: 15px;
    }
}

@media (max-width: 380px) {
    .login-card {
        padding: 32px 24px;
    }
    
    .login-logo-img {
        max-width: 210px;
    }
}

/* Remove o ícone de olho nativo do navegador no campo de senha */
input[type="password"]::-ms-reveal,
input[type="password"]::-webkit-credentials-auto-fill-button {
    display: none !important;
}

/* Estilos para os botões da tabela */
.btn-ver-codigo:hover {
    background: #2563eb !important;
    transform: translateY(-1px);
}

.btn-regerar-codigo:hover {
    background: #d97706 !important;
    transform: translateY(-1px);
}

/* Estilo da tabela responsiva */
@media (max-width: 768px) {
    #pacientesTableContainer table {
        font-size: 12px;
    }
    
    .btn-ver-codigo, .btn-regerar-codigo {
        padding: 4px 8px !important;
        font-size: 11px;
    }
}
