/* Hide scrollbar for modal elements */
.modal, .modal-content, .image-modal, .image-modal-content {
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* Internet Explorer 10+ */
}

.modal::-webkit-scrollbar, .modal-content::-webkit-scrollbar, .image-modal::-webkit-scrollbar, .image-modal-content::-webkit-scrollbar {
    display: none; /* WebKit */
}

/* Modal Base Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    animation: fadeIn 0.3s ease;
    overflow-y: auto;
    padding: 20px;
}

/* Prevent body scroll when modal is open */
body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

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

/* Modal Content */
.modal-content {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: slideInUp 0.4s ease;
    color: var(--text-primary, #ffffff);
    margin: auto;
}

/* Image Modal Specific Styles */
.image-modal-content {
    background: transparent;
    border: none;
    box-shadow: none;
    max-width: 100vw;
    max-height: 100vh;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 9999;
}

.image-modal-content img {
    max-width: 85vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: imageZoomIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: none;
    outline: none;
    display: block;
    margin: 0 auto;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.image-modal-content img:hover {
    transform: scale(1.02);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
}

@keyframes imageZoomIn {
    0% {
        transform: scale(0.3) rotate(-5deg);
        opacity: 0;
        filter: blur(10px);
    }
    50% {
        transform: scale(1.1) rotate(2deg);
        opacity: 0.8;
        filter: blur(2px);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
        filter: blur(0px);
    }
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        backdrop-filter: blur(0px);
    }
    to {
        opacity: 1;
        backdrop-filter: blur(5px);
    }
}

.image-close {
    display: none;
}

.image-close:hover {
    background: rgba(255, 0, 0, 0.8);
    transform: scale(1.1);
    border-color: rgba(255, 255, 255, 0.6);
}

.image-modal {
    animation: modalFadeIn 0.4s ease;
    backdrop-filter: blur(5px);
    background: rgba(0, 0, 0, 0.8);
}

.image-modal.show {
    opacity: 1;
    backdrop-filter: blur(8px);
}

/* Mobile responsive for image modal */
@media (max-width: 768px) {
    .image-modal-content img {
        max-width: 95vw;
        max-height: 85vh;
    }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Modal Header */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px 30px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: sticky;
    top: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
    backdrop-filter: blur(20px);
    border-radius: 20px 20px 0 0;
    z-index: 10;
}

.modal-header h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary, #ffffff);
    background: linear-gradient(45deg, #ffffff, rgba(255, 255, 255, 0.8));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    max-width: 80%;
    line-height: 1.3;
}

.close {
    color: rgba(255, 255, 255, 0.7);
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
}

.close:hover,
.close:focus {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Modal Body */
.modal-body {
    padding: 30px;
}

/* Product Modal Specific Styles */
.modal-image-container {
    margin-bottom: 25px;
}

.main-image {
    width: 100%;
    height: 300px;
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 15px;
    position: relative;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.main-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.main-image:hover img {
    transform: scale(1.05);
}

.image-thumbnails {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 5px 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.image-thumbnails::-webkit-scrollbar {
    height: 6px;
}

.image-thumbnails::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.image-thumbnails::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.image-thumbnails::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

.thumbnail {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    flex-shrink: 0;
    opacity: 0.7;
}

.thumbnail:hover {
    opacity: 1;
    transform: scale(1.05);
    border-color: rgba(255, 255, 255, 0.5);
}

.thumbnail.active {
    opacity: 1;
    border-color: rgba(255, 255, 255, 0.8);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

/* Modal Details */
.modal-details {
    padding-top: 20px;
}

.modal-details p {
    font-size: 16px;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 20px;
}

.modal-price {
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.modal-price .original-price {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.6);
    text-decoration: line-through;
    font-weight: 500;
}

.modal-price .discount-price,
.modal-price .current-price {
    font-size: 24px;
    font-weight: 700;
    color: #ffffff;
    background: linear-gradient(45deg, #4ade80, #22c55e);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.modal-price .free-price {
    font-size: 24px;
    font-weight: 700;
    color: #4ade80;
    background: rgba(74, 222, 128, 0.2);
    padding: 8px 16px;
    border-radius: 25px;
    border: 1px solid rgba(74, 222, 128, 0.3);
    display: inline-block;
}

/* Modal Actions */
.modal-actions {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin-top: 30px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    min-width: 140px;
    justify-content: center;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.btn:hover::before {
    left: 100%;
}

.btn-primary {
    background: var(--secondary-gradient, linear-gradient(135deg, #667eea 0%, #764ba2 100%));
    color: #ffffff;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.4);
    background: var(--primary-gradient, linear-gradient(135deg, #764ba2 0%, #667eea 100%));
}

.btn-secondary {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
    color: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.1) 100%);
    color: #ffffff;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

/* WhatsApp Modal Specific Styles */
.whatsapp-tabs {
    display: flex;
    margin-bottom: 25px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 5px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.tab-btn {
    flex: 1;
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab-btn.active {
    background: var(--secondary-gradient, linear-gradient(135deg, #667eea 0%, #764ba2 100%));
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.tab-btn:hover:not(.active) {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

.tab-content {
    display: none;
    animation: fadeInUp 0.3s ease;
}

.tab-content.active {
    display: block;
}

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

.template-list {
    max-height: 300px;
    overflow-y: auto;
    padding-right: 10px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.template-list::-webkit-scrollbar {
    width: 6px;
}

.template-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.template-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.template-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

.template-item {
    padding: 15px;
    margin-bottom: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.template-item:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.template-item.active {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.3) 0%, rgba(118, 75, 162, 0.3) 100%);
    border-color: rgba(102, 126, 234, 0.5);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.2);
}

.template-item h4 {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
}

.template-item p {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.4;
}

.template-preview {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
    font-style: italic;
    background: rgba(0, 0, 0, 0.2);
    padding: 8px 12px;
    border-radius: 8px;
    border-left: 3px solid rgba(102, 126, 234, 0.5);
}

#customMessage {
    width: 100%;
    min-height: 120px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    color: #ffffff;
    font-size: 16px;
    font-family: inherit;
    resize: vertical;
    outline: none;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

#customMessage:focus {
    border-color: rgba(102, 126, 234, 0.5);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
    background: rgba(255, 255, 255, 0.15);
}

#customMessage::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.message-preview {
    margin: 25px 0;
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.message-preview h4 {
    margin: 0 0 12px 0;
    font-size: 16px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
}

.message-preview div {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Responsive Design */
@media (max-width: 768px) {
    .modal {
        padding: 15px;
    }
    
    .modal-content {
        max-width: 100%;
        max-height: 95vh;
        border-radius: 15px;
    }
    
    .modal-header {
        padding: 20px 25px 15px;
        border-radius: 15px 15px 0 0;
    }
    
    .modal-header h2 {
        font-size: 20px;
        max-width: 75%;
    }
    
    .close {
        width: 35px;
        height: 35px;
        font-size: 28px;
    }
    
    .modal-body {
        padding: 25px;
    }
    
    .main-image {
        height: 250px;
    }
    
    .thumbnail {
        width: 70px;
        height: 70px;
    }
    
    .modal-details p {
        font-size: 15px;
    }
    
    .modal-price .discount-price,
    .modal-price .current-price {
        font-size: 22px;
    }
    
    .modal-price .free-price {
        font-size: 20px;
        padding: 6px 14px;
    }
    
    .modal-actions {
        flex-direction: column;
        gap: 12px;
    }
    
    .btn {
        padding: 14px 20px;
        font-size: 15px;
        min-width: auto;
        width: 100%;
    }
    
    .tab-btn {
        padding: 10px 15px;
        font-size: 15px;
    }
    
    .template-list {
        max-height: 250px;
    }
    
    .template-item {
        padding: 12px;
    }
    
    .template-item h4 {
        font-size: 15px;
    }
    
    .template-item p {
        font-size: 13px;
    }
    
    #customMessage {
        min-height: 100px;
        padding: 12px;
        font-size: 15px;
    }
    
    .message-preview {
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .modal {
        padding: 10px;
    }
    
    .modal-content {
        border-radius: 12px;
    }
    
    .modal-header {
        padding: 15px 20px 12px;
        border-radius: 12px 12px 0 0;
    }
    
    .modal-header h2 {
        font-size: 18px;
        max-width: 70%;
    }
    
    .close {
        width: 32px;
        height: 32px;
        font-size: 24px;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .main-image {
        height: 200px;
        border-radius: 12px;
    }
    
    .thumbnail {
        width: 60px;
        height: 60px;
        border-radius: 8px;
    }
    
    .modal-details p {
        font-size: 14px;
    }
    
    .modal-price .discount-price,
    .modal-price .current-price {
        font-size: 20px;
    }
    
    .modal-price .original-price {
        font-size: 16px;
    }
    
    .modal-price .free-price {
        font-size: 18px;
        padding: 5px 12px;
    }
    
    .btn {
        padding: 12px 18px;
        font-size: 14px;
        border-radius: 20px;
    }
    
    .tab-btn {
        padding: 8px 12px;
        font-size: 14px;
    }
    
    .template-item {
        padding: 10px;
    }
    
    .template-item h4 {
        font-size: 14px;
    }
    
    .template-item p {
        font-size: 12px;
    }
    
    .template-preview {
        font-size: 12px;
        padding: 6px 10px;
    }
    
    #customMessage {
        min-height: 80px;
        padding: 10px;
        font-size: 14px;
    }
    
    .message-preview {
        padding: 12px;
    }
    
    .message-preview h4 {
        font-size: 15px;
    }
    
    .message-preview div {
        font-size: 13px;
    }
}

/* Loading States */
.modal-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: rgba(255, 255, 255, 0.7);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error States */
.modal-error {
    padding: 20px;
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 12px;
    color: #fca5a5;
    text-align: center;
    margin: 20px 0;
}

/* Success States */
.modal-success {
    padding: 20px;
    background: rgba(34, 197, 94, 0.2);
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: 12px;
    color: #86efac;
    text-align: center;
    margin: 20px 0;
}

/* Accessibility */
.modal:focus-within {
    outline: none;
}

.btn:focus,
.tab-btn:focus,
.template-item:focus,
#customMessage:focus {
    outline: 2px solid rgba(102, 126, 234, 0.5);
    outline-offset: 2px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .modal-content {
        border: 2px solid #ffffff;
        background: rgba(0, 0, 0, 0.9);
    }
    
    .btn {
        border: 2px solid currentColor;
    }
    
    .template-item {
        border: 1px solid rgba(255, 255, 255, 0.5);
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .modal,
    .modal-content,
    .tab-content,
    .btn,
    .template-item,
    .thumbnail {
        animation: none !important;
        transition: none !important;
    }
}