/**
 * Sidebar Announcements Popup Styles
 * Responsive RTL-ready sidebar popup
 */

/* Reset and base styles */
.sap-sidebar,
.sap-toggle,
.sap-overlay {
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Overlay */
.sap-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 999998;
}

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

/* Sidebar */
.sap-sidebar {
    position: fixed;
    top: 0;
    width: 350px;
    max-width: 90vw;
    height: 100%;
    background-color: #ffffff;
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.15);
    z-index: 999999;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sap-sidebar.sap-position-right {
    right: 0;
    transform: translateX(100%);
}

.sap-sidebar.sap-position-left {
    left: 0;
    transform: translateX(-100%);
}

.sap-sidebar.active {
    transform: translateX(0);
}

/* Header */
.sap-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    color: #ffffff;
    flex-shrink: 0;
}

.sap-title {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.sap-close {
    background: none;
    border: none;
    color: #ffffff;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
    margin-right: -8px;
}

.sap-close:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.sap-close svg {
    width: 24px;
    height: 24px;
}

/* Content area */
.sap-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

/* Announcement items */
.sap-announcement {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    background-color: #ffffff;
    transition: background-color 0.2s ease;
}

.sap-announcement:hover {
    background-color: #fafafa;
}

.sap-announcement:last-child {
    border-bottom: none;
}

.sap-announcement-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 10px 0;
    line-height: 1.4;
}

.sap-announcement-content {
    font-size: 14px;
    color: #555555;
    line-height: 1.6;
    margin-bottom: 12px;
}

.sap-announcement-content p {
    margin: 0 0 10px 0;
}

.sap-announcement-content p:last-child {
    margin-bottom: 0;
}

.sap-announcement-link {
    display: inline-block;
    font-size: 13px;
    font-weight: 500;
    text-decoration: underline;
    margin-bottom: 10px;
    transition: opacity 0.2s ease;
}

.sap-announcement-link:hover {
    opacity: 0.7;
}

.sap-announcement-date {
    font-size: 12px;
    font-weight: 500;
}

/* Video container styles */
.sap-video-container {
    position: relative;
    width: 100%;
    margin: 12px 0;
    border-radius: 8px;
    overflow: hidden;
    background-color: #000;
}

/* YouTube container - 16:9 aspect ratio */
.sap-youtube-container {
    padding-top: 56.25%; /* 16:9 aspect ratio */
}

.sap-video-iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 8px;
}

/* TikTok specific styles - taller for vertical videos */
.sap-tiktok-container {
    position: relative;
    background-color: #000;
    padding-top: 0;
    height: auto;
    min-height: 500px;
}

.sap-tiktok-iframe {
    position: relative;
    width: 100%;
    height: 500px;
    border: none;
    border-radius: 8px;
}

/* MP4 video styles */
.sap-mp4-container {
    padding-top: 0;
    background-color: #000;
}

.sap-video-mp4 {
    width: 100%;
    height: auto;
    max-height: 400px;
    border-radius: 8px;
    display: block;
}

/* Video loading placeholder */
.sap-video-container.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: sap-spin 1s linear infinite;
}

