/* ============================================================================
   GENERAL/BASE STYLES
   ============================================================================ */
body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f5f5f5; /* Fallback */
    background: linear-gradient(rgba(245, 245, 245, 0.97), rgba(245, 245, 245, 0.97)), url('Media/Logos/Iso.png') center center / contain no-repeat fixed;
    text-align: center;
}

/* Index page specific body styles */
body.index-page {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, rgba(255,255,255,0.95), rgba(245,245,245,0.95)), url('Media/Logos/Iso.png') center center / 60vmin no-repeat;
    min-height: 100vh;
    color: #222;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Overlay page specific body styles */
body.overlay-page {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background: none !important;
    background-color: transparent !important;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    min-height: 100vh;
}

/* Iframe layout page specific body styles */
body.iframe-layout {
    margin: 0;
    padding: 0;
    display: flex;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

/* ============================================================================
   INDEX PAGE STYLES (Navigation, Buttons, Header, Footer)
   ============================================================================ */
.header {
    text-align: center;
    padding: 2rem;
    width: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    margin-bottom: 2rem;
    border-bottom: 2px solid #e0e0e0;
}

.logo {
    width: 200px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

.logo:hover {
    transform: scale(1.05);
}

.button-section {
    margin: 1.5rem 0;
    text-align: center;
    width: 80%;
    max-width: 1200px;
}

.section-title {
    font-size: 1.5rem;
    color: #0d47a1; /* deep blue */
    font-weight: 700;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.button-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 2rem;
}

/* Buttons */
.button {
    display: inline-block;
    text-decoration: none;
    text-align: center;
    background: #ffffff;
    color: #0d47a1;
    font-weight: bold;
    border: 2px solid #0d47a1;
    border-radius: 8px;
    padding: 12px 24px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
    background: linear-gradient(90deg, #1565c0, #0d47a1);
    color: #ffffff;
    border-color: #0d47a1;
}

.button:active {
    background: linear-gradient(90deg, #b71c1c, #e53935);
    border-color: #b71c1c;
}

.footer {
    margin-top: auto;
    padding: 1rem;
    text-align: center;
    font-size: 0.9rem;
    color: #555;
    width: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    border-top: 2px solid #e0e0e0;
}

@media (max-width: 768px) {
    .button-container {
        flex-direction: column;
        align-items: stretch;
    }

    .button {
        width: 100%;
    }
}

/* ============================================================================
   FLOATING MENU & BAR
   ============================================================================ */
.floating-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: rgba(51, 51, 51, 0.8); /* Semi-transparent background */
    padding: 4px;
    display: flex;
    justify-content: center;
    z-index: 1000;
}

.floating-menu a {
    color: #fff;
    text-decoration: none;
    padding: 5px 16px; /* Reduced padding for minimal look */
    margin: 0 5px; /* Reduced margin for minimal look */
    border-radius: 4px;
    font-weight: bold;
    transition: background-color 0.3s;
}

.floating-menu a:hover {
    background-color: rgba(85, 85, 85, 0.8); /* Semi-transparent hover effect */
}

/* Floating Bar */
.floating-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: rgba(51, 51, 51, 0.8); /* Semi-transparent background */
    padding: 8px; /* Reduced padding for minimal look */
    display: flex;
    justify-content: center;
    z-index: 1000;
}

.timestamp {
    color: #fff;
    font-weight: bold;
    font-size: 14px; /* Slightly smaller font size for minimal look */
}

/* ============================================================================
   MATCH SECTION
   ============================================================================ */
.match-section {
    padding: 10px;
    max-width: 1200px;
    margin: 50px auto 30px auto; /* Adjust margin to account for floating menu and bar */
}

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

.header-title {
    font-size: 24px;
    font-weight: bold;
    color: #333;
    align-self: center;
}

/* ============================================================================
   TABLE STYLES
   ============================================================================ */
.match-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.match-table caption {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 6px;
    text-align: left;
}

.match-table th,
.match-table td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: center;
}

.match-table th {
    background-color: #f4f4f4;
    color: #333;
    font-weight: bold;
    font-size: 18px;
}

.match-table tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

.match-table tbody tr:hover {
    background-color: #eaeaea;
}

/* Column Widths */
.match-table th:nth-child(1),
.match-table td:nth-child(1) {
    width: 30%;
}

.match-table th:nth-child(2),
.match-table td:nth-child(2) {
    width: 40%;
}

.match-table th:nth-child(3),
.match-table td:nth-child(3) {
    width: 30%;
}

/* Match table enhancements (from displayMatches.php) */
.match-table td:first-child {
    border-left: 4px solid rgba(255, 0, 0, 0.5);
}

.match-table td:last-child {
    border-right: 4px solid rgba(200, 200, 200, 0.5);
}

.match-table th:first-child {
    color: rgb(255, 90, 90);  /* Light red */
}

.match-table th:last-child {
    color: #aaaaaa;  /* Bright white */
}

/* ============================================================================
   MATCH INFO STYLES
   ============================================================================ */
.match-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px;
    background: linear-gradient(to right, rgba(255, 0, 0, 0.2), transparent);
    border-radius: 6px;
}

