/* modals-core.css - Generic modal architecture, overlays, and common dialog buttons */

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

.modal-overlay.hidden {
    display: none !important;
}

.modal-overlay .modal {
    position: relative;
    top: auto;
    left: auto;
    width: min(420px, 90vw);
    max-height: 85vh;
    height: auto;
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 12px 18px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.35);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

#duplicate-config-modal .modal {
    width: min(420px, 80vw);
    padding: 12px 18px 16px;
    gap: 12px;
    max-height: 90vh; /* Increased from 85vh to make it taller */
}

.duplicate-modal {
    padding-top: 32px;
}

.duplicate-modal .modal-body {
    gap: 12px;
}

/* Modal Content Container */
.modal-content {
    background: var(--bg-secondary);
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-color);
    
    /* Keep the Desktop Width */
    width: 900px;
    max-width: 95vw;
    
    /* --- REVERT TO SHRINK-WRAP --- */
    /* Was: height: 85vh; */
    height: auto;       /* Allow it to shrink for short lists */
    max-height: 85vh;   /* Cap it so it scrolls on long lists */
    
    /* Layout */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin: auto;
}

/* 1. The Container: Add the Arcane Glow (Duplicate Modal) */
#duplicate-config-modal .modal-content {
    border: 1px solid rgba(139, 92, 246, 0.3) !important; /* Purple border */
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 
                0 0 20px rgba(139, 92, 246, 0.15) !important; /* Purple glow */
    overflow: hidden; /* Ensure header background doesn't bleed */
}

/* 2. The Header: Add a subtle gradient background */
#duplicate-config-modal .modal-header {
    background: linear-gradient(to right, rgba(139, 92, 246, 0.1), transparent) !important;
    border-bottom: 1px solid rgba(139, 92, 246, 0.2) !important;
    padding-top: 20px;
    padding-bottom: 20px;
}

#duplicate-config-modal .modal-title {
    font-size: 1.25rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
}

/* 3. The Inputs: Focus States */
#duplicate-config-modal input[type="text"]:focus {
    border-color: #8b5cf6 !important; /* Violet-500 */
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25) !important;
}

/* 4. The Radio Buttons: Make them pop */
#duplicate-config-modal label {
    transition: color 0.2s ease;
}

#duplicate-config-modal label:hover {
    color: var(--accent);
}

/* 5. The Create Button: Gradient */
#duplicate-confirm-btn {
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%) !important;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

#duplicate-confirm-btn:hover {
    box-shadow: 0 6px 16px rgba(124, 58, 237, 0.5) !important;
    transform: translateY(-1px);
}

/* Modal Header */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    border-radius: 12px 12px 0 0;
    gap: 16px;
    flex-shrink: 0;
}

/* Left side: Title + Badge */
.modal-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.modal-title {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.25rem; /* text-xl */
    font-weight: 700; /* font-bold */
}

.modal-overlay .modal-title {
    margin: 0 0 8px;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Right side: Action Bar */
.modal-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.modal-action-btn {
    background: transparent;
    border: 0;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.modal-action-btn.delete-btn {
    color: #f87171; /* text-red-400 */
}

.modal-action-btn.delete-btn:hover {
    background: rgba(239, 68, 68, 0.1); /* hover:bg-red-500/10 */
}

.modal-action-btn.duplicate-btn {
    color: #94a3b8; /* text-slate-400 - Ghost button, slate text */
}

.modal-action-btn.duplicate-btn:hover {
    color: #ffffff; /* hover:text-white */
    background: rgba(148, 163, 184, 0.1);
}

.modal-action-btn.save-btn {
    background: #9333ea; /* bg-purple-600 - Solid Brand Color */
    color: #ffffff; /* text-white */
    font-weight: 500; /* font-medium */
    padding: 6px 16px; /* px-4 py-1.5 - Wide pill shape */
    border-radius: 6px; /* rounded-md */
}

.modal-action-btn.save-btn:hover {
    background: #a855f7; /* hover:bg-purple-500 */
}

.modal-action-separator {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 4px;
}

/* Modal Close Buttons */
.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    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(--bg-primary);
    color: var(--text-primary);
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px 10px;
    margin-left: auto;
    border-radius: 50%;
    transition: color 0.2s ease, background 0.2s ease;
}

.modal-close-btn:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.1);
}

.modal-close-btn.floating {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 2px 8px;
}

/* Modal Body */
.modal-body {
    padding: 24px;
    overflow-y: auto;
    /* Remove 'flex: 1' if it's there, so it doesn't force expansion */
}

