/**
 * @package     NVSP.Component
 * @subpackage  com_sloganhunt
 *
 * @copyright   (C) 2025 NVSP. All rights reserved.
 * @license     GNU General Public License version 3 or later
 */

/* ========================================
   NVSP Sloganhunt - Modal Styling
   ======================================== */

/* Color Palette */
:root {
    --modal-overlay-bg: rgba(0, 0, 0, 0.6);
    --modal-bg: #ffffff;
    --modal-header-bg: #003D7A;
    --modal-border: #dee2e6;
    --modal-shadow: rgba(0, 0, 0, 0.3);
}

/* ========================================
   Modal Overlay
   ======================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--modal-overlay-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Click outside to close */
.modal-overlay.clickable {
    cursor: pointer;
}

.modal-overlay.clickable .modal-dialog {
    cursor: default;
}

/* ========================================
   Modal Dialog
   ======================================== */

.modal-dialog {
    background: var(--modal-bg);
    border-radius: 12px;
    box-shadow: 0 10px 40px var(--modal-shadow);
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.9) translateY(-20px);
    transition: transform 0.3s ease;
    position: relative;
    overflow: hidden;
}

.modal-overlay.active .modal-dialog {
    transform: scale(1) translateY(0);
}

/* Modal Sizes */
.modal-dialog.modal-sm {
    max-width: 400px;
}

.modal-dialog.modal-md {
    max-width: 600px;
}

.modal-dialog.modal-lg {
    max-width: 800px;
}

.modal-dialog.modal-xl {
    max-width: 1000px;
}

.modal-dialog.modal-fullscreen {
    max-width: 95vw;
    max-height: 95vh;
    width: 95vw;
    height: 95vh;
}

/* ========================================
   Modal Header
   ======================================== */

.modal-header {
    background: linear-gradient(135deg, var(--modal-header-bg) 0%, #004d99 100%);
    color: white;
    padding: 20px 25px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: none;
    flex-shrink: 0;
}

.modal-header.modal-header-success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
}

