
/* Reset */
.apx-container * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Container */
.apx-container {
    --apx-radius: 14px;
    --apx-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --apx-shadow-hover: 0 10px 25px rgba(0, 0, 0, 0.12);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Segoe UI Arabic', 'Noto Sans Arabic', sans-serif;
    background: transparent;
    padding: 20px !important;
    border-radius: 12px;
}

/* Grid */
.apx-grid {
    display: grid;
    gap: 24px;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    opacity: 0;
    animation: apxGridAppear 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

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

/* Work Item */
.apx-item {
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
    animation: apxItemSlide 0.5s ease-out forwards;
    animation-delay: calc(var(--index, 0) * 0.05s);
    opacity: 0;
    transform: translateY(30px);
}

@keyframes apxItemSlide {
    to { opacity: 1; transform: translateY(0); }
}

/* Card */
.apx-card {
    background: var(--apx-inner-bg, #1a1a1a);
    border-radius: var(--apx-radius);
    position: relative;
    overflow: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    box-shadow: var(--apx-shadow);
    padding: 10px;
}

/* Border */
.apx-border {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 1.5px solid var(--apx-border, #111111);
    border-radius: var(--apx-radius);
    pointer-events: none;
    z-index: 1;
    transition: all 0.3s ease;
}

.apx-item:hover .apx-border {
    border-color: #444444;
    box-shadow: 0 0 0 1px rgba(68, 68, 68, 0.3);
}

/* Preview */
.apx-preview-wrapper {
    margin: 0 0 15px 0;
    border-radius: calc(var(--apx-radius) - 4px);
    overflow: hidden;
    position: relative;
}

.apx-preview {
    position: relative;
    width: 100%;
    padding-top: 56.25%;
    overflow: hidden;
    border-radius: calc(var(--apx-radius) - 4px);
    background: #111111;
}

/* BlurHash */
.apx-blurhash {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 1;
    transition: opacity 0.6s ease;
    z-index: 1;
    background: linear-gradient(45deg, #1a1a1a 25%, #222222 50%, #1a1a1a 75%);
}

.apx-gradient {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.05) 100%);
    animation: apxShimmer 1.5s infinite;
    background-size: 200% 100%;
}

@keyframes apxShimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Image */
.apx-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transform: scale(1.05);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2;
}

.apx-image.apx-loaded {
    opacity: 1;
    transform: scale(1);
}

.apx-blurhash.fade-out {
    opacity: 0;
}

/* Overlay */
.apx-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to top, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0.05) 20%, rgba(0,0,0,0.02) 40%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 3;
}

.apx-item:hover .apx-overlay {
    opacity: 0.5;
}

/* Play Button */
.apx-play-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    width: 60px;
    height: 60px;
    z-index: 4;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.apx-play-icon {
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 2;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.apx-play-icon svg {
    width: 24px;
    height: 24px;
    margin-left: 4px;
}

.apx-play-ring {
    position: absolute;
    top: -8px;
    left: -8px;
    right: -8px;
    bottom: -8px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    animation: apxRingPulse 2s infinite;
    z-index: 1;
}

@keyframes apxRingPulse {
    0% { transform: scale(0.8); opacity: 0.5; }
    100% { transform: scale(1.3); opacity: 0; }
}

.apx-item:hover .apx-play-btn {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* Duration */
.apx-duration {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    z-index: 4;
    opacity: 0;
    transform: translateY(5px);
    transition: all 0.3s ease;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.apx-item:hover .apx-duration {
    opacity: 1;
    transform: translateY(0);
}

/* Iframe */
.apx-iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: calc(var(--apx-radius) - 4px);
}

.apx-iframe.loaded {
    opacity: 1;
}

/* Loading Spinner for iframe */
.apx-iframe-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.apx-iframe-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: apxSpin 0.8s linear infinite;
}

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

/* Info */
.apx-info {
    padding: 5px 12px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: var(--apx-inner-bg, #1a1a1a);
    border-radius: 0 0 calc(var(--apx-radius) - 4px) calc(var(--apx-radius) - 4px);
}

.apx-title-wrapper {
    margin-bottom: 10px;
}

.apx-title {
    font-size: 14px;
    line-height: 1.5;
    color: #dddddd;
    font-weight: 500;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.3s ease;
    text-align: right;
    direction: rtl;
}

.apx-item:hover .apx-title {
    color: #ffffff;
}

/* Meta */
.apx-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: #aaaaaa;
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    direction: rtl;
    font-family: 'Segoe UI', 'Segoe UI Arabic', 'Noto Sans Arabic', sans-serif;
}

.apx-views, .apx-date {
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.apx-item:hover .apx-views,
.apx-item:hover .apx-date {
    opacity: 1;
}

/* Load More */
.apx-load-more-container {
    text-align: center;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.apx-load-more {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #dddddd;
    padding: 12px 28px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 150px;
    justify-content: center;
    backdrop-filter: blur(10px);
    font-family: 'Segoe UI', 'Segoe UI Arabic', 'Noto Sans Arabic', sans-serif;
}

.apx-load-more:hover {
    transform: translateY(-2px);
    background: rgba(0, 0, 0, 0.7);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.2);
}

.apx-load-more:active {
    transform: translateY(0);
}

.apx-loader {
    width: 18px;
    height: 18px;
}

.apx-spinner {
    width: 100%;
    height: 100%;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: apxSpin 0.8s linear infinite;
}

/* Error */
.apx-error {
    background: rgba(255, 0, 0, 0.1);
    border: 1px solid rgba(255, 0, 0, 0.3);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    color: #ff5555;
    font-size: 14px;
    font-weight: 500;
    backdrop-filter: blur(10px);
}

/* Responsive */
@media (max-width: 1200px) {
    .apx-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
}

@media (max-width: 768px) {
    .apx-container { padding: 15px !important; }
    .apx-grid { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
    .apx-card { padding: 8px; }
    .apx-info { padding: 12px 10px; }
    .apx-title { font-size: 13px; }
}

@media (max-width: 480px) {
    .apx-grid { grid-template-columns: 1fr; gap: 12px; }
    .apx-card { border-radius: 12px; padding: 6px; }
    .apx-border { border-radius: 12px; }
    .apx-preview-wrapper { margin: 0 0 10px 0; }
}

.apx-item:hover .apx-card {
    transform: translateY(-5px);
    box-shadow: var(--apx-shadow-hover);
    opacity:0.8
}
.apx-item:active .apx-card {
    transform: translateY(5px);
    box-shadow: var(--apx-shadow-hover);
    opacity:1
}