/**
 * Cordial Contest System - CSS Stylesheet
 * Version: 1.0.10
 * 
 * Changelog:
 * Version 1.0.10 - 2025-12-10
 * - ADDED: Calendar transformed into modal popup with overlay
 * - ADDED: Modal overlay with semi-transparent background
 * - ADDED: Centered calendar modal that's always fully visible
 * - ADDED: Close button and escape key support
 * - FIXED: Calendar never clipped by parent containers
 * - FIXED: Calendar appears as proper popup when clicking "Custom"
 */

/* =========================================================================
   CONTESTANT CARD STYLES
   ========================================================================= */
.contestant-loop-container {
    display: grid;
    gap: 20px;
    padding: 20px;
    overflow: hidden !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

.cordial-columns-3 {
    grid-template-columns: repeat(3, 1fr);
}

.cordial-columns-2 {
    grid-template-columns: repeat(2, 1fr);
}

.cordial-archive-parent {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 20px;
    box-sizing: border-box !important;
    overflow: hidden !important;
}

.cordial-archive-wrapper {
    display: flex;
    align-items: center;
    gap: 20px;
    overflow: hidden !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

.featured-container {
    position: relative;
    flex-shrink: 0;
    margin-left: 0;
    box-sizing: border-box !important;
}

.contestant-profile-pic {
    width: 12.5rem;
    height: 12.5rem;
    border-radius: 50%;
    object-fit: cover;
}

.cordial-columns-3 .featured-container img {
    width: 7.5rem;
    height: 7.5rem;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.cordial-columns-2 .featured-container img {
    width: 12.5rem;
    height: 12.5rem;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.adaptive-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: #3BB44A;
    color: white;
    font-weight: bold;
}

.votes-span {
    width: 30px;
    height: 30px;
    position: absolute;
    bottom: 10px;
    right: 10px;
    z-index: 2;
    background-color: #90EE90;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.ranks-span {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    border-radius: 50%;
    background-color: #90EE90;
}

.archive-details-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    text-align: left;
    gap: 15px;
    overflow: hidden !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

.rank-plus-name {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

.rank-plus-name h2 {
    font-size: 18px;
    margin: 0;
    color: #333;
}

.logic-button {
    display: flex;
    justify-content: flex-start;
    width: 100%;
    overflow: hidden !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

.cordial-vote-container {
    display: inline-block;
    overflow: hidden !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

.cordial-vote-counter {
    display: none;
    align-items: center;
    gap: 5px;
    margin-bottom: 5px;
    overflow: hidden !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

.cordial-minus-btn, .cordial-plus-btn {
    background-color: #3BB44A;
    color: white;
    border: none;
    border-radius: 5px;
    width: 30px;
    height: 30px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    flex-shrink: 0 !important;
}

.cordial-quantity-input {
    width: 50px;
    min-width: 50px;
    max-width: 100% !important;
    text-align: center;
    font-size: 16px;
    font-weight: bold;
    border: 1px solid #ccc;
    border-radius: 3px;
    padding: 2px;
    -moz-appearance: textfield;
    box-sizing: border-box !important;
    overflow-x: auto !important;
    white-space: nowrap !important;
}

.cordial-quantity-input::-webkit-outer-spin-button,
.cordial-quantity-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.cordial-counter-close {
    color: white;
    background: #94F4B6;
    border-radius: 50%;
    padding: 0 8px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    flex-shrink: 0 !important;
}

.cordial-counter-close:hover {
    background: #DCDCDF;
}

.cordial-vote-btn {
    background-color: #3BB44A;
    color: white;
    padding: 5px 20px;
    border: none;
    border-radius: 10px;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
}

.fade-in { animation: fadeIn 0.3s ease-in; }
.fade-out { animation: fadeOut 0.3s ease-out; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

/* =========================================================================
   VOTE MANAGEMENT STYLES (Admin)
   ========================================================================= */
.cordial-contest-vote-management-wrapper {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    align-items: flex-start;
}

.cordial-competition-current-votes {
    flex: 0 0 auto;
    width: auto;
    min-width: 120px;
}

.cordial-competition-manual-adjustment {
    flex: 2;
}

.cordial-competition-attribution-selector {
    flex: 1;
    min-width: 200px;
}

.vote-adjustment-controls {
    display: flex;
    gap: 5px;
    margin-top: 5px;
    flex-wrap: nowrap;
    align-items: center;
}

.vote-adjustment-controls button {
    padding: 8px 12px;
    border: 1px solid #ddd;
    background: #f9f9f9;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    white-space: nowrap;
}

.vote-adjustment-controls button:hover {
    background: #e9e9e9;
}

.vote-adjustment-controls .button-danger {
    background: #dc3545;
    color: white;
    border-color: #dc3545;
}

.vote-adjustment-controls .button-danger:hover {
    background: #c82333;
}

/* =========================================================================
   VOTE HISTORY TIMELINE STYLES
   ========================================================================= */
.vote-history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-bottom: 20px;
    border: 1px solid #eaeaea;
}

.vote-history-table th,
.vote-history-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #eaeaea;
    vertical-align: top;
}

.vote-history-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #495057;
    border-bottom: 2px solid #dee2e6;
}

.vote-history-table tr:nth-child(even) {
    background: #fcfcfc;
}

.vote-history-table tr:hover {
    background: #f8f9fa;
}

.vote-change-positive {
    color: #3bb44a;
    font-weight: bold;
}

.vote-change-negative {
    color: #dc3545;
    font-weight: bold;
}

.vote-history-summary {
    margin-top: 20px;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 5px;
    border-left: 4px solid #3bb44a;
}

.vote-history-summary h4 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #333;
}

.vote-history-summary ul {
    margin: 10px 0;
    padding-left: 20px;
}

.vote-history-summary li {
    margin-bottom: 5px;
    line-height: 1.4;
}

/* =========================================================================
   LEADERBOARD STYLES - WITH MODAL CALENDAR
   ========================================================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

#cordial-leaderboard-overall-parent {
    max-width: 800px;
    margin: 0 auto;
    background-color: white;
    border-radius: 15px;
    overflow: visible !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    border: 1px solid #eaeaea;
}

#leaderboard-filter {
    background-color: #f8f9fa;
    padding: 20px;
    border-bottom: 1px solid #eaeaea;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: visible !important;
    z-index: 1;
}

.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-select {
    padding: 10px 15px;
    border: 1px solid #ced4da;
    border-radius: 8px;
    background-color: white;
    font-size: 14px;
    cursor: pointer;
    min-width: 150px;
    transition: all 0.3s ease;
}

.dropdown-select:hover {
    border-color: #6a11cb;
    box-shadow: 0 0 0 2px rgba(106, 17, 203, 0.1);
}

.custom-date-btn {
    padding: 10px 15px;
    border: 1px solid #ced4da;
    border-radius: 8px;
    background-color: white;
    font-size: 14px;
    cursor: pointer;
    min-width: 150px;
    transition: all 0.3s ease;
    text-align: center;
}

.custom-date-btn:hover {
    border-color: #6a11cb;
    box-shadow: 0 0 0 2px rgba(106, 17, 203, 0.1);
}

/* NEW: MODAL CALENDAR STYLES */
.calendar-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.calendar-modal-overlay.active {
    opacity: 1;
}

.calendar-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    width: 90%;
    max-width: 350px;
    max-height: 90vh;
    overflow-y: auto;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.calendar-modal.active {
    opacity: 1;
}

.calendar-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 20px 10px 20px;
    border-bottom: 1px solid #eee;
}

.calendar-modal-title {
    font-weight: 600;
    font-size: 18px;
    color: #333;
}

.calendar-modal-close {
    background: #f0f0f0 !important;
    color: #666 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 30px !important;
    height: 30px !important;
    border-radius: 50% !important;
    font-size: 24px !important;
    cursor: pointer !important;
    padding: 0 !important;
    border: none !important;
    position: static !important;
    margin: 0 !important;
    line-height: 1 !important;
    text-align: center !important;
}

.calendar-modal-close:hover {
    background: #F54927 !important;
    color: white !important;
}

.calendar-modal-close:active {
    background: #C4C4C4 !important;
    color: #333 !important;
}

.calendar-modal-content {
    padding: 20px;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.calendar-nav {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 4px;
    transition: background 0.2s;
    color: #6a11cb;
}

.calendar-nav:hover {
    background: #f0f0f0;
}

.month-year {
    font-weight: 600;
    font-size: 16px;
    color: #333;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
    margin-bottom: 20px;
}

.calendar-day {
    text-align: center;
    padding: 10px 5px;
    font-weight: bold;
    font-size: 12px;
    color: #6c757d;
}

.calendar-date {
    text-align: center;
    padding: 10px 5px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}

.calendar-date:hover {
    background: #f0f0f0;
}

.calendar-date.selected {
    background: #6a11cb;
    color: white;
}

.calendar-date.other-month {
    color: #ccc;
}

.calendar-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.calendar-btn {
    padding: 10px 20px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    font-weight: 500;
}

.calendar-btn.primary {
    background: #3bb44a !important;
    color: white !important;
    border-color: #3bb44a !important;
}

.calendar-btn:hover {
    opacity: 0.9;
}

#leaderboard-contents {
    padding: 20px;
}

#cordial-leaderboard-wrapper {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.leaderboard1 {
    display: flex;
    align-items: center;
    background-color: white;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid #f1f3f4;
}

.leaderboard1:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.rank {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #3bb44a;
    color: white;
    border-radius: 50%;
    font-weight: bold;
    font-size: 18px;
    margin-right: 15px;
}

.leaderboard-profile-photo {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    overflow: hidden;
    margin-right: 15px;
    border: 3px solid #e9ecef;
}

.leaderboard-profile-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.username-vote-count {
    flex-grow: 1;
}

.username-vote-count p:first-child {
    font-weight: 600;
    font-size: 18px;
    color: #212529;
    margin-bottom: 5px;
}

.username-vote-count p:last-child {
    color: #6c757d;
    font-size: 14px;
}

.leaderboard-trophy {
    width: 50px;
    height: 50px;
}

.leaderboard-trophy img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* =========================================================================
   APPLY NOW BUTTON STYLES
   ========================================================================= */
.apply-now-button {
    display: inline-block;
    width: 20%;
    margin: 10px 0;
    padding: 0 .5rem 5px .5rem ;
    background-color: #3bb44a;
    color: #fff;
    font-size: 1.375rem;
    text-decoration: none;
    transition: all 0.3s ease-in-out;
    border-radius: 1rem;
    font-weight: bold;
    text-align: center;
}

.apply-now-button:hover {
    background-color: #90ee90;
    color: #000000;
}

/* =========================================================================
   VOTE BADGE STYLES
   ========================================================================= */
.vote-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* =========================================================================
   PAGINATION STYLES
   ========================================================================= */
.contestant-pagination {
    text-align: center;
    margin-top: 20px;
}

.contestant-pagination .page-numbers {
    padding: 8px 16px;
    margin: 0 4px;
    border: 1px solid #ddd;
    text-decoration: none;
    border-radius: 4px;
}

.contestant-pagination .page-numbers.current {
    background-color: #3bb44a;
    color: white;
    border-color: #3bb44a;
}

/* =========================================================================
   ADMINISTRATION METABOX STYLES
   ========================================================================= */
.competition-admin-metabox .inline-fields {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.competition-admin-metabox .field-group {
    flex: 1;
    min-width: 200px;
}

.competition-admin-metabox .field-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.competition-admin-metabox .field-group input,
.competition-admin-metabox .field-group select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.competition-admin-metabox .settings-group {
    padding: 15px;
    background: #f9f9f9;
    border-radius: 5px;
    margin-top: 20px;
}

.competition-admin-metabox .settings-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

/* =========================================================================
   RESPONSIVE STYLES
   ========================================================================= */
@media (max-width: 600px) {
    #leaderboard-filter {
        flex-direction: column;
        align-items: center;
    }
    
    .dropdown {
        width: 100%;
    }
    
    .dropdown-select {
        width: 100%;
    }
    
    .custom-date-btn {
        width: 100%;
    }
    
    .calendar-modal {
        width: 95%;
        max-width: 320px;
    }
    
    .leaderboard1 {
        padding: 12px;
    }
    
    .leaderboard-profile-photo {
        width: 50px;
        height: 50px;
    }
    
    .username-vote-count p:first-child {
        font-size: 16px;
    }
    
    .apply-now-button {
        width: 100%;
    }
    
    .cordial-archive-wrapper {
        flex-direction: column;
        text-align: center;
    }
    
    .contestant-loop-container {
        grid-template-columns: 1fr;
    }
    
    .cordial-columns-2,
    .cordial-columns-3 {
        grid-template-columns: 1fr;
    }
    
    .contestant-profile-pic {
        width: 10rem;
        height: 10rem;
    }
    
    .cordial-columns-3 .featured-container img {
        width: 6rem;
        height: 6rem;
    }
    
    .cordial-columns-2 .featured-container img {
        width: 10rem;
        height: 10rem;
    }
    
    /* Vote Management Responsive */
    .cordial-contest-vote-management-wrapper {
        flex-direction: column;
        gap: 15px;
    }
    
    .cordial-competition-current-votes,
    .cordial-competition-manual-adjustment,
    .cordial-competition-attribution-selector {
        width: 100%;
    }
    
    .cordial-competition-current-votes {
        min-width: 100%;
    }
    
    .vote-adjustment-controls {
        flex-wrap: wrap;
    }
    
    .vote-adjustment-controls button {
        flex: 1;
        min-width: 70px;
    }
    
    /* Vote History Responsive */
    .vote-history-table {
        font-size: 11px;
    }
    
    .vote-history-table th,
    .vote-history-table td {
        padding: 6px 8px;
    }
    
    /* Admin responsive */
    .competition-admin-metabox .inline-fields {
        flex-direction: column;
        gap: 15px;
    }
}