/* styles.css - consolidated & cleaned header, buttons, profile menu, tables, modal, etc. */

/* Palette */
:root {
    --bg: #1e1e2f;
    --header: #2a2a3d;
    --accent: #f5c518;
    --muted: #3a3a4f;
    --panel: #141414;
    --table-bg: #2a2a3d;
    --text: #ffffff;
}

/* Base */
html,
body {
    height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, "Segoe UI", Roboto, Helvetica, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Header: buttons on the left, logo on the right
   HTML order should be:
   <header>
     <div class="buttons" id="header-buttons"></div>
     <div class="logo">LibyanLegends</div>
   </header>
*/
header {
    background: var(--header);
    padding: 8px 12px;
    /* compact so items sit near edges */
    display: flex;
    justify-content: space-between;
    /* .buttons left, .logo right */
    align-items: center;
    gap: 12px;
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25);
}

/* Buttons container */
.buttons {
    display: flex;
    align-items: center;
    gap: 8px;
    /* even spacing */
    margin: 0;
    padding: 0;
    flex-wrap: nowrap;
    /* allow wrap via media query if needed */
}

/* Generic header button */
.header-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 12px;
    min-width: 88px;
    height: 36px;
    border-radius: 8px;
    border: 2px solid transparent;
    background: var(--accent);
    color: #0b0b0b;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    line-height: 1;
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.18);
    transition: transform .06s ease, filter .06s ease, box-shadow .06s ease;
}

/* Small variant (login/register) */
.header-btn.small {
    min-width: 68px;
    padding: 6px 10px;
    font-weight: 600;
}

/* Hover / active */
.header-btn:hover {
    transform: translateY(-1px);
    filter: brightness(.98);
}

.header-btn:active {
    transform: translateY(0);
}

/* Back button style (used on inner pages) */
.back-btn {
    padding: 8px 12px;
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 700;
}

/* Profile icon & dropdown */
.profile-wrapper {
    position: relative;
    display: inline-block;
    margin: 0;
    /* ensure flush with other buttons */
    padding: 0;
}

.profile-button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--accent);
    background-color: #1e1e2f;
    color: var(--accent);
    cursor: pointer;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

/* Dropdown opens to the right of the icon (left anchored) */
.profile-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    /* align left edge of menu to profile-wrapper */
    right: auto;
    transform-origin: left top;
    background: var(--header);
    border: 1px solid #444;
    border-radius: 6px;
    min-width: 150px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    display: none;
    z-index: 1200;
}

.profile-menu.open {
    display: block;
}

.profile-menu>* {
    white-space: nowrap;
}

.profile-menu button,
.profile-menu div {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text);
    padding: 8px 12px;
    text-align: left;
    cursor: pointer;
    font-size: 14px;
}

.profile-menu button:hover {
    background: var(--muted);
}

/* Logo (right) */
.logo {
    font-size: 22px;
    font-weight: 700;
    color: var(--accent);
    margin-left: 12px;
    user-select: none;
}

/* Ranking table on home */
.ranking-table {
    width: 60%;
    border-collapse: collapse;
    margin: 0 auto;
}

.ranking-table th,
.ranking-table td {
    padding: 15px;
    text-align: left;
}

.ranking-table th {
    border-bottom: 2px solid var(--accent);
    font-size: 18px;
}

.ranking-table td img {
    width: 40px;
    height: 40px;
    vertical-align: middle;
    margin-right: 10px;
}

.player-row {
    border-bottom: 1px solid #444;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.modal {
    background: var(--header);
    border-radius: 10px;
    padding: 20px 24px;
    min-width: 280px;
    max-width: 520px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
    color: var(--text);
}

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

.modal-title {
    font-size: 20px;
    font-weight: 700;
}

.modal-close {
    cursor: pointer;
    font-size: 18px;
    border: none;
    background: transparent;
    color: var(--text);
}

.modal-body p {
    margin: 6px 0;
}

.modal-body a {
    color: var(--accent);
    text-decoration: none;
}

.modal-body a:hover {
    text-decoration: underline;
}

.modal-avatar {
    display: block;
    margin: 0 auto 10px auto;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent);
}

/* Leaderboard / tables (shared) */
.leaderboard-container {
    width: 90%;
    max-width: 1000px;
    margin: 28px auto;
    background: var(--panel);
    padding: 18px;
    border-radius: 12px;
    border: 2px solid #333;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
}

.leaderboard {
    width: 100%;
    border-collapse: collapse;
    font-size: 16px;
}

.leaderboard thead {
    background: #222;
}

.leaderboard thead th {
    padding: 14px;
    font-weight: 700;
    border-bottom: 2px solid #555;
}

.leaderboard-row td {
    padding: 12px;
    border-bottom: 1px solid #333;
}

/* Rank icons */
.rank-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.rank-icon {
    width: 35px;
    height: 35px;
    object-fit: contain;
}

/* Top highlights (consistent definitions) */
.first-place {
    background: rgba(255, 215, 0, 0.08);
}

.second-place {
    background: rgba(192, 192, 192, 0.06);
}

.third-place {
    background: rgba(205, 127, 50, 0.06);
}

/* Hover rows */
.leaderboard-row:hover,
.player-row:hover {
    background: rgba(255, 255, 255, 0.03);
}

/* Responsive */
@media (max-width:900px) {
    .ranking-table {
        width: 90%;
    }

    .header-btn {
        min-width: 72px;
        padding: 6px 10px;
    }
}

@media (max-width:720px) {
    header {
        padding: 10px;
    }

    .buttons {
        gap: 6px;
        flex-wrap: wrap;
    }

    .header-btn {
        min-width: 76px;
        padding: 6px 10px;
    }

    .logo {
        font-size: 18px;
    }

    .ranking-table {
        width: 100%;
    }
}

/* Utility / small elements */
.small-muted {
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
}

.center {
    text-align: center;
}

header {
    padding-left: 6px !important;
    /* very small padding so elements aren't touching the browser edge */
    padding-right: 6px !important;
}

/* Guarantee .buttons container is exactly at the left edge of the header */
.buttons {
    margin-left: 0 !important;
    padding-left: 0 !important;
}

/* Ensure profile wrapper/icon has no extra left margin */
.profile-wrapper {
    margin-left: 0 !important;
    padding-left: 0 !important;
}

/* If any other rules apply margin-left to .buttons button, override them */
.buttons .header-btn,
.buttons button,
.profile-button {
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* If some global container is centering children (like .container or .site),
   make header full width and remove its inner content padding: */
header {
    width: 100%;
    box-sizing: border-box;
}

/* Override to force the header/buttons flush to the page edges.
   Place this file at the end of your styles (or paste the rules at the
   very end of styles.css) so it overrides earlier rules. */

:root {
    --header-flush-padding: 6px;
}

/* Ensure body has no default margin (important) */
body {
    margin: 0 !important;
    box-sizing: border-box;
}

/* Make header full width and use small edge padding */
header {
    width: 100% !important;
    box-sizing: border-box !important;
    padding-left: var(--header-flush-padding) !important;
    padding-right: var(--header-flush-padding) !important;
}

/* Remove any leftover left padding/margin from .buttons and profile wrapper */
.buttons {
    margin-left: 0 !important;
    padding-left: 0 !important;
}

/* Ensure individual header buttons have no external margins */
.buttons .header-btn,
.buttons button,
.profile-button {
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* Make profile wrapper flush with other buttons */
.profile-wrapper {
    margin-left: 0 !important;
    padding-left: 0 !important;
}