@keyframes sap-spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* WooCommerce Products Styles */
.sap-products-container {
    margin: 15px 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sap-product-card {
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.sap-product-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.sap-product-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: inherit;
    padding: 10px;
    gap: 12px;
}

.sap-product-image {
    flex-shrink: 0;
    width: 70px;
    height: 70px;
    border-radius: 6px;
    overflow: hidden;
    background: #fff;
}

.sap-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sap-product-info {
    flex: 1;
    min-width: 0;
}

.sap-product-name {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin: 0 0 5px 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.sap-product-price {
    font-size: 14px;
    font-weight: 700;
    color: #e53935;
    margin-bottom: 4px;
}

.sap-product-price del {
    color: #999;
    font-weight: 400;
    font-size: 12px;
    margin-left: 5px;
}

.sap-product-price ins {
    text-decoration: none;
    color: #e53935;
}

.sap-product-description {
    font-size: 12px;
    color: #666;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Toggle button */
.sap-toggle {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 999997;
    transition: transform 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease;
}

.sap-toggle.sap-position-right {
    right: 20px;
}

.sap-toggle.sap-position-left {
    left: 20px;
}

.sap-toggle:hover {
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.sap-toggle.hidden {
    opacity: 0;
    pointer-events: none;
}

.sap-toggle svg {
    width: 24px;
    height: 24px;
}

/* Badge */
.sap-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: #333333;
    color: #ffffff;
    font-size: 11px;
    font-weight: 600;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}

/* Scrollbar styling */
.sap-content::-webkit-scrollbar {
    width: 6px;
}

.sap-content::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.sap-content::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.sap-content::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Animation for new announcements */
@keyframes sap-pulse {
    0% {
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    }
    50% {
        box-shadow: 0 4px 25px rgba(229, 57, 53, 0.5);
    }
    100% {
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    }
}

.sap-toggle.pulse {
    animation: sap-pulse 2s infinite;
}

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

/* Tablets */
@media screen and (max-width: 768px) {
    .sap-sidebar {
        width: 320px;
    }
    
    .sap-header {
        padding: 16px;
    }
    
    .sap-title {
        font-size: 16px;
    }
    
    .sap-announcement {
        padding: 16px;
    }
    
    .sap-announcement-title {
        font-size: 14px;
    }
    
    .sap-announcement-content {
        font-size: 13px;
    }
    
    .sap-toggle {
        width: 45px;
        height: 45px;
    }
    
    .sap-toggle.sap-position-right {
        right: 15px;
    }
    
    .sap-toggle.sap-position-left {
        left: 15px;
    }
    
    .sap-video-container {
        margin: 10px 0;
        border-radius: 6px;
    }
    
    .sap-video-iframe {
        border-radius: 6px;
    }
    
    .sap-tiktok-container {
        min-height: 450px;
    }
    
    .sap-tiktok-iframe {
        height: 450px;
    }
    
    .sap-video-mp4 {
        max-height: 350px;
    }
    
    .sap-product-image {
        width: 60px;
        height: 60px;
    }
    
    .sap-product-name {
        font-size: 13px;
    }
    
    .sap-product-price {
        font-size: 13px;
    }
    
    .sap-product-description {
        font-size: 11px;
    }
}

/* Mobile phones */
@media screen and (max-width: 480px) {
    .sap-sidebar {
        width: 100%;
        max-width: 100%;
    }
    
    .sap-header {
        padding: 14px 16px;
    }
    
    .sap-title {
        font-size: 15px;
    }
    
    .sap-close {
        padding: 6px;
    }
    
    .sap-close svg {
        width: 22px;
        height: 22px;
    }
    
    .sap-announcement {
        padding: 14px 16px;
    }
    
    .sap-announcement-title {
        font-size: 14px;
        margin-bottom: 8px;
    }
    
    .sap-announcement-content {
        font-size: 13px;
        line-height: 1.5;
        margin-bottom: 10px;
    }
    
    .sap-announcement-link {
        font-size: 12px;
    }
    
    .sap-announcement-date {
        font-size: 11px;
    }
    
    .sap-toggle {
        width: 48px;
        height: 48px;
        bottom: 20px;
        top: auto;
        transform: translateY(0);
    }
    
    .sap-toggle.sap-position-right {
        right: 15px;
    }
    
    .sap-toggle.sap-position-left {
        left: 15px;
    }
    
    .sap-toggle:hover {
        transform: scale(1.05);
    }
    
    .sap-toggle svg {
        width: 22px;
        height: 22px;
    }
    
    .sap-badge {
        font-size: 10px;
        min-width: 18px;
        height: 18px;
    }
    
    .sap-products-container {
        gap: 10px;
    }
    
    .sap-product-link {
        padding: 8px;
        gap: 10px;
    }
    
    .sap-product-image {
        width: 55px;
        height: 55px;
    }
    
    .sap-product-name {
        font-size: 12px;
    }
    
    .sap-product-price {
        font-size: 12px;
    }
    
    .sap-product-description {
        display: none;
    }
}

/* Small mobile phones */
@media screen and (max-width: 360px) {
    .sap-header {
        padding: 12px 14px;
    }
    
    .sap-announcement {
        padding: 12px 14px;
    }
    
    .sap-announcement-title {
        font-size: 13px;
    }
    
    .sap-announcement-content {
        font-size: 12px;
    }
}

/* Landscape mode on mobile */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .sap-sidebar {
        width: 300px;
    }
    
    .sap-header {
        padding: 10px 16px;
    }
    
    .sap-announcement {
        padding: 12px 16px;
    }
    
    .sap-toggle {
        top: 50%;
        bottom: auto;
        transform: translateY(-50%);
        width: 40px;
        height: 40px;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .sap-sidebar {
        box-shadow: -3px 0 20px rgba(0, 0, 0, 0.12);
    }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .sap-sidebar,
    .sap-toggle,
    .sap-overlay,
    .sap-close,
    .sap-announcement,
    .sap-announcement-link {
        transition: none;
    }
    
    .sap-toggle.pulse {
        animation: none;
    }
}

/* Print styles - hide the sidebar */
@media print {
    .sap-sidebar,
    .sap-toggle,
    .sap-overlay {
        display: none !important;
    }
}