.modal-header.modal-header-warning {
    background: linear-gradient(135deg, #ffc107 0%, #ff9800 100%);
    color: #333;
}

.modal-header.modal-header-danger {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
}

.modal-header.modal-header-info {
    background: linear-gradient(135deg, #17a2b8 0%, #138496 100%);
}

.modal-title {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-title-icon {
    font-size: 28px;
}

.modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    line-height: 1;
    transition: background 0.2s, transform 0.2s;
    flex-shrink: 0;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.modal-close:active {
    transform: rotate(90deg) scale(0.9);
}

/* ========================================
   Modal Body
   ======================================== */

.modal-body {
    padding: 30px 25px;
    overflow-y: auto;
    flex: 1;
    color: #333;
}

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

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

.modal-body::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

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

/* Modal Body Content Styles */
.modal-body p {
    line-height: 1.6;
    margin: 0 0 15px 0;
}

.modal-body p:last-child {
    margin-bottom: 0;
}

.modal-body h3 {
    font-size: 18px;
    font-weight: 700;
    color: #003D7A;
    margin: 20px 0 15px 0;
}

.modal-body h3:first-child {
    margin-top: 0;
}

/* ========================================
   Modal Footer
   ======================================== */

.modal-footer {
    padding: 20px 25px;
    border-top: 1px solid var(--modal-border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    flex-shrink: 0;
    background: #f8f9fa;
}

.modal-footer.modal-footer-center {
    justify-content: center;
}

.modal-footer.modal-footer-between {
    justify-content: space-between;
}

/* Modal Footer Buttons */
.modal-footer .btn {
    padding: 10px 24px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-footer .btn-primary {
    background: linear-gradient(135deg, #FF6B35 0%, #F7931E 100%);
    color: white;
}

.modal-footer .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.4);
}

.modal-footer .btn-secondary {
    background: #6c757d;
    color: white;
}

.modal-footer .btn-secondary:hover {
    background: #5a6268;
}

.modal-footer .btn-success {
    background: #28a745;
    color: white;
}

.modal-footer .btn-success:hover {
    background: #218838;
}

.modal-footer .btn-danger {
    background: #dc3545;
    color: white;
}

.modal-footer .btn-danger:hover {
    background: #c82333;
}

/* ========================================
   Letter Found Modal (Special Styling)
   ======================================== */

.modal-letter-found {
    text-align: center;
}

.modal-letter-display {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 120px;
    height: 120px;
    background: linear-gradient(135deg, #FFF5F0 0%, #fff0e6 100%);
    border: 5px solid #FF6B35;
    border-radius: 20px;
    font-size: 72px;
    font-weight: 700;
    color: #FF6B35;
    margin: 20px auto 30px;
    animation: letterBounce 0.6s ease;
    box-shadow: 0 8px 24px rgba(255, 107, 53, 0.3);
}

@keyframes letterBounce {
    0%, 100% { transform: scale(1); }
    25% { transform: scale(1.2) rotate(-5deg); }
    50% { transform: scale(1.3) rotate(5deg); }
    75% { transform: scale(1.2) rotate(-3deg); }
}

.modal-letter-info {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
}

.modal-letter-info p {
    margin: 8px 0;
    font-size: 16px;
}

.modal-letter-info strong {
    color: #003D7A;
}

.modal-progress-display {
    margin-top: 25px;
    padding-top: 25px;
    border-top: 1px solid #dee2e6;
}

.modal-progress-bar {
    background: #e9ecef;
    height: 30px;
    border-radius: 15px;
    overflow: hidden;
    margin-top: 10px;
}

.modal-progress-fill {
    background: linear-gradient(90deg, #28a745 0%, #20c997 100%);
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 14px;
    transition: width 0.8s ease;
}

/* ========================================
   Confirmation Modal
   ======================================== */

.modal-confirmation {
    text-align: center;
}

.modal-confirmation-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.modal-confirmation-icon.warning {
    color: #ffc107;
}

.modal-confirmation-icon.danger {
    color: #dc3545;
}

.modal-confirmation-icon.info {
    color: #17a2b8;
}

.modal-confirmation h3 {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 15px 0;
    color: #333;
}

.modal-confirmation p {
    font-size: 16px;
    color: #666;
    margin: 0 0 25px 0;
}

/* ========================================
   Loading Modal
   ======================================== */

.modal-loading {
    text-align: center;
    padding: 40px 20px;
}

.modal-loading-spinner {
    width: 60px;
    height: 60px;
    border: 6px solid rgba(255, 107, 53, 0.2);
    border-top-color: #FF6B35;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 25px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.modal-loading p {
    font-size: 18px;
    color: #666;
    margin: 0;
}

/* ========================================
   Instructions Modal
   ======================================== */

.modal-instructions ol {
    counter-reset: instruction-counter;
    list-style: none;
    padding: 0;
    margin: 20px 0;
}

.modal-instructions li {
    counter-increment: instruction-counter;
    position: relative;
    padding-left: 50px;
    margin-bottom: 20px;
    line-height: 1.6;
}

.modal-instructions li::before {
    content: counter(instruction-counter);
    position: absolute;
    left: 0;
    top: 0;
    width: 35px;
    height: 35px;
    background: linear-gradient(135deg, #FF6B35 0%, #F7931E 100%);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
}

/* ========================================
   Animation Variants
   ======================================== */

/* Fade In */
.modal-overlay.fade-in .modal-dialog {
    animation: modalFadeIn 0.3s ease;
}

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

/* Slide Up */
.modal-overlay.slide-up .modal-dialog {
    animation: modalSlideUp 0.4s ease;
}

@keyframes modalSlideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

/* Zoom In */
.modal-overlay.zoom-in .modal-dialog {
    animation: modalZoomIn 0.3s ease;
}

@keyframes modalZoomIn {
    from {
        transform: scale(0.7);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 768px) {
    .modal-dialog {
        width: 95%;
        max-height: 85vh;
    }

    .modal-header {
        padding: 15px 20px;
    }

    .modal-title {
        font-size: 18px;
    }

    .modal-body {
        padding: 20px;
    }

    .modal-footer {
        padding: 15px 20px;
        flex-direction: column;
    }

    .modal-footer .btn {
        width: 100%;
    }

    .modal-letter-display {
        width: 100px;
        height: 100px;
        font-size: 60px;
    }
}

@media (max-width: 480px) {
    .modal-dialog {
        width: 98%;
        border-radius: 8px;
    }

    .modal-title {
        font-size: 16px;
    }

    .modal-body {
        padding: 15px;
    }

    .modal-letter-display {
        width: 80px;
        height: 80px;
        font-size: 48px;
    }
}

/* ========================================
   Accessibility
   ======================================== */

.modal-overlay[aria-hidden="true"] {
    display: none;
}

.modal-dialog:focus {
    outline: none;
}

/* Trap focus within modal */
.modal-overlay.active {
    position: fixed;
    inset: 0;
}

/* ========================================
   Print Styles
   ======================================== */

@media print {
    .modal-overlay,
    .modal-dialog {
        display: none !important;
    }
}
