/* ========== Shared: Page Header ========== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.page-header h1 {
    margin: 0;
    font-size: 1.8rem;
    color: #ffffff;
}

/* ========== Buttons ========== */
.btn-join {
    background-color: #00ffaa;
    color: #0f0f1a;
    border: none;
    border-radius: 6px;
    font-weight: 600;
}

.btn-join:hover {
    background-color: #00ddaa;
}

.btn-filter {
    background-color: #2a2a3a;
    color: #e0e0f0;
    border: 1px solid #3a3a4a;
}

.btn-filter:hover {
    background-color: #3a3a4a;
}

.btn-send {
    background-color: #00ffaa;
    color: #0f0f1a;
    padding: 0.5rem 1rem;
}

.btn-ready-toggle {
    background-color: transparent;
    color: #00aaff;
    border: 1px solid #00aaff;
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
    border-radius: 4px;
    cursor: pointer;
}

.btn-ready-toggle:hover {
    background-color: #00aaff;
    color: #0f0f1a;
}

.btn[disabled] {
    background-color: #555;
    color: #aaa;
    cursor: not-allowed;
    opacity: 0.6;
}

/* ========== Filter Bar ========== */
.filter-bar {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background-color: #1e1e2e;
    border-radius: 8px;
}

.filter-form {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.filter-group label {
    font-size: 0.8rem;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-group select {
    background-color: #2a2a3a;
    color: #e0e0f0;
    border: 1px solid #3a3a4a;
    border-radius: 5px;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    min-width: 160px;
}

/* ========== Tournament Grid (Small Cards) ========== */
.tournament-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 1rem;
}

.tournament-card-link {
    text-decoration: none;
    color: inherit;
}

/* --- Tournament Card (compact, image on top) --- */
.t-card {
    background-color: #2a2a3a;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    position: relative;
    border: 1px solid transparent;
}

.t-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 255, 170, 0.12);
    border-color: rgba(0, 255, 170, 0.25);
}

/* Game image: full width, aspect ratio preserved */
.t-card-image {
    width: 100%;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    background-color: #1e1e2e;
    flex-shrink: 0;
}

.t-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Card body under the image */
.t-card-body {
    padding: 0.6rem 0.75rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}

.t-card-name {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.t-card-game {
    display: block;
    font-size: 0.75rem;
    color: #00aaff;
    line-height: 1.2;
}

.t-card-format {
    display: none; /* hidden on compact cards */
}

/* Slot bar */
.t-card-slot-bar {
    width: 100%;
    height: 4px;
    background-color: #1e1e2e;
    border-radius: 2px;
    overflow: hidden;
    margin-top: 0.25rem;
}

.t-card-slot-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s ease;
}

.t-card-slot-fill.slots-open {
    background-color: #00ffaa;
}

.t-card-slot-fill.slots-full {
    background-color: #ff5555;
}

.t-card-slot-fill.slots-joined {
    background-color: #00aaff;
}

.t-card-slots-text {
    font-size: 0.7rem;
    color: #999;
    margin-top: 0.15rem;
}

