/* ============================================
   MODALS — Overlays, Agent Modal, Task Modal
   ============================================ */

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.agent-modal {
    background: var(--bg-card);
    width: 600px;
    max-width: 90vw;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transform: translateY(20px);
    transition: transform 0.2s;
}

.modal-overlay.active .agent-modal {
    transform: translateY(0);
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.modal-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    font-size: 24px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.modal-title h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}

.modal-title p {
    font-size: 13px;
    color: var(--text-secondary);
}

.btn-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
}

.modal-body {
    padding: 24px;
    display: grid;
    gap: 24px;
}

.section-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 12px;
    text-transform: uppercase;
}

.soul-card {
    background: var(--bg-main);
    padding: 16px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

.memory-block {
    font-family: monospace;
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 16px;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
}

.memory-key {
    color: #569cd6;
}

.memory-val {
    color: #ce9178;
}

.memory-com {
    color: #6a9955;
}
/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: auto;
    z-index: 1001;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--tag-bg);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}
/* Fix modal overlay to cover everything */
.modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 9999 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.75) !important;
    backdrop-filter: blur(8px) !important;
    z-index: 9999 !important;
}

.modal-content {
    position: relative !important;
    background: var(--bg-card) !important;
    border-radius: 12px !important;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5) !important;
    width: 90% !important;
    max-width: 500px !important;
    max-height: 85vh !important;
    overflow-y: auto !important;
    z-index: 10000 !important;
    animation: modalSlideIn 0.3s ease !important;
}

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

/* Ensure modal content is readable in both themes */
[data-theme="dark"] .modal-content {
    background: #1a1a2e !important;
}

[data-theme="light"] .modal-content,
:root:not([data-theme]) .modal-content {
    background: #ffffff !important;
}

/* Hide modal when not active */
.modal[style*="display: none"],
.modal[style*="display:none"] {
    display: none !important;
}

/* Show modal overlay properly when active */
.modal[style*="display: flex"],
.modal[style*="display:flex"] {
    display: flex !important;
}