.match-info.right {
    background: linear-gradient(to left, rgba(100, 100, 100, 0.1), transparent);
}

.photo-flag-container {
    position: relative;
}

.player-photo {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 2px solid #ddd;
    object-fit: cover;
}

.flag {
    border: 2px solid #fff;
}

.red-flag {
    position: absolute;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    bottom: 6px;
    left: 100%;
    transform: translateX(-50%);
    border-color: red;
}

.white-flag {
    position: absolute;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    bottom: 0px;
    left: 0%;
    transform: translateX(-50%);
    border-color: white;
}

.player-name {
    font-size: 18px;
    color: #333;
    text-align: center;
    line-height: 1.3;
    margin: 2px 0;
}

.player-name strong {
    display: block;
    font-size: 20px;
    color: #222;
}

/* Center Column texts */
.category {
    font-size: 24px;
    color: #333;
    text-align: center;
    font-weight: bold;
    margin: 2px 0;
}

.court {
    font-size: 16px;
    color: #333;
    text-align: center;
    margin: 1px 0;
}

.status {
    font-size: 16px;
    color: #333;
    text-align: center;
    margin: 1px 0;
}

.match-number {
    font-size: 16px;
    color: #333;
    text-align: center;
    margin: 1px 0;
}

.fight-index {
    font-size: 14px;
    color: #666;
    text-align: center;
    margin: 1px 0;
}

/* Winner Highlight */
.winner {
    background-color: lightblue;
    border: 2px solid #c3e6cb;
    border-radius: 5px;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);  /* Golden glow */
}

/* Match Details Styles */
.match-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0px;
    background-color: #f9f9f9;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    width: 100%; /* Ensure it takes full width */
}

.red-flags {
    flex: 1; /* Allows this section to take up available space */
    text-align: center;
    font-size: 36px;
    color: #222;
    font-weight: bold;
}

.details-container {
    flex: 2; /* Allows this section to be centered and take more space */
    text-align: center;
}

.white-flags {
    flex: 1; /* Allows this section to take up available space */
    text-align: center;
    font-size: 36px;
    color: #222;
    font-weight: bold;
}

/* ============================================================================
   OVERLAY PAGE STYLES (currentMatchOverlay.php)
   ============================================================================ */
/* Bottom section (players + center box) */
.bottom-quarter {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 25vh;
    display: flex;
    align-items: center;
    justify-content: space-between;
    pointer-events: none;
    padding: 0 50px;
}

.bottom-quarter #currentMatch {
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

/* Center match info box */
.topbar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.9);
    padding: 12px 30px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    border: 2px solid #c62828;
    pointer-events: auto;
}

.corner-logo {
    width: 180px;
    height: auto;
    pointer-events: none;
}

.logo-info {
    color: #fff;
    font-weight: bold;
    line-height: 1.4;
    text-align: center;
}

.logo-info .title { 
    font-size: 28px; 
}

.logo-info .row { 
    font-size: 24px; 
}