/* Card footer (badge + ranked star) */
.t-card-footer {
    padding: 0.4rem 0.75rem 0.6rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.t-card-ranked {
    color: #ffd700;
    font-size: 0.9rem;
    position: absolute;
    top: 6px;
    right: 6px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

/* ========== Status Badges ========== */
.t-card-badge,
.td-card-badge,
.tmd-t-badge {
    display: inline-block;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-registration {
    background-color: rgba(0, 170, 255, 0.15);
    color: #00aaff;
}

.status-active {
    background-color: rgba(0, 255, 170, 0.15);
    color: #00ffaa;
}

.status-finished {
    background-color: rgba(102, 102, 102, 0.2);
    color: #666;
}

/* ========== Empty State ========== */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem;
    color: #666;
    font-size: 1.1rem;
}

/* ========== Tournament Detail ========== */
.tournament-detail {
    max-width: 900px;
}

.td-header {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #2a2a3a;
}

.td-header-icon {
    width: 100px;
    height: 100px;
    border-radius: 12px;
    overflow: hidden;
    background-color: #1e1e2e;
    flex-shrink: 0;
}

.td-header-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.td-header-info h1 {
    margin: 0 0 0.5rem 0;
    font-size: 1.6rem;
    color: #ffffff;
}

.td-meta-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.td-meta-item {
    color: #aaa;
    font-size: 0.9rem;
}

.td-meta-sep {
    color: #444;
}

.td-slots {
    font-size: 0.9rem;
    color: #e0e0f0;
}

.td-team-size {
    font-size: 0.85rem;
    color: #00aaff;
}

/* ========== Actions ========== */
.td-actions,
.tmd-actions {
    margin-bottom: 1.5rem;
    display: flex;
    gap: 1rem;
    align-items: center;
}

.td-action-form,
.tmd-action-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.td-team-select {
    background-color: #2a2a3a;
    color: #e0e0f0;
    border: 1px solid #3a3a4a;
    border-radius: 5px;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
}

.td-bracket-link {
    margin-bottom: 1.5rem;
}

.tmd-captain-note {
    color: #888;
    font-size: 0.9rem;
    font-style: italic;
}

/* ========== Section Headings ========== */
.td-section,
.tmd-section {
    margin-bottom: 2rem;
}

.td-section h2,
.tmd-section h2 {
    font-size: 1.2rem;
    color: #00ffaa;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #2a2a3a;
}

.td-empty,
.tmd-empty {
    color: #666;
    font-style: italic;
}

/* ========== Player List ========== */
.td-player-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.td-player-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.8rem;
    background-color: #1e1e2e;
    border-radius: 6px;
}

.td-player-info {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.td-player-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    background-color: #2a2a3a;
}

.td-player-name {
    font-weight: 500;
    color: #e0e0f0;
}

.td-player-team {
    color: #00aaff;
    font-size: 0.85rem;
    margin-left: 0.3rem;
}

.td-player-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ready-dot {
    font-size: 0.7rem;
}

.ready-dot.ready {
    color: #00ffaa;
}

.ready-dot.not-ready {
    color: #ff5555;
}

.td-ready-form {
    display: inline;
}

/* ========== Chat ========== */
.td-chat {
    background-color: #1e1e2e;
    border-radius: 8px;
    overflow: hidden;
}

.td-chat-messages {
    padding: 1rem;
    max-height: 300px;
    overflow-y: auto;
}

.td-chat-form {
    display: flex;
    border-top: 1px solid #2a2a3a;
}

.td-chat-form input {
    flex: 1;
    background-color: #2a2a3a;
    color: #e0e0f0;
    border: none;
    padding: 0.7rem 1rem;
    font-size: 0.9rem;
}

.td-chat-form input:focus {
    outline: none;
    background-color: #333344;
}

/* ========== Create Form ========== */
.tournament-create,
.team-create {
    max-width: 600px;
}

.tournament-create h1,
.team-create h1 {
    font-size: 1.6rem;
    color: #ffffff;
    margin-bottom: 1.5rem;
}

.create-form {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.form-group label {
    font-size: 0.85rem;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input,
.form-group select {
    background-color: #2a2a3a;
    color: #e0e0f0;
    border: 1px solid #3a3a4a;
    border-radius: 6px;
    padding: 0.6rem 0.75rem;
    font-size: 0.95rem;
    transition: border-color 0.2s ease;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #00ffaa;
}

.form-group input[type="file"] {
    padding: 0.5rem;
}

.form-group input[type="file"]::file-selector-button {
    background-color: #2a2a3a;
    color: #e0e0f0;
    border: 1px solid #3a3a4a;
    border-radius: 4px;
    padding: 0.3rem 0.8rem;
    cursor: pointer;
    margin-right: 0.5rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
}

/* ========== Team Grid ========== */
.team-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.team-card-link {
    text-decoration: none;
    color: inherit;
}

.tm-card {
    background-color: #1e1e2e;
    border-radius: 10px;
    padding: 1rem;
    display: flex;
    gap: 1rem;
    align-items: center;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    border: 1px solid transparent;
}

.tm-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 255, 170, 0.1);
    border-color: #00ffaa33;
}

.tm-card-tag {
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    border-radius: 8px;
    background-color: #00ffaa15;
    color: #00ffaa;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 1px;
}

.tm-card-info {
    flex: 1;
    min-width: 0;
}

.tm-card-name {
    margin: 0 0 0.3rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: #ffffff;
}

.tm-card-meta {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.tm-card-members {
    font-size: 0.85rem;
    color: #e0e0f0;
}

.member-icon {
    color: #00aaff;
    font-size: 0.6rem;
    vertical-align: middle;
    margin-right: 2px;
}

.tm-card-captain {
    font-size: 0.8rem;
    color: #888;
}

/* ========== Team Detail ========== */
.team-detail {
    max-width: 800px;
}

.tmd-header {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #2a2a3a;
}

.tmd-tag-badge {
    width: 80px;
    height: 80px;
    border-radius: 12px;
    background-color: #00ffaa15;
    color: #00ffaa;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.4rem;
    letter-spacing: 2px;
    flex-shrink: 0;
}

.tmd-header-info h1 {
    margin: 0 0 0.3rem 0;
    font-size: 1.6rem;
    color: #ffffff;
}

.tmd-member-count {
    color: #aaa;
    font-size: 0.9rem;
    margin-right: 1rem;
}

.tmd-captain {
    color: #00aaff;
    font-size: 0.9rem;
}

/* ========== Member List ========== */
.tmd-member-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tmd-member-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.8rem;
    background-color: #1e1e2e;
    border-radius: 6px;
}

.tmd-member-info {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.tmd-member-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    background-color: #2a2a3a;
}

.tmd-member-name {
    font-weight: 500;
    color: #e0e0f0;
}

.tmd-member-role {
    font-size: 0.8rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
}

.role-captain {
    background-color: rgba(255, 215, 0, 0.15);
    color: #ffd700;
}

.role-member {
    background-color: rgba(0, 170, 255, 0.1);
    color: #00aaff;
}

/* ========== Tournament History (Team Detail) ========== */
.tmd-tournament-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tmd-tournament-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.8rem;
    background-color: #1e1e2e;
    border-radius: 6px;
    text-decoration: none;
    color: inherit;
    transition: background-color 0.15s ease;
}

.tmd-tournament-row:hover {
    background-color: #252535;
}

.tmd-t-name {
    font-weight: 500;
    color: #e0e0f0;
}

.tmd-t-game {
    color: #00aaff;
    font-size: 0.85rem;
}

/* ========== Responsive ========== */
@media (max-width: 1024px) {
    .tournament-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

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

@media (max-width: 640px) {
    .tournament-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .team-grid {
        grid-template-columns: 1fr;
    }

    .td-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .td-meta-row {
        justify-content: center;
    }

    .tmd-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .filter-form {
        flex-direction: column;
    }

    .filter-group select {
        min-width: auto;
        width: 100%;
    }

    .form-actions {
        flex-direction: column;
    }

    .td-actions,
    .tmd-actions {
        flex-direction: column;
    }
}
