/**
 * 随机看图插件样式
 */

/* ========== 容器 ========== */
.wp-random-image-container {
    max-width: 100%;
    margin: 0 auto;
    position: relative;
    background: #fff;
}

.wp-random-image-container *,
.wp-random-image-container *::before,
.wp-random-image-container *::after {
    box-sizing: border-box;
}

/* ========== 包装器 ========== */
.wp-random-image-container .wp-random-image-wrapper {
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #f8f8f8;
    padding: 16px;
    border-radius: 12px;
    margin: 0;
}

/* ========== 图片主区域 ========== */
.wp-random-image-container #wp-random-image-main,
.wp-random-image-popup #wp-random-image-popup-main {
    width: 100%;
    height: 800px;
    position: relative;
    background: #111;
    overflow: hidden;
    border-radius: 8px;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wp-random-image-container #wp-random-image-viewer,
.wp-random-image-popup #wp-random-image-popup-viewer {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    display: block;
    object-fit: contain;
    cursor: pointer;
    transition: opacity 0.3s ease;
}

.wp-random-image-container #wp-random-image-viewer.loading,
.wp-random-image-popup #wp-random-image-popup-viewer.loading {
    opacity: 0.3;
}

/* ========== 控制按钮区域 ========== */
.wp-random-image-container .wp-random-image-controls {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wp-random-image-container #wp-random-image-buttons,
.wp-random-image-popup #wp-random-image-popup-buttons {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    padding: 0;
    margin: 0;
}

/* ========== 按钮样式 ========== */
.wp-random-image-container .wp-random-image-btn,
.wp-random-image-popup .wp-random-image-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: #333;
    color: #fff;
    min-height: 40px;
    min-width: 100px;
    padding: 10px 20px;
    border: none;
    margin: 0;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    line-height: 1.4;
}

.wp-random-image-container .wp-random-image-btn:hover,
.wp-random-image-popup .wp-random-image-btn:hover {
    background: #555;
}

.wp-random-image-container .wp-random-image-btn:active,
.wp-random-image-popup .wp-random-image-btn:active {
    transform: scale(0.97);
}

.wp-random-image-container .wp-random-image-btn .btn-icon,
.wp-random-image-popup .wp-random-image-btn .btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
}

.wp-random-image-container .wp-random-image-btn .btn-icon svg,
.wp-random-image-popup .wp-random-image-btn .btn-icon svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ========== 下拉选择框 ========== */
.wp-random-image-container .wp-random-image-select-wrapper,
.wp-random-image-popup .wp-random-image-select-wrapper {
    margin: 0;
    position: relative;
}

.wp-random-image-container .wp-random-image-select-wrapper:after,
.wp-random-image-popup .wp-random-image-select-wrapper:after {
    content: '';
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    pointer-events: none;
}

.wp-random-image-container .wp-random-image-select,
.wp-random-image-popup .wp-random-image-select {
    width: 100%;
    background: #fff;
    color: #333;
    border: 1px solid #e5e5e5;
    height: 40px;
    padding: 0 36px 0 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

.wp-random-image-container .wp-random-image-select:hover,
.wp-random-image-popup .wp-random-image-select:hover {
    border-color: #333;
}

.wp-random-image-container .wp-random-image-select:focus,
.wp-random-image-popup .wp-random-image-select:focus {
    outline: none;
    border-color: #333;
}

/* ========== 加载指示器 ========== */
.wp-random-image-container .wp-random-image-loader,
.wp-random-image-popup .wp-random-image-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.2);
    border-radius: 50%;
    border-top-color: #fff;
    animation: wp-random-image-spin 0.8s linear infinite;
    z-index: 5;
    display: none;
}

.wp-random-image-container .wp-random-image-loader.show,
.wp-random-image-popup .wp-random-image-loader.show {
    display: block;
}

@keyframes wp-random-image-spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ========== 切换提示 ========== */
.wp-random-image-container .wp-random-image-switch-hint,
.wp-random-image-popup .wp-random-image-switch-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.7);
    color: #fff;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 500;
    z-index: 20;
    opacity: 0;
    transition: opacity 0.3s ease;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.wp-random-image-container .wp-random-image-switch-hint.show,
.wp-random-image-popup .wp-random-image-switch-hint.show {
    animation: wp-random-image-fadeInOut 1.5s ease-in-out;
}

@keyframes wp-random-image-fadeInOut {
    0% { opacity: 0; }
    20% { opacity: 1; }
    80% { opacity: 1; }
    100% { opacity: 0; }
}

/* ========== 滑动指引 ========== */
.wp-random-image-container .wp-random-image-swipe-guide,
.wp-random-image-popup .wp-random-image-swipe-guide {
    position: absolute;
    top: 50%;
    right: 16px;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.6);
    color: #fff;
    padding: 10px 6px;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9;
    opacity: 0.6;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.wp-random-image-container .wp-random-image-swipe-guide:hover,
.wp-random-image-popup .wp-random-image-swipe-guide:hover {
    opacity: 1;
}

.wp-random-image-container .swipe-arrow,
.wp-random-image-popup .swipe-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 2px 0;
}