/* Player containers for overlay */
body.overlay-page .player-container {
    padding: 10px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 30%;
    position: relative;
    overflow: hidden;
    transform: scale(0.9);
}

body.overlay-page .player-container::before {
    content: '';
    position: absolute;
    top: 0; 
    left: 0; 
    right: 0; 
    bottom: 0;
    background: url('Media/Logos/Iso.png') center / 100% no-repeat;
    opacity: 0.08;
    filter: grayscale(100%);
    pointer-events: none;
}

body.overlay-page .player-container.red {
    background-color: lightgray;
    border: 5px solid red;
    justify-content: flex-end;
}

body.overlay-page .player-container.white {
    background-color: darkgray;
    border: 5px solid white;
    justify-content: flex-start;
}

body.overlay-page .player-photo {
    width: 130px;
    height: 130px;
    object-fit: cover;
    border-radius: 50%;
}

body.overlay-page .photo-flag-container {
    position: relative;
    width: 150px;
    height: 150px;
    flex-shrink: 0;
    display: flex;
    justify-content: flex-end;
    align-items: flex-end;
}

body.overlay-page .flag {
    width: 50px;
    height: 50px;
    position: absolute;
    bottom: 0px;
    border-radius: 50%;
}

body.overlay-page .red-flag { 
    left: -10px; 
    border-color: red; 
}

body.overlay-page .white-flag { 
    left: 100%;
    transform: translateX(-50%);
    border-color: white; 
}

.player-info { 
    line-height: 1.3; 
}

/* Player Screen (playerScreen.php) */
.player-search {
    padding: 20px;
    text-align: center;
    display: flex;
    gap: 16px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

.player-search-input {
    font-size: 16px;
    padding: 8px 12px;
    min-width: 320px;
    border-radius: 5px;
}

.player-info-card {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 10px;
    margin-bottom: 20px;
}

.player-info-photo {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 50%;
    border: 3px solid #ddd;
}

.player-info-name {
    margin: 0 0 10px 0;
    font-size: 28px;
}

.player-info-id {
    font-size: 14px;
    color: #888;
    margin: 0 0 8px 0;
}

.player-info-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 5px;
}

.player-info-flag {
    width: 30px;
    height: 20px;
    border-radius: 3px;
}

.player-info-country {
    font-size: 18px;
}

.player-info-category {
    font-size: 16px;
    color: #666;
    margin-top: 5px;
}

/* Compact adjustments for playerScreen only */
body.player-screen .player-search { padding: 12px; gap: 8px; }
body.player-screen .player-search-input { min-width: 280px; padding: 6px 10px; }
body.player-screen .player-info-card { padding: 12px; gap: 12px; margin-bottom: 12px; }
body.player-screen .player-info-photo { width: 96px; height: 96px; border-width: 2px; }
body.player-screen .player-info-name { font-size: 22px; margin-bottom: 6px; }
body.player-screen .player-info-id { font-size: 12px; margin-bottom: 6px; }
body.player-screen .player-info-row { gap: 8px; margin-bottom: 4px; }
body.player-screen .player-info-flag { width: 24px; height: 16px; }
body.player-screen .player-info-country { font-size: 16px; }
body.player-screen .player-info-category { font-size: 14px; margin-top: 4px; }

/* Compact match table inside player screen */
body.player-screen .match-table th, 
body.player-screen .match-table td { padding: 6px 8px; }

/* Announcer Screen Specific Styles */
.announcer-table th {
    background-color: #2c3e50;
    color: #fff;
    font-weight: bold;
    letter-spacing: 0.5px;
}

.announcer-table tbody tr {
    background-color: #fff;
}

.announcer-table tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}

.announcer-table tbody tr:hover {
    background-color: #e8f4f8;
}
body.player-screen .player-photo { width: 64px; height: 64px; }
body.player-screen .flag { width: 24px; height: 24px; }
body.player-screen .match-info .player-name { font-size: 16px; }
body.player-screen .match-details .details-container div { font-size: 12px; }

.player-info.left { 
    text-align: left; 
}

.player-info.right { 
    text-align: right; 
}

