/**
 * Sports Meister Competitions - Frontend Popups & Modals
 * All modal, popup, and dialog styles including results modals and match details
 *
 * @package Sports_Meister_Competitions
 * @since 1.0.0
 * @requires frontend-core.css
 */

/* Results Popup Modal */
.smc-results-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    pointer-events: none;
}

.smc-results-popup * {
    pointer-events: auto;
}
td.smc-col-team1 .smc-team-info {
    flex-direction: row-reverse !important;
    justify-content: flex-start !important;
}

td.smc-col-team2 .smc-team-info {
    flex-direction: row !important;
    justify-content: flex-start !important;
}
.smc-popup-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9998;
    transition: opacity 0.3s ease;
    opacity: 0;
}

.smc-popup-overlay.active {
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
}

body.smc-popup-open {
    overflow: hidden;
}

.smc-popup-content {
    background: #fff;
    border-radius: var(--smc-border-radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    max-width: 90%;
    width: 1400px;
    max-height: 90vh;
    overflow-y: auto;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: slideIn 0.3s ease;
    z-index: 9999;
}

@keyframes slideIn {
    from {
        transform: translate(-50%, calc(-50% - 50px));
        opacity: 0;
    }
    to {
        transform: translate(-50%, -50%);
        opacity: 1;
    }
}

.smc-popup-header {
    background: linear-gradient(to right, rgba(59, 130, 246, 0.1), rgba(168, 85, 247, 0.1), rgba(6, 182, 212, 0.1)) !important;
    color: #fff;
    padding-right: 1.5rem !important;
    border-radius: var(--smc-border-radius) var(--smc-border-radius) 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.smc-popup-header h3 {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 600;
}

.smc-popup-close {
    background: none;
    border: none !important;
    color: #fff;
    font-size: 2rem !important;
    cursor: pointer !important;
    padding: 0 !important;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50% !important;
    transition: var(--smc-transition) !important;
}

.smc-popup-close span {
    height: 50px !important;
}

.smc-popup-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

.smc-popup-body {
    padding: 1.5rem;
    width: 100%;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

/* Loading State in Popup - fade handled via JS */
.smc-popup-body .smc-loading {
    width: 100% !important;
    margin: 0 0 2rem 0 !important;
    padding: 1.5rem !important;
    display: flex;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.75rem !important;
    transform: none !important;
    rotate: none !important;
    background: #f9f9f9 !important;
    border-bottom: 1px solid #e0e0e0 !important;
    flex-shrink: 0 !important;
    order: -1 !important;
}

.smc-loading.smc-loading--fade-out {
    animation: smc-loading-fade 0.3s ease-out forwards !important;
}

@keyframes smc-loading-fade {
    0% {
        opacity: 1;
        visibility: visible;
    }
    100% {
        opacity: 0;
        visibility: hidden;
    }
}

/* Hide any spinner elements in popup loading */
.smc-popup-body .smc-spinner {
    display: none !important;
}

/* Loading Progress Bar Container */
.smc-loading-progress-container {
    width: 200px !important;
    height: 6px !important;
    background: #e0e0e0 !important;
    border-radius: 3px !important;
    overflow: hidden !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    transform: none !important;
    rotate: none !important;
    animation: none !important;
}

.smc-loading-progress-bar {
    height: 100% !important;
    background: linear-gradient(90deg, #4b92af, #5ca3c0) !important;
    border-radius: 3px !important;
    width: 0% !important;
    animation: smc-loading-progress 4s ease-out forwards !important;
    transform: translateX(0) !important;
    rotate: 0deg !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
}

@keyframes smc-loading-progress {
    0% {
        width: 0%;
    }
    100% {
        width: 100%;
    }
}

.smc-loading-text {
    font-size: 1rem !important;
    color: #666 !important;
    font-weight: 500 !important;
    margin: 0 !important;
    padding: 0 !important;
    text-align: center !important;
    letter-spacing: 0.5px !important;
    animation: none !important;
    transform: translateY(0) !important;
    rotate: 0deg !important;
}

.smc-popup-footer {
    padding: 1.5rem 2rem;
    background: var(--smc-gray-100);
    border-top: 1px solid var(--smc-gray-300);
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    border-radius: 0 0 var(--smc-border-radius) var(--smc-border-radius);
}

.smc-form-messages {
    margin-top: 1rem;
}

/* Results Table in Popup */
.smc-results-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 0;
    border: 1px solid #e5e5e5;
    border-radius: 16px;
    overflow: hidden;
}

.smc-results-table thead {
    background: linear-gradient(to right, rgba(59, 130, 246, 0.1), rgba(168, 85, 247, 0.1), rgba(6, 182, 212, 0.1));
    border-bottom: 2px solid var(--smc-gray-300);
}

.smc-results-table th {
    padding: 1rem 0.75rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--smc-gray-700);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border:none;
}

.smc-results-table th.smc-col-stage {
    width: 15%;
    border-top-left-radius: 1rem;
}
.smc-results-table th.smc-col-team1 {
    text-align: right;
}
.smc-results-table th.smc-col-team1,
.smc-results-table th.smc-col-team2 {
    width: 25%;
}

.smc-results-table th.smc-col-score1,
.smc-results-table th.smc-col-score2 {
    width: 10%;
    text-align: center;
}

.smc-results-table th.smc-col-status {
    width: 15%;
    text-align: center;
    border-top-right-radius: 1rem;
}

.smc-results-table tbody tr {
    border-bottom: 1px solid var(--smc-gray-200);
    transition: background-color 0.2s ease;
}

.smc-results-table tbody tr:hover {
    background-color: var(--smc-gray-50);
}

.smc-results-table tbody tr:last-child {
    border-bottom: none;
}

.smc-results-table tbody tr:last-child td.smc-col-stage {
    border-bottom-left-radius: 1rem;
}

.smc-results-table tbody tr:last-child td.smc-col-status {
    border-bottom-right-radius: 1rem;
}

.smc-results-table td {
    padding: 0.75rem;
    vertical-align: middle;
    border: none;
    border-bottom: 1px solid #e5e5e5;
}

table tbody > tr:nth-child(odd):not(.smc-standings-row-winner) > td,
table tbody > tr:nth-child(odd):not(.smc-standings-row-winner) > th {
    background-color: white !important;
}

.smc-results-table .smc-match-row.smc-match-has-result > td {
    background-color: #f5f5f5 !important;
}

.smc-results-table .smc-match-row.smc-match-has-result:hover > td {
    background-color: #ebebeb !important;
}

.smc-results-table .smc-match-row.cancelled > td {
    background: #fff5f5 !important;
    border-bottom-color: #fecaca;
    position: relative;
}

.smc-results-table .smc-match-row.cancelled:hover > td {
    background: #ffe8e8 !important;
}

.smc-results-table .smc-match-row.cancelled .smc-team-name {
    text-decoration: line-through;
    color: #b91c1c;
}

.smc-results-table .smc-match-row.cancelled .smc-col-stage {
    color: #b91c1c;
    font-weight: 600;
}

.smc-results-table .smc-match-row.cancelled .smc-score-input {
    border-color: #f5b8bf !important;
    background: #fffefe !important;
    cursor: not-allowed;
    color: #b91c1c;
}

.smc-results-table .smc-team-info.winner .smc-team-name {
    font-weight: 600;
    color: var(--smc-success, #0f766e);
}

.smc-results-table .smc-team-info.loser .smc-team-name {
    opacity: 0.75;
}

.smc-results-table .smc-team-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.smc-results-table .smc-team-logo {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.smc-results-table .smc-team-name {
    font-size: 0.9375rem;
    color: var(--smc-gray-900);
    font-weight: 500;
}

.smc-results-table .smc-score-input {
    width: 80px !important;
    padding: 0.5rem !important;
    font-size: 1rem !important;
    text-align: center !important;
    border: 2px solid var(--smc-gray-300) !important;
    border-radius: 1rem !important;
    transition: all 0.2s ease !important;
    background: #ebf7fa52 !important;
}

.smc-results-table .smc-score-input:focus {
    outline: none;
    border-color: var(--smc-primary);
    box-shadow: 0 0 0 3px rgba(75, 146, 175, 0.1);
}

.smc-results-table .smc-score-input.error {
    border-color: var(--smc-danger);
}

.smc-results-table .smc-score-input.winner {
    background-color: #d4edda !important;
    color: #155724 !important;
    border: 2px solid var(--smc-success) !important;
    font-weight: 600 !important;
}

.smc-results-table .smc-score-input.loser {
    background-color: #f8f9fa;
    color: var(--smc-gray-600);
    border: 2px solid var(--smc-gray-300) !important;
}

.smc-results-table .smc-col-score1,
.smc-results-table .smc-col-score2 {
    text-align: center;
}

.smc-results-table .smc-col-status {
    text-align: center;
}

/* Popup Filters */
.smc-popup-filters {
    padding: 0.75rem 1.5rem;
    background: var(--smc-gray-50);
    border-bottom: 1px solid var(--smc-gray-200);
}

.smc-filter-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9375rem;
    color: var(--smc-gray-700);
    cursor: pointer;
    user-select: none;
}

.smc-filter-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Competition Meta in Popup Header */
.smc-header-content {
    flex: 1;
}

.smc-popup-title {
    margin: 0 0 0.5rem 0 !important;
    font-size: 1.5rem !important;
    font-weight: 600 !important;
    color: var(--smc-gray-900) !important;
    text-align: left;
}

.smc-competition-meta {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    font-size: 0.9375rem;
    opacity: 0.95;
}

.smc-meta-item {
    display: inline-flex;
    gap: 0.25rem;
    color: var(--smc-gray-900) !important;
}

.smc-meta-item strong {
    font-weight: 600;
}

/* No Matches Message */
.smc-no-matches {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--smc-gray-700);
}

.smc-no-matches p {
    font-size: 1.125rem;
    margin: 0;
}

