/* =============================================
   WAVE DETAIL MODAL - Enhanced Edition
   Wider, more attractive, with inline editing
   ============================================= */

/* Modal overlay */
.wave-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Modal container */
.wave-detail-modal {
    background: white;
    border-radius: 20px;
    width: 100%;
    max-width: 900px;
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: slideUp 0.3s ease;
    overflow: hidden;
}

@keyframes slideUp {
    from { 
        opacity: 0; 
        transform: translateY(20px) scale(0.98);
    }
    to { 
        opacity: 1; 
        transform: translateY(0) scale(1);
    }
}

/* Modal header with gradient */
.wave-modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 24px 28px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.wave-modal-title-group { display: flex; flex-direction: column; gap: 8px; }
.wave-modal-title { margin: 0; font-size: 1.75rem; font-weight: 700; display: flex; align-items: center; gap: 12px; }
.wave-modal-subtitle { font-size: 0.9rem; opacity: 0.9; display: flex; gap: 16px; flex-wrap: wrap; }
.wave-modal-subtitle span { display: inline-flex; align-items: center; gap: 6px; }

.wave-modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5rem;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}
.wave-modal-close:hover { background: rgba(255, 255, 255, 0.3); }

/* Cap indicators section */
.wave-modal-caps {
    background: #f8fafc;
    padding: 20px 28px;
    border-bottom: 1px solid #e2e8f0;
}
.caps-title { margin: 0 0 16px; font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: #64748b; }
.caps-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

.cap-item {
    background: white;
    border-radius: 12px;
    padding: 14px 16px;
    border: 1px solid #e2e8f0;
}
.cap-item-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.cap-item-label { font-size: 0.8rem; font-weight: 600; color: #475569; }
.cap-item-value { font-size: 0.85rem; font-weight: 700; }
.cap-item-value .current { color: #1e293b; }
.cap-item-value .separator { color: #94a3b8; margin: 0 2px; }
.cap-item-value .cap { color: #64748b; }
.cap-item-bar { height: 8px; background: #e2e8f0; border-radius: 4px; overflow: hidden; }
.cap-item-fill { height: 100%; border-radius: 4px; transition: width 0.4s ease; }
.cap-item-fill.safe { background: linear-gradient(90deg, #22c55e 0%, #4ade80 100%); }
.cap-item-fill.warning { background: linear-gradient(90deg, #eab308 0%, #facc15 100%); }
.cap-item-fill.danger { background: linear-gradient(90deg, #ef4444 0%, #f87171 100%); }
.cap-item-fill.over { background: linear-gradient(90deg, #dc2626 0%, #b91c1c 100%); }

.cap-status-badge {
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
}
.cap-status-badge.ok { background: #dcfce7; color: #166534; }
.cap-status-badge.warn { background: #fef9c3; color: #854d0e; }
.cap-status-badge.over { background: #fee2e2; color: #991b1b; }

/* Modal body - applications table */
.wave-modal-body { flex: 1; overflow-y: auto; padding: 0; }
.apps-table-container { min-height: 200px; }
.apps-table { width: 100%; border-collapse: collapse; }
.apps-table thead { position: sticky; top: 0; z-index: 10; }
.apps-table thead th {
    background: #f8fafc;
    padding: 14px 16px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
    border-bottom: 2px solid #e2e8f0;
}
.apps-table thead th:first-child { padding-left: 28px; }
.apps-table thead th:last-child { padding-right: 28px; }
.apps-table tbody tr { border-bottom: 1px solid #f1f5f9; transition: background 0.1s ease; }
.apps-table tbody tr:hover { background: #f8fafc; }
.apps-table tbody td { padding: 14px 16px; vertical-align: middle; }
.apps-table tbody td:first-child { padding-left: 28px; }
.apps-table tbody td:last-child { padding-right: 28px; }

/* Application name cell - IMPORTANT: Show full name */
.app-name-cell { max-width: 300px; }
.app-name-full { font-weight: 600; color: #1e293b; font-size: 0.9rem; line-height: 1.4; word-break: break-word; }
.app-id { font-size: 0.75rem; color: #94a3b8; margin-top: 2px; font-family: monospace; }

/* Editable select/input fields */
.edit-field {
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.85rem;
    background: white;
    transition: all 0.15s ease;
    width: 100%;
    max-width: 130px;
}
.edit-field:hover { border-color: #cbd5e1; }
.edit-field:focus { outline: none; border-color: #667eea; box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15); }
.edit-field.changed { border-color: #f59e0b; background: #fffbeb; }

.move-wave-select { min-width: 110px; }

/* Points display */
.points-display {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 32px;
    padding: 0 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 700;
}

.points-display.recalculated {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    animation: bounce 0.3s ease;
}

@keyframes bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Modal footer */
.wave-modal-footer {
    background: #f8fafc;
    padding: 16px 28px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.footer-info { font-size: 0.85rem; color: #64748b; }
.footer-info.has-changes { color: #d97706; font-weight: 600; }
.footer-actions { display: flex; gap: 12px; }

.btn-modal {
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.btn-modal.secondary { background: white; border: 1px solid #e2e8f0; color: #475569; }
.btn-modal.secondary:hover { background: #f1f5f9; border-color: #cbd5e1; }
.btn-modal.primary { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); border: none; color: white; }
.btn-modal.primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4); }

/* Drag and drop styles */
.wave-app-chip { cursor: grab; transition: all 0.15s ease; }
.wave-app-chip:active { cursor: grabbing; }
.wave-app-chip.dragging { opacity: 0.5; transform: scale(0.95); }
.wave-card.drag-over { border: 2px dashed #667eea; background: rgba(102, 126, 234, 0.05); }

/* Responsive */
@media (max-width: 900px) {
    .wave-detail-modal {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .caps-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .apps-table {
        font-size: 0.85rem;
    }
    
    .app-name-cell {
        max-width: 200px;
    }
}

@media (max-width: 768px) {
    .wave-detail-modal { max-width: 100%; border-radius: 0; max-height: 100vh; }
    .caps-grid { grid-template-columns: repeat(2, 1fr); }
    .wave-modal-footer { flex-direction: column; gap: 12px; }
    .footer-actions { width: 100%; justify-content: stretch; }
    .btn-modal { flex: 1; justify-content: center; }
}

@media (max-width: 600px) {
    .wave-modal-header {
        padding: 16px 20px;
    }
    
    .wave-modal-title {
        font-size: 1.25rem;
    }
    
    .caps-grid {
        grid-template-columns: 1fr;
    }
    
    .wave-modal-footer {
        flex-direction: column;
        gap: 12px;
    }
    
    .footer-actions {
        width: 100%;
        justify-content: stretch;
    }
    
    .btn-modal {
        flex: 1;
        justify-content: center;
    }
}
