/* ====================================
   Modal Components
   ==================================== */

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: 16px;
    box-sizing: border-box;
}

.modal-overlay.active {
    display: flex;
}

/* Modal Container */
.modal-container {
    background: var(--bg-primary);
    border-radius: 20px;
    padding: 0;
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: var(--shadow-floating);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.modal-overlay,
.modal-container {
    animation: none !important;
}

.modal-container .btn,
.modal-close,
.reset-option {
    transform: none !important;
}

/* Modal Header */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid var(--border-primary);
    background: var(--bg-primary);
}

.modal-header h3 {
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    min-width: 0;
    overflow-wrap: anywhere;
}

.modal-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 24px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-raised);
    line-height: 1;
    padding: 0;
}

.modal-close:hover {
    color: var(--color-hover);
    box-shadow: var(--shadow-raised-hover);
}

/* Modal Body */
.modal-body {
    padding: 20px 25px;
    overflow-y: auto;
    flex: 1;
    min-width: 0;
}

.modal-body textarea {
    width: 100%;
    min-height: 150px;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--border-primary);
    background: var(--bg-body);
    color: var(--text-primary);
    resize: vertical;
    font-family: inherit;
    margin-top: 10px;
}

/* Modal Stats */
.modal-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: 10px;
    box-shadow: var(--shadow-inset);
}

.modal-progress {
    color: var(--text-accent);
    font-weight: 600;
    font-size: 14px;
}

.modal-valid-count {
    color: var(--color-success);
    font-weight: 600;
    font-size: 14px;
}

.modal-count {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 14px;
}

/* Modal Footer */
.modal-footer {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 20px 25px;
    border-top: 1px solid var(--border-primary);
    background: var(--bg-primary);
    flex-wrap: wrap;
}

.modal-btn {
    padding: 10px 20px;
    min-width: 120px;
}

.modal-btn.primary {
    background: linear-gradient(135deg, #E040FB, #9C27B0);
    color: white;
}

.modal-btn.danger {
    background: #ef4444;
    color: #ffffff;
    border-color: #ef4444;
}

.modal-btn.danger:hover {
    background: #dc2626;
    border-color: #dc2626;
}

.reset-modal {
    max-width: 360px;
    border: 1px solid var(--border-primary);
    box-shadow: var(--shadow-floating);
}

.reset-modal .modal-header h3 {
    color: var(--color-danger);
}

.reset-modal .modal-body {
    padding: 18px 25px 0;
}

.reset-modal .modal-footer {
    border-top: none;
    padding-top: 16px;
}

.reset-note {
    margin: 0 0 14px;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 700;
    text-align: center;
}

.reset-options {
    display: grid;
    gap: 10px;
    margin: 0 auto;
    max-width: 240px;
    text-align: left;
}

.reset-option {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: var(--shadow-inset-field);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    outline: none;
    border-bottom-color: var(--border-primary) !important;
}

.reset-option:hover {
    box-shadow: var(--shadow-inset-field);
}

.modal-container .btn:hover,
.modal-container .btn:active,
.modal-close:hover,
.modal-close:active,
.reset-option:hover,
.reset-option:active {
    transform: none !important;
}

.reset-option input {
    width: 16px;
    height: 16px;
    margin: 0;
    appearance: none;
    -webkit-appearance: none;
    border: 2px solid var(--text-accent);
    border-radius: 4px;
    background: var(--bg-secondary);
    box-shadow: none;
    outline: none;
    display: grid;
    place-content: center;
}

.reset-option input:checked {
    background: var(--bg-secondary);
    border-color: var(--color-danger);
}

.reset-option input:checked::before {
    content: "✓";
    color: var(--color-danger);
    font-size: 12px;
    font-weight: 900;
    line-height: 1;
}

.reset-option input:focus,
.reset-option input:focus-visible,
.reset-option:focus,
.reset-option:focus-within {
    outline: none !important;
    box-shadow: none !important;
}

/* QR Popup */
#qrPopup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 99999;
}

#qrPopupBox {
    background: var(--bg-primary);
    border-radius: 20px;
    padding: 30px;
    box-shadow: var(--shadow-raised);
    text-align: center;
    border: none;
}

#qrPopupImg {
    width: 300px;
    height: 300px;
    border-radius: 12px;
    border: 4px solid var(--bg-secondary);
    box-shadow: var(--shadow-inset);
    padding: 10px;
    background: white;
}

#qrPopupText {
    color: var(--text-accent);
    margin-top: 25px;
    font-size: 16px;
    font-weight: 700;
    text-shadow: none;
    background: var(--bg-primary);
    padding: 12px 30px;
    border-radius: 50px;
    box-shadow: var(--shadow-inset);
    display: inline-block;
    letter-spacing: 1px;
}
