/* Uniformiza los botones en grids de 4 para que el texto se adapte y no desborde */
.card-actions.four-btn-grid .dashboard-btn {
    width: 100%;
    min-width: 0;
    white-space: normal;
    text-overflow: ellipsis;
    overflow: hidden;
    text-align: center;
    word-break: break-word;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}
/* Opcional: limitar a 2 líneas y elipsis si el texto es muy largo (solo navegadores modernos) */
.card-actions.four-btn-grid .dashboard-btn {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
/* === Estilos para modales de resultados (migrados de styles.css) === */
.modal-result {
    font-size: 0.9rem;
    line-height: 1.6;
}

.modal-result.success {
    border-left: 4px solid #28a745;
}

.modal-result.warning {
    border-left: 4px solid #ffc107;
}

.modal-result.error {
    border-left: 4px solid #dc3545;
}

.modal-result.development {
    border-left: 4px solid #6f42c1;
}

.modal-result.loading {
    border-left: 4px solid #007bff;
}
/* Bloques migrados de styles.css relacionados con modales. */

/* Estilos para modales - Consistente con el diseño del proyecto */
.modal {
    display: flex; /* visible by default; hidden via .hidden */
    align-items: center;
    justify-content: center;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
    animation: fadeIn 0.3s ease-in-out;
}

.modal-content {
    background-color: #220F17;
    margin: auto;
    padding: 30px;
    border: none;
    border-radius: 15px;
    width: 80%;
    max-width: 600px;
    min-width: 320px;
    box-shadow: 0 8px 32px rgba(247, 147, 26, 0.3);
    position: relative;
    animation: slideIn 0.3s ease-out;
    backdrop-filter: blur(10px);
    color: #ffffff;
}

.modal-content h2 {
    color: #FFC48C;
    text-align: center;
    margin-bottom: 20px;
    border-bottom: none;
    padding-bottom: 10px;
}

.close {
    color: #FFC48C;
    float: right;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    top: 8px;
    right: 8px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
    background-color: rgba(255, 196, 140, 0.12);
}

.close:hover,
.close:focus {
    color: #fff;
    background-color: #6B0F0F;
    transform: scale(1.1);
    text-decoration: none;
}

/* Animaciones para los modales */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { 
        transform: translateY(-50px);
        opacity: 0;
    }
    to { 
        transform: translateY(0);
        opacity: 1;
    }
}

/* Estilos para formularios dentro de modales */
.modal-content input,
.modal-content select,
.modal-content textarea {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

/* Dedicated style for the passphrase input shown via modal */
#passphraseModalInput {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: 2px solid #ddd;
    background: #fff;
    color: #222;
    font-size: 16px;
    box-sizing: border-box;
}

#passphraseModalInput::placeholder {
    color: #6c757d;
    opacity: 0.9;
}

.modal-content input:focus,
.modal-content select:focus,
.modal-content textarea:focus {
    border-color: #FFC48C;
    outline: none;
    box-shadow: 0 0 8px rgba(255, 196, 140, 0.25);
}

.modal-content button {
    width: 100%;
    margin-top: 10px;
    font-size: 16px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Contenido específico de modales */
.modal-body {
    max-height: 70vh;
    overflow-y: auto;
    margin-top: 20px;
    color: #e9e3e3;
}

.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: #6B0F0F;
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: #8B1E3F;
}

/* Estilo para información en modales */
.modal-info {
    background-color: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 196, 140, 0.25);
    border-radius: 8px;
    padding: 15px;
    margin: 10px 0;
    word-break: break-all;
    color: #ffffff;
}