.wp-random-image-container .swipe-arrow svg,
.wp-random-image-popup .swipe-arrow svg {
    width: 16px;
    height: 16px;
    stroke: #fff;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.wp-random-image-container .swipe-up,
.wp-random-image-popup .swipe-up {
    animation: wp-random-image-moveUp 1.5s ease-in-out infinite;
}

.wp-random-image-container .swipe-down,
.wp-random-image-popup .swipe-down {
    animation: wp-random-image-moveDown 1.5s ease-in-out infinite;
}

@keyframes wp-random-image-moveUp {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

@keyframes wp-random-image-moveDown {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(4px); }
}

.wp-random-image-container .swipe-text,
.wp-random-image-popup .swipe-text {
    font-size: 11px;
    text-align: center;
    margin: 4px 0;
    writing-mode: vertical-lr;
    text-orientation: upright;
    letter-spacing: 1px;
    color: #fff;
}

/* ========== 触发按钮（弹窗模式） ========== */
.wp-random-image-button-container {
    display: inline-block;
    margin: 10px 0;
}

.wp-random-image-trigger-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    min-height: 44px;
    padding: 12px 28px;
    border: none;
    margin: 0;
    border-radius: 22px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.wp-random-image-trigger-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.wp-random-image-trigger-btn:active {
    transform: translateY(0);
}

.wp-random-image-trigger-btn .btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
}

.wp-random-image-trigger-btn .btn-icon svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

/* ========== 弹窗 ========== */
.wp-random-image-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wp-random-image-popup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(8px);
}

.wp-random-image-popup-content {
    position: relative;
    background: #fff;
    border-radius: 16px;
    max-width: 95%;
    max-height: 95%;
    width: 90%;
    height: 85%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: wp-random-image-popupIn 0.3s ease-out;
}

@keyframes wp-random-image-popupIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.wp-random-image-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: #f8f8f8;
    border-bottom: 1px solid #eee;
}

.wp-random-image-popup-header h3 {
    margin: 0;
    color: #333;
    font-size: 16px;
    font-weight: 600;
}

.wp-random-image-popup-close {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wp-random-image-popup-close:hover {
    background: rgba(0,0,0,0.05);
    color: #333;
}

.wp-random-image-popup-close svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.wp-random-image-popup-body {
    flex: 1;
    padding: 16px;
    overflow: auto;
    background: #fff;
}

/* 弹窗内容器样式 */
.wp-random-image-popup .wp-random-image-container {
    height: 100%;
}

.wp-random-image-popup .wp-random-image-wrapper {
    height: 100%;
    background: #f8f8f8;
    padding: 16px;
    border-radius: 8px;
}

.wp-random-image-popup #wp-random-image-popup-main {
    flex: 1;
    min-height: 300px;
}

/* 弹窗关闭动画 */
.wp-random-image-popup.closing {
    animation: wp-random-image-popupOut 0.2s ease-in forwards;
}

.wp-random-image-popup.closing .wp-random-image-popup-content {
    animation: wp-random-image-popupOut 0.2s ease-in forwards;
}

@keyframes wp-random-image-popupOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.95);
    }
}

/* ========== 全屏查看 ========== */
.wp-random-image-fullscreen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.95);
    z-index: 9999999;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}

.wp-random-image-fullscreen-overlay img {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
}

.wp-random-image-fullscreen-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255,255,255,0.1);
    border: none;
    color: #fff;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.wp-random-image-fullscreen-close:hover {
    background: rgba(255,255,255,0.2);
}

.wp-random-image-fullscreen-close svg {
    width: 24px;
    height: 24px;
    stroke: #fff;
    fill: none;
    stroke-width: 2;
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
    .wp-random-image-container .wp-random-image-wrapper {
        flex-direction: column;
        padding: 12px;
        gap: 12px;
    }
    
    .wp-random-image-container .wp-random-image-controls {
        width: 100%;
    }
    
    .wp-random-image-container #wp-random-image-buttons,
    .wp-random-image-popup #wp-random-image-popup-buttons {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }
    
    .wp-random-image-container .wp-random-image-btn,
    .wp-random-image-popup .wp-random-image-btn {
        flex: 0 0 auto;
        min-width: auto;
        padding: 8px 16px;
        white-space: nowrap;
    }
    
    .wp-random-image-container .wp-random-image-select-wrapper,
    .wp-random-image-popup .wp-random-image-select-wrapper {
        flex: 1;
        min-width: 120px;
    }
    
    .wp-random-image-container #wp-random-image-main {
        height: auto;
        aspect-ratio: 3 / 4;
        max-height: 80vh;
    }
    
    .wp-random-image-container .wp-random-image-swipe-guide {
        right: 10px;
        padding: 8px 4px;
    }
    
    /* 移动端隐藏全屏按钮 */
    #wp-random-image-fullscreen,
    #wp-random-image-popup-fullscreen {
        display: none !important;
    }
    
    /* 弹窗响应式 */
    .wp-random-image-popup-content {
        width: 98%;
        height: 90%;
        max-width: 98%;
        max-height: 90%;
        border-radius: 12px;
    }
    
    .wp-random-image-popup-header {
        padding: 12px 16px;
    }
    
    .wp-random-image-popup-body {
        padding: 12px;
    }
    
    .wp-random-image-popup .wp-random-image-wrapper {
        flex-direction: column;
        padding: 12px;
        gap: 12px;
    }
    
    .wp-random-image-popup .wp-random-image-controls {
        width: 100%;
    }
    
    .wp-random-image-popup #wp-random-image-popup-main {
        aspect-ratio: unset;
        min-height: 250px;
    }
}

@media (max-width: 480px) {
    .wp-random-image-container .wp-random-image-wrapper {
        padding: 10px;
        gap: 10px;
    }
    
    .wp-random-image-container #wp-random-image-buttons,
    .wp-random-image-popup #wp-random-image-popup-buttons {
        gap: 6px;
    }
    
    .wp-random-image-container .wp-random-image-btn,
    .wp-random-image-popup .wp-random-image-btn {
        padding: 8px 14px;
        font-size: 13px;
        min-width: 70px;
    }
    
    .wp-random-image-popup-content {
        width: 99%;
        height: 95%;
    }
    
    .wp-random-image-trigger-btn {
        padding: 10px 20px;
        font-size: 14px;
    }
}
