/**
 * YT Video Voting - Frontend Stylesheet
 */

:root {
    --wp-yt-primary: #e63946;
    --wp-yt-primary-hover: #d62828;
    --wp-yt-primary-light: #ffccd5;
    --wp-yt-success: #2a9d8f;
    --wp-yt-success-light: #e8f5e9;
    --wp-yt-text-main: #1f2937;
    --wp-yt-text-muted: #6b7280;
    --wp-yt-bg-card: #ffffff;
    --wp-yt-bg-wrapper: #f9fafb;
    --wp-yt-border: #e5e7eb;
    --wp-yt-radius: 12px;
    --wp-yt-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --wp-yt-shadow-hover: 0 12px 24px -4px rgba(0, 0, 0, 0.12), 0 4px 8px -2px rgba(0, 0, 0, 0.06);
}

.wp-yt-voting-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans TC", sans-serif;
    color: var(--wp-yt-text-main);
    margin: 2rem 0;
    box-sizing: border-box;
}

.wp-yt-voting-wrapper *,
.wp-yt-voting-wrapper *::before,
.wp-yt-voting-wrapper *::after {
    box-sizing: border-box;
}

/* Status Banner */
.wp-yt-status-banner {
    background: #ffffff;
    border: 1px solid var(--wp-yt-border);
    border-radius: var(--wp-yt-radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--wp-yt-shadow);
}

.wp-yt-status-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--wp-yt-border);
}

.wp-yt-user-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.05rem;
}

.wp-yt-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.85rem;
    border-radius: 9999px;
    font-size: 0.9rem;
    font-weight: 600;
}

.wp-yt-badge-available {
    background-color: #e0f2fe;
    color: #0369a1;
}

.wp-yt-badge-used {
    background-color: var(--wp-yt-success-light);
    color: var(--wp-yt-success);
}

.wp-yt-login-notice {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.95rem;
    color: var(--wp-yt-text-muted);
}

.wp-yt-btn-login {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.9rem;
    background-color: var(--wp-yt-primary);
    color: #ffffff !important;
    text-decoration: none !important;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: background 0.2s ease, transform 0.1s ease;
}

.wp-yt-btn-login:hover {
    background-color: var(--wp-yt-primary-hover);
    transform: translateY(-1px);
}

/* Controls Bar (Filter Tabs & Search) */
.wp-yt-controls-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1.25rem;
}

.wp-yt-tabs {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.wp-yt-tab-btn {
    background: #f3f4f6;
    border: 1px solid transparent;
    color: var(--wp-yt-text-muted);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.wp-yt-tab-btn:hover {
    background: #e5e7eb;
    color: var(--wp-yt-text-main);
}

.wp-yt-tab-btn.active {
    background: var(--wp-yt-text-main);
    color: #ffffff;
}

.wp-yt-search-box {
    position: relative;
    min-width: 240px;
}

.wp-yt-search-input {
    width: 100%;
    padding: 0.5rem 1rem;
    border: 1px solid var(--wp-yt-border);
    border-radius: 8px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s ease;
}

.wp-yt-search-input:focus {
    border-color: var(--wp-yt-primary);
    box-shadow: 0 0 0 2px var(--wp-yt-primary-light);
}

/* Grid Layout */
.wp-yt-grid {
    display: grid;
    gap: 1.75rem;
}

.wp-yt-grid-cols-1 {
    grid-template-columns: 1fr;
}

.wp-yt-grid-cols-2 {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.wp-yt-grid-cols-3 {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.wp-yt-grid-cols-4 {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

/* Video Card */
.wp-yt-card {
    background: var(--wp-yt-bg-card);
    border: 1px solid var(--wp-yt-border);
    border-radius: var(--wp-yt-radius);
    overflow: hidden;
    box-shadow: var(--wp-yt-shadow);
    display: flex;
    flex-direction: column;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.wp-yt-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--wp-yt-shadow-hover);
}

/* Video Container & Facade */
.wp-yt-video-container {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 Aspect Ratio */
    background: #000;
    overflow: hidden;
}

.wp-yt-video-container iframe,
.wp-yt-facade {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.wp-yt-facade {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wp-yt-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease, filter 0.3s ease;
}

.wp-yt-card:hover .wp-yt-thumb {
    transform: scale(1.03);
    filter: brightness(0.95);
}

.wp-yt-play-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    transition: transform 0.2s ease;
}

.wp-yt-play-button:hover {
    transform: translate(-50%, -50%) scale(1.15);
}

.wp-yt-no-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    background: #f3f4f6;
    font-size: 0.9rem;
}

/* Card Body */
.wp-yt-card-body {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.wp-yt-author-tag {
    font-size: 0.825rem;
    color: #4b5563;
    background: #f3f4f6;
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-weight: 500;
    margin-bottom: 0.5rem;
    align-self: flex-start;
}

.wp-yt-card-title {
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.4;
    color: var(--wp-yt-text-main);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.wp-yt-card-excerpt {
    font-size: 0.875rem;
    color: var(--wp-yt-text-muted);
    line-height: 1.5;
    margin-bottom: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Card Footer */
.wp-yt-card-footer {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    border-top: 1px solid var(--wp-yt-border);
}

.wp-yt-votes-display {
    display: flex;
    align-items: baseline;
    gap: 0.3rem;
}

.wp-yt-heart-icon {
    font-size: 1.1rem;
}

.wp-yt-vote-num {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--wp-yt-primary);
    transition: transform 0.3s ease;
}

.wp-yt-vote-num.pulse {
    transform: scale(1.3);
}

.wp-yt-vote-unit {
    font-size: 0.85rem;
    color: var(--wp-yt-text-muted);
}

/* Action Buttons */
.wp-yt-vote-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    background-color: var(--wp-yt-primary);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.wp-yt-vote-btn:hover:not(:disabled) {
    background-color: var(--wp-yt-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(230, 57, 70, 0.25);
}

.wp-yt-vote-btn:active:not(:disabled) {
    transform: translateY(0);
}

.wp-yt-vote-btn.is-voted {
    background-color: var(--wp-yt-success);
    cursor: not-allowed;
    opacity: 0.9;
}

.wp-yt-vote-btn.is-disabled {
    background-color: #9ca3af;
    cursor: not-allowed;
    opacity: 0.7;
}

.wp-yt-vote-btn:disabled {
    cursor: not-allowed;
}

.wp-yt-btn-unauth {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.55rem 1rem;
    background-color: #f3f4f6;
    color: #4b5563 !important;
    text-decoration: none !important;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.wp-yt-btn-unauth:hover {
    background-color: #e5e7eb;
    color: var(--wp-yt-text-main) !important;
}

/* Toast Notifications */
.wp-yt-toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 999999;
    padding: 0.9rem 1.4rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    display: none;
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    max-width: 90vw;
}

.wp-yt-toast.show {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.wp-yt-toast.toast-success {
    background-color: #10b981;
}

.wp-yt-toast.toast-error {
    background-color: #ef4444;
}

.wp-yt-toast.toast-info {
    background-color: #3b82f6;
}

/* Empty State */
.wp-yt-empty-state {
    text-align: center;
    padding: 4rem 1rem;
    background: #ffffff;
    border: 1px dashed var(--wp-yt-border);
    border-radius: var(--wp-yt-radius);
    color: var(--wp-yt-text-muted);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .wp-yt-status-info {
        flex-direction: column;
        align-items: flex-start;
    }

    .wp-yt-controls-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .wp-yt-search-box {
        width: 100%;
    }

    .wp-yt-toast {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
        text-align: center;
    }
}
