/* Estilos CSS adicionais para melhorias na interface */

:root {
    --body-text-color: #e2e8f0;
    --dark-bg-alt: #1e293b;
}

body {
    color: var(--body-text-color, #e2e8f0);
}

/* Melhorias no tema dark */
.sidebar .btn-refresh:focus {
    box-shadow: 0 0 0 0.2rem rgba(255, 255, 255, 0.25);
}

/* Efeitos de hover melhorados */
.device-card {
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.device-card.disabled {
    opacity: 0.6;
    pointer-events: none;
    filter: grayscale(0.3);
}

.device-card:hover {
    transform: translateY(-3px) scale(1.02);
}

/* Loading states melhorados */
.btn.loading {
    opacity: 0.8;
    cursor: not-allowed;
}

.btn.loading * {
    visibility: hidden;
}

/* Animações de entrada */
@keyframes slideInDown {
    from {
        transform: translate3d(0, -100%, 0);
        visibility: visible;
    }
    to {
        transform: translate3d(0, 0, 0);
    }
}

.slide-in-down {
    animation: slideInDown 0.5s ease-out;
}

/* Melhorias no terminal */
.terminal-container {
    position: relative;
    overflow: hidden;
}

.terminal-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
}

/* Estados de conexão melhorados */
.status-indicator {
    position: relative;
}

.status-indicator.status-online::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid currentColor;
    border-radius: 50%;
    opacity: 0.3;
    animation: ripple 2s infinite;
}

@keyframes ripple {
    0% {
        width: 12px;
        height: 12px;
        opacity: 0.8;
    }
    100% {
        width: 24px;
        height: 24px;
        opacity: 0;
    }
}

/* Melhorias nos badges */
.protocol-badge {
    position: relative;
    overflow: hidden;
}

.protocol-badge::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

.device-card:hover .protocol-badge::before {
    left: 100%;
}

/* Scrollbar customizada para sidebar */
.sidebar-content {
    overflow-y: auto;
    max-height: calc(100vh - 140px);
}

.sidebar-content::-webkit-scrollbar {
    width: 6px;
}

.sidebar-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.sidebar-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Melhorias na responsividade */
@media (max-width: 992px) {
    .connection-form .row {
        margin: 0;
    }
    
    .connection-form .col-md-6 {
        padding: 0.5rem;
    }
}

/* Tooltips customizados */
[data-bs-toggle="tooltip"] {
    cursor: help;
}

/* Animações de entrada staggered para devices */
.device-card:nth-child(1) { animation-delay: 0.1s; }
.device-card:nth-child(2) { animation-delay: 0.2s; }
.device-card:nth-child(3) { animation-delay: 0.3s; }
.device-card:nth-child(4) { animation-delay: 0.4s; }
.device-card:nth-child(5) { animation-delay: 0.5s; }

.devices-loading .device-card {
    animation: fadeIn 0.5s ease-out both;
}

/* Melhorias no form de conexão */
.connection-form .form-floating {
    margin-bottom: 1.5rem;
}

.form-floating > .form-control:focus ~ label,
.form-floating > .form-control:not(:placeholder-shown) ~ label {
    color: var(--primary-color);
    transform: scale(0.85) translateY(-0.5rem) translateX(0.15rem);
}

/* Estados de erro melhorados */
.form-control.is-invalid {
    border-color: var(--danger-color);
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 20%, 40%, 60%, 80% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
}

/* Melhorias nos alerts */
.alert-floating {
    animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Transferência de arquivos */
.file-transfer-body {
    background: rgba(15, 23, 42, 0.7);
}

.file-transfer-card {
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 14px;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.25);
}

.file-transfer-card .card-header {
    background: transparent;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.file-transfer-card .card-body {
    background: transparent;
}

.remote-browser {
    position: relative;
    min-height: 320px;
}

.remote-files-table tbody tr {
    cursor: pointer;
    transition: background 0.2s ease;
}

.remote-files-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.12);
}

.remote-files-table i {
    width: 18px;
}

.remote-files-empty {
    border: 1px dashed rgba(148, 163, 184, 0.2);
    border-radius: 12px;
}

.remote-files-table .btn {
    padding: 0.25rem 0.5rem;
}

@media (max-width: 768px) {
    .file-transfer-card {
        border-radius: 10px;
    }
}

/* Dark mode enhancements */
@media (prefers-color-scheme: dark) {
    .connection-form {
        background: rgba(30, 41, 59, 0.9);
        color: white;
    }
    
    .welcome-area {
        background: rgba(30, 41, 59, 0.5);
        color: white;
    }
    
    .form-control {
        background: rgba(51, 65, 85, 0.8);
        border-color: rgba(71, 85, 105, 0.8);
        color: white;
    }
    
    .form-control::placeholder {
        color: rgba(255, 255, 255, 0.6);
    }
}

