/**
 * MedSim.HEALTH - Estilos Customizados
 * Refatorado para reduzir repetição no HTML
 */

/* ==========================================================================
   Base
   ========================================================================== */
[x-cloak] { display: none !important; }
* { -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; overflow-x: hidden; }
body {
    background: radial-gradient(ellipse at top, #0f1a14 0%, #080c0a 50%, #050807 100%);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
}

/* ==========================================================================
   Animations
   ========================================================================== */
@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 208, 132, 0.5), 0 0 20px rgba(0, 208, 132, 0.2); }
    50% { box-shadow: 0 0 0 8px rgba(0, 208, 132, 0), 0 0 30px rgba(0, 208, 132, 0.3); }
}
@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    14% { transform: scale(1.1); }
    28% { transform: scale(1); }
    42% { transform: scale(1.1); }
    70% { transform: scale(1); }
}
@keyframes fade-up {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes slide-in {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes ecg-draw { to { stroke-dashoffset: 0; } }

.pulse-glow { animation: pulse-glow 2s ease-in-out infinite; }
.heartbeat { animation: heartbeat 1.5s ease-in-out infinite; }
.fade-up { animation: fade-up 0.5s ease-out forwards; }
.slide-in { animation: slide-in 0.4s ease-out forwards; }
.ecg-line { stroke-dasharray: 500; stroke-dashoffset: 500; animation: ecg-draw 2s linear infinite; }
.glow-text { text-shadow: 0 0 30px rgba(0, 208, 132, 0.5), 0 0 60px rgba(0, 208, 132, 0.3); }

/* ==========================================================================
   Component Classes - Reduce HTML repetition
   ========================================================================== */

/* Panel - base container */
.panel {
    background: #0f1512;
    border-radius: 1rem;
    border: 1px solid #1f2a25;
    overflow: hidden;
}

/* Card & Stat-box - shared base */
.card, .stat-box {
    background: rgba(8, 12, 10, 0.5);
    border-radius: 0.75rem;
    border: 1px solid rgba(31, 42, 37, 0.5);
}
.card { padding: 1rem; }
.stat-box { padding: 0.75rem; text-align: center; }

/* ==========================================================================
   Modal System - Robust & Accessible
   ========================================================================== */

/* Overlay */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 50;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 1rem;
    padding-top: max(1rem, env(safe-area-inset-top));
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
}

@media (min-width: 640px) {
    .modal-overlay {
        align-items: center;
        padding: 2rem;
    }
}

/* Modal Container */
.modal {
    position: relative;
    background: linear-gradient(180deg, #111916 0%, #0f1512 100%);
    border-radius: 1.25rem;
    border: 1px solid #1f2a25;
    box-shadow:
        0 25px 50px -12px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(255, 255, 255, 0.02) inset;
    overflow: hidden;
    max-width: 42rem;
    width: 100%;
    max-height: calc(100vh - 2rem);
    max-height: calc(100dvh - 2rem);
    display: flex;
    flex-direction: column;
    animation: modal-enter 0.3s cubic-bezier(0.21, 1.02, 0.73, 1);
}

@keyframes modal-enter {
    0% { opacity: 0; transform: scale(0.95) translateY(10px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

@media (min-width: 640px) {
    .modal {
        max-height: 90vh;
        max-height: 90dvh;
    }
}

/* Modal Header */
.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #1f2a25;
    background: linear-gradient(90deg, rgba(0, 208, 132, 0.08) 0%, transparent 100%);
    flex-shrink: 0;
}

/* Modal Body - scrollable */
.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    overscroll-behavior: contain;
}

/* Modal Footer */
.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #1f2a25;
    background: rgba(8, 12, 10, 0.5);
    flex-shrink: 0;
}

/* Large modal variant */
.modal-lg {
    max-width: 56rem;
}

/* Small modal variant */
.modal-sm {
    max-width: 28rem;
}

/* ==========================================================================
   Drawer Panel (Mobile Prontuario)
   ========================================================================== */

.drawer-panel {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    max-width: 20rem;
    background: linear-gradient(180deg, #111916 0%, #0f1512 100%);
    border-left: 1px solid #1f2a25;
    display: flex;
    flex-direction: column;
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.5);
}

.drawer-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #1f2a25;
    background: linear-gradient(90deg, rgba(74, 222, 128, 0.08) 0%, transparent 100%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.25rem;
    overscroll-behavior: contain;
}

/* Section header */
.section-header {
    padding: 1rem;
    border-bottom: 1px solid #1f2a25;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.section-header-icon {
    width: 2rem;
    height: 2rem;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 600;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}
.btn-primary {
    background: linear-gradient(to right, #00d084, #4ade80);
    color: #080c0a;
}
.btn-primary:hover { box-shadow: 0 10px 25px -5px rgba(0, 208, 132, 0.2); }
.btn-secondary {
    background: #0f1512;
    border: 1px solid #1f2a25;
    color: #9ca3af;
}
.btn-secondary:hover { color: white; border-color: #2a3830; }
.btn-action {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}
.btn-action::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
    transform: translateX(-100%);
    transition: transform 0.5s ease;
}
.btn-action:hover::before { transform: translateX(100%); }

/* Badge relevance */
.badge { padding: 0.125rem 0.5rem; border-radius: 9999px; font-size: 0.75rem; }
.badge-essencial { background: rgba(0, 208, 132, 0.15); color: #00d084; border: 1px solid rgba(0, 208, 132, 0.3); }
.badge-util { background: rgba(84, 160, 255, 0.15); color: #54a0ff; border: 1px solid rgba(84, 160, 255, 0.3); }
.badge-superflua { background: rgba(255, 159, 67, 0.15); color: #ff9f43; border: 1px solid rgba(255, 159, 67, 0.3); }

/* Action Cost Badge */
.action-cost-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    background: rgba(31, 42, 37, 0.8);
    border: 1px solid rgba(42, 56, 48, 0.8);
    border-radius: 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: #9ca3af;
}
.action-cost-badge svg { color: #6b7280; }
.action-cost-badge-warning {
    background: rgba(255, 159, 67, 0.15);
    border-color: rgba(255, 159, 67, 0.3);
    color: #ff9f43;
}
.action-cost-badge-warning svg { color: #ff9f43; }

/* ==========================================================================
   Phase Navigation
   ========================================================================== */

.phase-navigation {
    background: #0f1512;
    border-radius: 1rem;
    border: 1px solid #1f2a25;
    overflow: hidden;
}

.phase-nav-progress {
    height: 3px;
    background: #1f2a25;
}

.phase-nav-progress-bar {
    height: 100%;
    background: linear-gradient(to right, #00d084, #4ade80);
    transition: width 0.3s ease;
    border-radius: 0 3px 3px 0;
}

.phase-nav-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    gap: 1rem;
}

.phase-nav-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.phase-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.625rem 1rem;
    border-radius: 0.625rem;
    font-size: 0.875rem;
    font-weight: 600;
    transition: all 0.2s;
}

.phase-nav-btn-secondary {
    background: #141a17;
    border: 1px solid #1f2a25;
    color: #9ca3af;
}
.phase-nav-btn-secondary:hover {
    background: #1f2a25;
    color: white;
}

.phase-nav-btn-primary {
    background: rgba(0, 208, 132, 0.25);
    border: 1px solid rgba(0, 208, 132, 0.5);
    color: #00d084;
}
.phase-nav-btn-primary:hover {
    background: rgba(0, 208, 132, 0.35);
    border-color: rgba(0, 208, 132, 0.7);
}

.phase-nav-btn-highlight {
    background: linear-gradient(to right, #00d084, #4ade80);
    border: none;
    color: #080c0a;
    box-shadow: 0 4px 15px rgba(0, 208, 132, 0.3);
}
.phase-nav-btn-highlight:hover {
    box-shadow: 0 6px 20px rgba(0, 208, 132, 0.4);
    transform: translateY(-1px);
}

/* Tooltip */
.tooltip {
    position: absolute;
    background: #080c0a;
    border: 1px solid #1f2a25;
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    z-index: 50;
    width: 16rem;
}
@media (max-width: 640px) {
    .tooltip {
        position: fixed !important;
        left: 1rem !important;
        right: 1rem !important;
        width: auto;
        max-width: none;
    }
}

/* Alert box */
.alert {
    padding: 1rem;
    border-radius: 1rem;
    border: 1px solid;
}
.alert-danger { background: rgba(255, 71, 87, 0.1); border-color: rgba(255, 71, 87, 0.3); color: #ff4757; }
.alert-success { background: rgba(0, 208, 132, 0.05); border-color: rgba(0, 208, 132, 0.3); color: #00d084; }
.alert-info { background: rgba(84, 160, 255, 0.1); border-color: rgba(84, 160, 255, 0.2); }
.alert-warning { background: rgba(254, 202, 87, 0.1); border-color: rgba(254, 202, 87, 0.2); }

/* Response bubble */
.response-bubble {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: rgba(8, 12, 10, 0.5);
    border-radius: 0.75rem;
    border-left: 2px solid #00d084;
}

/* Phase button */
.phase-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 0.75rem;
    transition: all 0.2s;
    text-align: left;
}
.phase-btn.active {
    background: rgba(0, 208, 132, 0.15);
    color: #00d084;
    border: 1px solid rgba(0, 208, 132, 0.3);
}
.phase-btn:not(.active) { color: #9ca3af; }
.phase-btn:not(.active):hover { background: rgba(8, 12, 10, 0.5); }

/* Grid background */
.medical-grid {
    background-image:
        linear-gradient(rgba(0, 208, 132, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 208, 132, 0.03) 1px, transparent 1px);
    background-size: 24px 24px;
}

/* ==========================================================================
   Scrollbar
   ========================================================================== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #0f1512; border-radius: 3px; }
::-webkit-scrollbar-thumb { background: #1f2a25; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #00d084; }
.scrollbar-hide { -ms-overflow-style: none; scrollbar-width: none; }
.scrollbar-hide::-webkit-scrollbar { display: none; }

/* ==========================================================================
   Form
   ========================================================================== */
input:focus, textarea:focus {
    outline: none;
    border-color: #00d084 !important;
    box-shadow: 0 0 0 3px rgba(0, 208, 132, 0.1);
}

/* ==========================================================================
   Toast System - Robust Notifications
   ========================================================================== */

/* Container - bottom-right desktop, bottom-center mobile */
.toast-container {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
    max-width: 100%;
    bottom: 0;
    right: 0;
    left: 0;
}

@media (min-width: 640px) {
    .toast-container {
        left: auto;
        max-width: 400px;
        padding: 1.5rem;
    }
}

/* Toast Item */
.toast-item {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: 0.875rem;
    background: #141a17;
    border: 1px solid #2a3830;
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
    animation: toast-enter 0.4s cubic-bezier(0.21, 1.02, 0.73, 1);
}

@keyframes toast-enter {
    0% { opacity: 0; transform: translateY(100%) scale(0.9); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* Icon container */
.toast-icon {
    flex-shrink: 0;
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.toast-icon svg { width: 100%; height: 100%; }

/* Content */
.toast-content { flex: 1; min-width: 0; }
.toast-message {
    font-size: 0.875rem;
    font-weight: 500;
    color: #e5e7eb;
    line-height: 1.4;
    word-break: break-word;
}

/* Close button */
.toast-close {
    flex-shrink: 0;
    width: 1.25rem;
    height: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s, color 0.2s;
    margin-left: 0.25rem;
}
.toast-close:hover { opacity: 1; color: #9ca3af; }
.toast-close svg { width: 100%; height: 100%; }

/* Progress bar */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(0, 0, 0, 0.2);
}
.toast-progress-bar {
    height: 100%;
    transition: width 0.1s linear;
    border-radius: 0 0 0.875rem 0.875rem;
}

/* Variants */
.toast-success { border-color: rgba(0, 208, 132, 0.3); }
.toast-success .toast-icon { color: #00d084; }
.toast-success .toast-progress-bar { background: #00d084; }

.toast-error { border-color: rgba(255, 71, 87, 0.3); }
.toast-error .toast-icon { color: #ff4757; }
.toast-error .toast-progress-bar { background: #ff4757; }

.toast-warning { border-color: rgba(254, 202, 87, 0.3); }
.toast-warning .toast-icon { color: #feca57; }
.toast-warning .toast-progress-bar { background: #feca57; }

.toast-info { border-color: rgba(84, 160, 255, 0.3); }
.toast-info .toast-icon { color: #54a0ff; }
.toast-info .toast-progress-bar { background: #54a0ff; }

/* ==========================================================================
   Mobile
   ========================================================================== */
@media (max-width: 768px) {
    input, select, textarea { font-size: 16px; }
    .fixed.inset-0 > .min-h-full {
        min-height: 100%;
        padding-top: env(safe-area-inset-top, 1rem);
        padding-bottom: env(safe-area-inset-bottom, 1rem);
    }
}
@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
        padding-bottom: max(0px, env(safe-area-inset-bottom));
    }
}

/* Touch */
.touch-manipulation { touch-action: manipulation; }
@media (pointer: coarse) {
    button, [role="button"], .cursor-pointer { min-height: 44px; min-width: 44px; }
    .text-xs button, button.text-xs { min-height: 32px; min-width: auto; }
    button:active:not(.btn-action), [role="button"]:active { transform: scale(0.98); opacity: 0.9; }
}

/* ==========================================================================
   Notification Center
   ========================================================================== */

.notification-item {
    border-left: 3px solid transparent;
}

.notification-important {
    background: rgba(255, 71, 87, 0.05);
    border-left-color: #ff4757;
}

.notification-icon {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notification-icon-success {
    background: rgba(0, 208, 132, 0.15);
    color: #00d084;
}

.notification-icon-error {
    background: rgba(255, 71, 87, 0.15);
    color: #ff4757;
}

.notification-icon-warning {
    background: rgba(254, 202, 87, 0.15);
    color: #feca57;
}

.notification-icon-info {
    background: rgba(84, 160, 255, 0.15);
    color: #54a0ff;
}