body.overlay-page .player-name {
    font-size: 32px;
    font-weight: bold;
    margin: 0;
}

.player-country {
    font-size: 20px;
    font-weight: bold;
    margin: 0;
}

.player-points {
    font-size: 100px;
    font-weight: bold;
    margin: 0;
    text-align: right;
}

.red-text { 
    color: red; 
}

.white-text { 
    color: white; 
}

@keyframes slideOutFade {
    from { 
        opacity: 1; 
        transform: translateY(0); 
    }
    to { 
        opacity: 0; 
        transform: translateY(-40px); 
    }
}

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

.animate-out { 
    animation: slideOutFade 0.9s ease-out forwards; 
}

.animate-in { 
    animation: slideInFade 0.9s ease-out forwards; 
}

/* Overlay animation for data changes - using movement instead of highlight */
@keyframes slideInFromRight {
    0% {
        opacity: 0;
        transform: translateX(40px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInFromLeft {
    0% {
        opacity: 0;
        transform: translateX(-40px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideUp {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.3);
    }
}

body.overlay-page .animate-change {
    animation: slideUp 0.6s ease-out;
}

body.overlay-page [data-field="name1"].animate-change,
body.overlay-page [data-field="country1"].animate-change {
    animation: slideInFromRight 0.6s ease-out;
}

body.overlay-page [data-field="name2"].animate-change,
body.overlay-page [data-field="country2"].animate-change {
    animation: slideInFromLeft 0.6s ease-out;
}

body.overlay-page .topbar .animate-change,
body.overlay-page .topbar.animate-change {
    animation: slideUp 0.6s ease-out;
}

body.overlay-page .player-points.animate-change {
    animation: pulse 0.7s ease-out;
}

/* Previous Match Results Box */
.previous-match-results {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 2000;
    padding: 5px 5px;
    opacity: 0;
    transform: translateY(-100px);
    pointer-events: none;
    transition: opacity 0.9s ease-out, transform 0.9s ease-out;
    display: flex;
    justify-content: flex-end;
}

.previous-match-results.animate-in {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.previous-match-results.animate-out {
    opacity: 0;
    transform: translateY(-100px);
}

.previous-match-container {
    display: flex;
    flex-direction: column;
    width: 1500px;
    gap: 0;
    border: 0px solid #0d47a1;
    border-radius: 10px;
    padding: 10px;
    position: relative;
}

.previous-match-content-wrapper {
    display: flex;
    align-items: stretch;
    justify-content: flex-end;
    width: 100%;
    gap: 0;
}

.previous-match-title {
    font-size: 24px;
    font-weight: bold;
    color: #fff;
    text-align: right;
    padding: 8px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 8px;
    position: absolute;
    bottom: -10px;
    right: 10px;
    margin: 0;
}

/* Scale down the previous match display to fit in the box */
.previous-match-container .player-container {
    transform: scale(1);
    transform-origin: top center;
}

.previous-match-container .topbar {
    transform: scale(1);
    transform-origin: top center;
}

/* ============================================================================
   IFRAME LAYOUT STYLES (for multi-court display pages)
   ============================================================================ */
.iframe-container {
    position: absolute;
    width: 50%;
    height: 50%;
}

/* Positioning each iframe in the corners */
.iframe-container:nth-child(1) {
    top: 0;
    left: 0;
}

.iframe-container:nth-child(2) {
    top: 0;
    right: 0;
}

.iframe-container:nth-child(3) {
    bottom: 0;
    left: 0;
}

.iframe-container:nth-child(4) {
    bottom: 0;
    right: 0;
}

iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* ============================================================================
   RESPONSIVE STYLES
   ============================================================================ */
@media (max-width: 768px) {
    .match-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .timestamp {
        margin-top: 10px;
    }

    .match-info {
        flex-direction: column;
        align-items: center;
    }

    .photo-flag-container {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .player-photo {
        margin-bottom: 6px;
        width: 100px;
        height: 100px;
    }
}

@media (max-width: 480px) {
    .player-photo {
        width: 80px;
        height: 80px;
    }

    .flag {
        width: 28px;
        height: 28px;
    }
}