/* ===== MELHORIAS GLOBAIS DE CONTRASTE E VISIBILIDADE ===== */
:root {
    --text-light: #f1f5f9;
    --text-muted-light: #94a3b8;
    --text-danger-light: #f87171;
    --text-success-light: #4ade80;
    --text-warning-light: #fbbf24;
}

/* Correções globais de contraste */
.text-muted {
    color: var(--text-muted-light) !important;
}

.card-header h5, 
.card-header h4, 
.card-header h3 {
    color: var(--text-light) !important;
    font-weight: 600;
}

.form-label {
    color: var(--text-light) !important;
    font-weight: 500;
}

.form-text {
    color: var(--text-muted-light) !important;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text-light) !important;
}

.text-danger {
    color: var(--text-danger-light) !important;
}

.text-success {
    color: var(--text-success-light) !important;
}

.text-warning {
    color: var(--text-warning-light) !important;
}

/* Melhorar contraste de placeholders */
.form-control::placeholder,
.form-select::placeholder {
    color: var(--text-muted-light) !important;
    opacity: 0.8;
}

/* Modal - Tema escuro */
.modal-content {
    background: var(--card-bg, #1e293b);
    border: 1px solid rgba(148, 163, 184, 0.25);
    color: var(--text-light, #e2e8f0);
}

.modal-header {
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.modal-footer {
    border-top: 1px solid rgba(148, 163, 184, 0.2);
}

.modal .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* Melhorar visibilidade de labels em modals */
.modal-body .form-label {
    color: var(--text-light) !important;
}

/* Melhorar contraste de textos pequenos */
small.text-muted {
    color: var(--text-muted-light) !important;
}

/* Melhorar contraste de parágrafo e span */
p, span {
    color: inherit;
}

p.text-muted, span.text-muted {
    color: var(--text-muted-light) !important;
}

/* Melhorar visibilidade de strong dentro de text-muted */
.text-muted strong {
    color: var(--text-light) !important;
}

/* Espaçamento extra para modais quando rodapé fixo estiver presente */
body.with-app-footer .modal {
    padding-bottom: var(--app-footer-offset, 96px);
}

body.with-app-footer .modal-dialog {
    margin-bottom: calc(var(--app-footer-offset, 96px) + 1.5rem);
}

@media (max-width: 576px) {
    body.with-app-footer .modal-dialog {
        margin-bottom: calc(var(--app-footer-offset, 120px) + 1rem);
    }
}

/* Estilos para nós de link externo */
.canvas-external-link-node {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(168, 85, 247, 0.12));
    border: 1px solid rgba(139, 92, 246, 0.4);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 25px rgba(139, 92, 246, 0.2);
}

.canvas-external-link-node:hover {
    transform: translate(-50%, -50%) scale(1.08);
    border-color: rgba(139, 92, 246, 0.8);
    box-shadow: 0 12px 35px rgba(139, 92, 246, 0.4);
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.25), rgba(168, 85, 247, 0.2));
}

.canvas-external-link-node .node-type {
    background: rgba(139, 92, 246, 0.2);
    color: #c4b5fd;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.canvas-external-link-node .node-title {
    color: #e9d5ff;
    font-weight: 600;
    font-size: 0.9rem;
}

.canvas-external-link-node .node-subtitle {
    color: rgba(233, 213, 255, 0.7);
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

.canvas-external-link-node .node-status-badge {
    background: rgba(139, 92, 246, 0.15);
    border-color: rgba(139, 92, 246, 0.4);
    color: #c4b5fd;
}

.canvas-external-link-node .node-status-badge.status-up {
    background: rgba(34, 197, 94, 0.2);
    border-color: rgba(34, 197, 94, 0.4);
    color: #bbf7d0;
}

.canvas-external-link-node .node-status-badge.status-down {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
    color: #fecaca;
}

.canvas-external-link-node .node-status-badge.status-degraded {
    background: rgba(245, 158, 11, 0.2);
    border-color: rgba(245, 158, 11, 0.4);
    color: #fde68a;
}

.canvas-external-link-node .node-status-badge.status-unknown {
    background: rgba(148, 163, 184, 0.2);
    border-color: rgba(148, 163, 184, 0.4);
    color: rgba(226, 232, 240, 0.7);
}

.canvas-links .external-link-marker {
    cursor: pointer;
}

.canvas-links .external-link-endpoint {
    pointer-events: visiblePainted;
    filter: drop-shadow(0 6px 15px rgba(15, 23, 42, 0.45));
    transition: transform 0.2s ease, filter 0.2s ease;
}

.canvas-links .external-link-marker:hover .external-link-endpoint {
    transform: scale(1.08);
    filter: drop-shadow(0 10px 20px rgba(15, 23, 42, 0.55));
}

.canvas-links .external-link-label {
    pointer-events: none;
    fill: #e2e8f0;
    font-size: 0.85rem;
    font-weight: 600;
    paint-order: stroke;
    stroke: rgba(15, 23, 42, 0.85);
    stroke-width: 3px;
    stroke-linejoin: round;
    letter-spacing: 0.01em;
}