.modal-overlay .modal-body {
    overflow-y: auto;
    /* Removed flex: 1 1 auto to prevent forced expansion */
}

.modal-body {
    margin: 8px 0 12px 0;
}

/* Modal Footer */
.modal-overlay .modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 12px;
}

/* Modal Buttons */
.modal-btn {
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 10px 20px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.modal-btn.ghost {
    background: rgba(148, 163, 184, 0.12);
    color: var(--text-primary);
    border: 1px solid rgba(148, 163, 184, 0.4);
}

.modal-btn.ghost:hover {
    background: rgba(148, 163, 184, 0.2);
}

.modal-btn.primary {
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    color: #fff;
    box-shadow: 0 8px 18px rgba(99, 102, 241, 0.35);
}

.modal-btn.primary:hover {
    background: linear-gradient(135deg, #7c3aed 0%, #4c1d95 100%);
}

/* Modal Inputs */
.modal-label {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 4px;
    color: var(--text-secondary);
}

.modal-input {
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 12px;
    border-radius: 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.modal-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 4px var(--accent-alpha);
}

.modal-radio-group {
    margin-bottom: 12px;
}

.modal-radio-group label {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 4px;
    cursor: pointer;
}

/* === Arcane Delete Modal (Matches Settings / Breakdown Modals) === */
.arcane-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    padding: 20px;
    backdrop-filter: blur(6px);
}

.arcane-modal[hidden] {
    display: none;
}

.arcane-modal-content {
    background: var(--bg-secondary);
    border-radius: 14px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.45);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.arcane-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-tertiary);
    padding: 18px 22px;
    border-bottom: 1px solid var(--border-color);
}

.arcane-modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--text-primary);
}

.arcane-modal-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--text-secondary);
}

.arcane-modal-close:hover {
    color: var(--text-primary);
}

.arcane-modal-body {
    padding: 22px;
    font-size: 1rem;
    color: var(--text-primary);
}

.arcane-modal-footer {
    padding: 16px 22px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

/* Subtle arcane danger button (non-neon) */
.arcane-danger {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

.arcane-danger:hover {
    background: rgba(239, 68, 68, 0.25);
}

/* --- Light Mode Refinements for Core Modals --- */

/* Fix "Floating Emoji" Buttons */
[data-theme="light"] .modal-header-right .modal-action-btn {
    background-color: #f3f4f6; /* Light gray background to define the button area */
    border: 1px solid #d1d5db; /* Subtle border to define the edges */
    color: #374151; /* Dark icon color */
    box-shadow: 0 1px 2px rgba(0,0,0,0.05); /* Tiny shadow for depth */
}

/* Keep the Save button distinct (Purple) */
[data-theme="light"] .modal-header-right .modal-action-btn.save-btn {
    background-color: #8b5cf6; /* Keep your purple brand color */
    color: white;
    border: 1px solid #7c3aed;
}

[data-theme="light"] .modal-header-right .modal-action-btn:hover {
    background-color: #e5e7eb; /* Darker gray on hover */
}

[data-theme="light"] .modal-header-right .modal-action-btn.save-btn:hover {
    background-color: #7c3aed; /* Darker purple on hover */
}

/* --- UI Polish: Header Buttons (Dark Mode) --- */
/* Gives shape to the Delete/Duplicate/Close buttons in Dark Mode */
[data-theme="dark"] .modal-header-right .modal-action-btn,
[data-theme="dark"] .modal-close {
    background-color: rgba(255, 255, 255, 0.05); /* Subtle container */
    border: 1px solid rgba(255, 255, 255, 0.1);  /* Definition */
    color: #cbd5e1;
    border-radius: 6px;
    transition: all 0.2s ease;
}

[data-theme="dark"] .modal-header-right .modal-action-btn:hover,
[data-theme="dark"] .modal-close:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.2);
}

/* Ensure Save button keeps its purple identity */
[data-theme="dark"] .modal-header-right .modal-action-btn.save-btn {
    background-color: #9333ea;
    border-color: #9333ea;
    color: white;
}

[data-theme="dark"] .modal-header-right .modal-action-btn.save-btn:hover {
    background-color: #a855f7;
}

/* Responsive adjustments for modals */
@media (max-width: 1000px) {
    .modal-content {
        width: 95vw;        /* Allow it to shrink on smaller screens */
        max-width: 900px;    /* But never exceed desktop width */
        max-height: 95vh;
    }
}

@media (max-width: 768px) {
    .modal-header {
        padding: 16px 20px;
    }
    
    .modal-header h3 {
        font-size: 1.1rem;
    }
    
    .modal-body {
        padding: 20px;
    }
}