/* Monitor modal content helpers */
.monitor-card {
    background: #2F1D25;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    border: 1px solid rgba(255, 196, 140, 0.25);
}
.monitor-title { color: #FFC48C; margin-top: 0; }
.monitor-list { color: #ffffff; margin: 0; padding-left: 20px; }
.monitor-link { color: #63b3ed; }
.status-online { color: #48bb78; }
.status-standalone { color: #ed8936; }
.monitor-sublist { list-style: none; margin-left: 8px; }
.monitor-subitems { margin: 6px 0 0 12px; color: #cfe8de; }
.modal-actions { text-align: center; margin-top: 20px; }

.modal-info p {
    margin: 5px 0;
    line-height: 1.4;
}

.modal-info strong {
    color: #FFC48C;
}

/* Estilos para botones dentro de modales que siguen el tema del proyecto */
.modal-content button {
    background-color: #f7931a;
    border: none;
    color: white;
    padding: 12px 24px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 14px;
    margin: 8px 4px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    min-width: 120px;
}

.modal-content button:hover {
    background-color: #6B0F0F;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(107, 15, 15, 0.4);
}

.modal-content button:active {
    transform: translateY(0);
}

/* Botones de acción específicos */
.modal-content button[type="submit"] {
    background-color: #28a745;
    width: 100%;
    margin-top: 15px;
    padding: 15px;
    font-size: 16px;
}

.modal-content button[type="submit"]:hover {
    background-color: #218838;
}

.modal-content button.cancel-btn {
    background-color: #dc3545;
}

.modal-content button.cancel-btn:hover {
    background-color: #c82333;
}

/* Mejoras para elementos de lista en modales */
.modal-content ul {
    list-style-type: none;
    padding: 0;
}

.modal-content li {
    background-color: rgba(247, 147, 26, 0.05);
    border: 1px solid rgba(247, 147, 26, 0.2);
    border-radius: 6px;
    padding: 10px;
    margin: 8px 0;
    word-break: break-all;
}

/* Mejoras para código y elementos pre */
.modal-content pre,
.modal-content code {
    background-color: #220F17;
    color: #ffffff;
    border-radius: 6px;
    padding: 12px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.4;
    overflow-x: auto;
    border: 1px solid rgba(255, 196, 140, 0.35);
}

/* JSON/pre blocks that use a light background should explicitly set dark text */
.json-display,
.json-display pre {
    background: #2F1D25 !important;
    color: #ffffff;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid rgba(255, 196, 140, 0.35);
    overflow-x: auto;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.4;
}

/* Transaction item styles */
.tx-item { list-style: none; }
.tx-label { color: #333; font-weight: 700; }
.tx-id {
    color: #fff !important;
    background: #3A2324 !important;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    word-break: break-all;
}
.tx-copy-btn { padding: 6px 10px; font-size: 0.9rem; }

.modal-content code {
    padding: 2px 6px;
    display: inline;
}

/* Estados de carga para modales */
.modal-loading {
    text-align: center;
    padding: 20px;
}

.modal-loading::after {
    content: "⏳";
    font-size: 24px;
    animation: spin 2s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 🎉 Estilos para modal de éxito */
.modal-success {
    text-align: center;
    padding: 20px;
}

.success-icon {
    font-size: 48px;
    margin-bottom: 15px;
    animation: bounceIn 0.6s ease;
}

@keyframes bounceIn {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.05); }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); opacity: 1; }
}

.modal-success h3 {
    color: #28a745;
    margin: 10px 0;
    font-weight: 600;
}

.modal-success p {
    color: #2d3748;
    margin: 8px 0;
    font-weight: 500;
}

.modal-success strong {
    color: #1a202c;
    font-weight: 600;
}

.modal-success code {
    background: #2d3748;
    color: #e2e8f0;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    font-weight: 500;
}

.status-success {
    color: #28a745;
    font-weight: bold;
    background: #d4edda;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
}

.modal-details {
    margin-top: 15px;
    border-top: 1px solid #dee2e6;
    padding-top: 15px;
}

.modal-details summary {
    cursor: pointer;
    color: #007bff;
    font-size: 14px;
    margin-bottom: 10px;
}

.json-display {
    background: #2d3748;
    color: #e2e8f0;
    padding: 12px;
    border-radius: 6px;
    font-size: 11px;
    overflow-x: auto;
    max-height: 300px;
    white-space: pre-wrap;      /* Permite saltos de línea automáticos */
    word-break: break-all;      /* Rompe palabras largas */
    overflow-wrap: anywhere;    /* Rompe donde sea necesario */
}

/* Ajuste específico para transacciones dentro de modales */
.modal-content .transaction,
.modal-content .transaction-modal-item,
.modal-content .monitor-card {
    max-width: calc(100% - 20px);
    margin: 8px auto;
    overflow: hidden;
}

/* Responsive para el modal QR */
@media (max-width: 768px) {
    .qr-container {
        flex-direction: column;
        text-align: center;
    }
    .qr-info {
        min-width: 100%;
    }
    .qr-actions {
        flex-direction: column;
        align-items: center;
    }
    .qr-actions .dashboard-btn {
        width: 100%;
        max-width: 250px;
    }
}

/* Eliminar scroll horizontal en el modal de wallet */
#walletModalBody, .modal-body {
  overflow-x: hidden !important;
  max-width: 100%;
  box-sizing: border-box;
}

/* Utilidad global: romper palabras muy largas (hex, hashes, pubkeys) para evitar overflow en modales */
.break-anywhere,
.modal .modal-content,
.modal .modal-content * {
    overflow-wrap: anywhere;
    word-break: break-word;
    line-break: anywhere;
}

.modal-content, .modal-content * {
  word-break: normal;
  overflow-wrap: break-word;
  hyphens: auto;
}

@media (max-width: 600px) {
  .modal-content, .modal-content * {
    word-break: normal;
    overflow-wrap: break-word;
    hyphens: auto;
  }
}
