/* assets/css/style.css */

:root {
    --primary: #072d46;
    --primary-dark: #001832;
    --secondary: #0f74b4;
    --success: #16a34a;
    --danger: #dc266c;
    --warning: #ea580c;
    --light: #f1f5f9;
    --dark: #072d46;
    --border: #e2e8f0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--light);
    color: var(--dark);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    background: var(--primary);
    color: white;
    padding: 20px 0;
    margin-bottom: 30px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.header h1 {
    font-size: 1.8rem;
    font-weight: 700;
}

.header-logo {
    height: 96px;
    width: auto;
    object-fit: contain;
}

.header p {
    opacity: 0.9;
    margin-top: 5px;
}

/* Cards */
.card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.card-header {
    border-bottom: 2px solid var(--border);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.card-header h2 {
    font-size: 1.5rem;
    color: var(--primary);
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--dark);
}

.form-control {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
}

.form-control:disabled {
    background: var(--light);
    cursor: not-allowed;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
}

@media (min-width: 768px) {
    .form-row {
        grid-template-columns: 1fr 1fr;
    }

    .form-row-3 {
        grid-template-columns: 2fr 1fr 1fr;
    }
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    text-align: center;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #15803d;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #b91c1c;
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-warning:hover:not(:disabled) {
    background: #c2410c;
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #475569;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.875rem;
}

.btn-block {
    width: 100%;
}

.btn-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    margin: 20px 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

thead {
    background: var(--light);
}

th,
td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    font-weight: 600;
    color: var(--dark);
    white-space: nowrap;
}

tr:hover {
    background: #f8fafc;
}

.text-center {
    text-align: center !important;
}

.text-right {
    text-align: right !important;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: #dcfce7;
    color: #15803d;
}

.badge-danger {
    background: #fee2e2;
    color: #b91c1c;
}

.badge-warning {
    background: #fed7aa;
    color: #c2410c;
}

.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

/* Match Cards */
.match-card {
    background: white;
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

.match-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.table-number {
    font-weight: 700;
    color: var(--primary);
    font-size: 1.1rem;
}

.match-players {
    display: grid;
    gap: 10px;
}

.player-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: var(--light);
    border-radius: 6px;
}

.player-info {
    flex: 1;
}

.player-name {
    font-weight: 600;
    font-size: 1rem;
}

.player-deck {
    font-size: 0.875rem;
    color: var(--secondary);
}

.score-input {
    width: 60px;
    padding: 8px;
    text-align: center;
    border: 2px solid var(--border);
    border-radius: 6px;
    font-size: 1.1rem;
    font-weight: 600;
}

.score-display {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    min-width: 40px;
    text-align: center;
}

.winner-indicator {
    background: var(--success);
    color: white;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 600;
}

/* Alerts */
.alert {
    padding: 15px 20px;
    border-radius: 6px;
    margin-bottom: 20px;
}

.alert-success {
    background: #dcfce7;
    color: #15803d;
    border-left: 4px solid var(--success);
}

.alert-danger {
    background: #fee2e2;
    color: #b91c1c;
    border-left: 4px solid var(--danger);
}

.alert-warning {
    background: #fed7aa;
    color: #c2410c;
    border-left: 4px solid var(--warning);
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border-left: 4px solid var(--primary);
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid var(--primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--secondary);
    margin-bottom: 5px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

/* Standings Table */
.standings-table td:first-child {
    font-weight: 700;
    color: var(--primary);
}

.top-position {
    background: #fef3c7 !important;
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--secondary);
}

/* Utilities */
.mt-1 {
    margin-top: 10px;
}

.mt-2 {
    margin-top: 20px;
}

.mt-3 {
    margin-top: 30px;
}

.mb-1 {
    margin-bottom: 10px;
}

.mb-2 {
    margin-bottom: 20px;
}

.mb-3 {
    margin-bottom: 30px;
}

.hidden {
    display: none;
}

.text-muted {
    color: var(--secondary);
}

.text-sm {
    font-size: 0.875rem;
}

.text-lg {
    font-size: 1.125rem;
}

.font-bold {
    font-weight: 700;
}

/* Print Styles */
@media print {
    .no-print {
        display: none;
    }

    .card {
        box-shadow: none;
        border: 1px solid var(--border);
    }

    body {
        background: white;
    }
}

/* Responsive */
/* Bottom Navigation */
.mobile-bottom-nav {
    display: none;
    /* Oculto por defecto en desktop */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 65px;
    background: white;
    box-shadow: 0 -2px 15px rgba(0, 0, 0, 0.08);
    justify-content: space-around;
    align-items: center;
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid var(--border);
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #64748b;
    font-size: 0.7rem;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    gap: 4px;
}

.bottom-nav-item.active {
    color: var(--primary);
}

.bottom-nav-item svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    transition: transform 0.2s;
}

.bottom-nav-item.active svg {
    transform: translateY(-2px);
    stroke: var(--primary);
}

/* More Menu Styles */
#more-nav-trigger {
    position: relative;
    cursor: pointer;
}

.more-menu-container {
    display: none;
    position: absolute;
    bottom: 75px;
    right: 10px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    width: 160px;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border);
    z-index: 1001;
}

.more-menu-container.show {
    display: flex;
}

.more-menu-container a {
    padding: 12px 20px;
    text-decoration: none;
    color: var(--dark);
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    transition: background 0.2s;
}

.more-menu-container a:last-child {
    border-bottom: none;
}

.more-menu-container a:hover {
    background: var(--light);
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    .header h1 {
        font-size: 1.2rem;
    }

    .header p {
        font-size: 0.85rem;
        display: none;
        /* Limpiamos el header ocultando el subtitulo en móvil */
    }

    .header .container a {
        gap: 10px !important;
    }

    .header img {
        height: 68px !important;
        /* Logo más grande para no perder detalle */
    }

    .mobile-hide {
        display: none !important;
    }

    .card {
        padding: 15px;
    }

    table {
        font-size: 0.875rem;
    }

    th,
    td {
        padding: 8px;
    }

    .btn-group {
        flex-direction: column;
    }

    .btn:not(.t-card-top .btn) {
        width: 100%;
    }

    .match-card {
        padding: 12px;
    }

    .player-row {
        grid-template-columns: 1fr auto;
        gap: 5px;
        padding: 8px;
    }

    .player-name {
        font-size: 0.9rem;
    }

    .score-input {
        width: 50px;
        padding: 6px;
        font-size: 1rem;
    }

    /* Bottom Nav visibility */
    .mobile-bottom-nav {
        display: flex;
    }

    body {
        padding-bottom: 80px;
        /* Espacio para que el bottom nav no tape contenido */
    }

    .text-justify-mobile {
        text-align: justify;
    }

    .filter-dropdown-mobile {
        display: block !important;
    }
}

/* Mobile filter dropdown - hidden by default on desktop */
.filter-dropdown-mobile {
    display: none;
}

/* Footer */
.footer {
    background: var(--primary);
    color: white;
    padding: 25px 0 15px;
    margin-top: 40px;
    text-align: center;
}

@media (max-width: 768px) {
    .footer {
        display: none;
        /* Ocultamos el footer en móvil ya que tenemos el bottom nav */
    }
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.footer-logo {
    font-size: 1.1rem;
    font-weight: 700;
}

.footer-menu {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
    list-style: none;
    margin: 5px 0;
    padding: 0;
}

.footer-menu a,
.footer-menu a:visited {
    color: white !important;
    text-decoration: none;
    font-size: 0.9rem;
    opacity: 0.8;
    transition: opacity 0.3s;
}

.footer-menu a:hover {
    opacity: 1;
}

.footer-copyright {
    font-size: 0.75rem;
    opacity: 0.6;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 15px;
    width: 100%;
}

@media (max-width: 768px) {
    .footer-menu {
        flex-direction: column;
        gap: 10px;
    }

    .footer {
        padding-bottom: 20px;
        /* Ya tenemos el nav fijo */
    }
}

/* Standings Mobile Cards */
.standings-mobile-list {
    display: none;
}

@media (max-width: 768px) {
    .standings-table-container {
        display: none;
    }

    .standings-mobile-list {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .standing-card {
        background: white;
        border: 1px solid var(--border);
        border-radius: 8px;
        padding: 10px 12px;
        display: grid;
        grid-template-columns: auto 1fr auto;
        align-items: center;
        gap: 12px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
        position: relative;
        overflow: hidden;
    }

    /* Top Cut Highlight */
    .standing-card.top-position {
        border: 1px solid #fcd34d;
        background: linear-gradient(to right, #fffbeb, #ffffff);
    }

    .standing-card.top-position::before {
        content: "";
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 4px;
        background: #f59e0b;
    }

    .rank-circle {
        width: 28px;
        height: 28px;
        background: var(--light);
        color: var(--primary);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 800;
        font-size: 0.85rem;
    }

    .standing-card.top-position .rank-circle {
        background: #fcd34d;
        color: #78350f;
    }

    .player-details {
        display: flex;
        flex-direction: column;
        gap: 2px;
        overflow: hidden;
    }

    .player-name-m {
        font-weight: 700;
        font-size: 0.95rem;
        color: var(--dark);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1.2;
    }

    .player-deck-m {
        font-size: 0.8rem;
        color: var(--secondary);
        display: flex;
        align-items: center;
        gap: 6px;
        line-height: 1.2;
    }

    .cossy-id-m {
        font-size: 0.75rem;
        color: #94a3b8;
    }

    .points-badge {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        background: var(--primary);
        color: white;
        border-radius: 6px;
        min-width: 40px;
        padding: 5px 3px;
        text-align: center;
    }

    .points-val {
        font-weight: 800;
        font-size: 1rem;
        line-height: 1;
    }

    .points-label {
        font-size: 0.55rem;
        text-transform: uppercase;
        opacity: 0.8;
        margin-top: 1px;
    }

    .status-badges {
        display: flex;
        gap: 4px;
        margin-top: 2px;
    }

    .mini-badge {
        font-size: 0.65rem;
        padding: 1px 5px;
        border-radius: 3px;
        font-weight: 600;
    }
}

/* Minimalistic Champion Banner */
.champion-banner {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    text-align: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.champion-banner::before {
    content: "♛";
    position: absolute;
    top: -15px;
    right: -10px;
    font-size: 6rem;
    color: white;
    opacity: 0.05;
    transform: rotate(15deg);
}

.champion-content {
    position: relative;
    z-index: 2;
}

.champion-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    opacity: 0.8;
    margin-bottom: 5px;
}

.champion-name {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 5px;
}

.champion-deck {
    display: inline-block;
    background: rgba(255, 255, 255, 0.15);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Compact Stats Bar */
.compact-stats-card {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 12px !important;
    gap: 10px;
    background: white;
    /* Explicitly white foundation */
}

.compact-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.2;
}

.compact-divider {
    width: 1px;
    height: 25px;
    background: var(--border);
}

.c-label {
    font-size: 0.7rem;
    color: var(--secondary);
    text-transform: uppercase;
}

.c-value {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary);
}

.c-value.status-running {
    color: var(--success);
}

.c-value.status-finished {
    color: var(--dark);
}

.c-value.status-top_cut {
    color: var(--warning);
}

/* Recent Tournaments Mobile */
.recent-tournaments-mobile {
    display: none;
}

@media (max-width: 768px) {
    .recent-tournaments-desktop {
        display: none;
    }

    .recent-tournaments-mobile {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .tournament-card-mobile {
        background: white;
        border: 1px solid var(--border);
        border-radius: 8px;
        padding: 12px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
    }

    .t-card-top {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 6px;
        gap: 10px;
    }

    .t-card-top .btn {
        flex-shrink: 0;
        padding: 6px 12px;
        font-size: 0.75rem;
    }

    .t-name {
        flex: 1;
        font-weight: 700;
        color: var(--dark);
        font-size: 1rem;
        line-height: 1.2;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .t-card-info {
        display: flex;
        justify-content: space-between;
        font-size: 0.8rem;
        color: var(--secondary);
        margin-bottom: 10px;
    }

    .t-card-actions {
        display: flex;
        gap: 8px;
        padding-top: 10px;
        border-top: 1px solid var(--light);
    }

    /* Override buttons inside actions to be 50% width */
    .t-card-actions .btn {
        flex: 1;
        text-align: center;
        width: auto !important;
        /* Override the width:100% rule */
        font-size: 0.8rem;
        padding: 8px;
    }
}

/* Tournaments Page Mobile */
.tournaments-mobile {
    display: none;
}

@media (max-width: 768px) {
    .tournaments-desktop {
        display: none;
    }

    .tournaments-mobile {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .t-card-actions {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-top: 8px;
        padding-top: 8px;
        border-top: 1px solid var(--light);
    }

    .t-card-actions .btn {
        flex-shrink: 0;
        padding: 6px 12px;
        font-size: 0.75rem;
    }

    /* Compact Pagination for Mobile */
    .pagination-container {
        padding: 15px 0;
        text-align: center;
    }

    .pagination-group {
        display: inline-flex !important;
        /* Force inline-flex to override column direction */
        flex-direction: row !important;
        gap: 5px;
    }

    .pagination-group .btn {
        width: auto !important;
        padding: 8px 12px;
        flex: 0 0 auto;
    }

    .page-info {
        display: flex;
        align-items: center;
        white-space: nowrap;
    }

    /* Compact Stats Bar (Single Row/Wrapped) */
    .stats-grid {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        justify-content: center;
        gap: 0 !important;
        margin: 0 !important;
        background: white;
        border: 1px solid var(--border);
        border-radius: 8px;
        padding: 5px 0 !important;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    }

    /* Fix for when .stats-grid is direct child of .card in mobile */
    .card .stats-grid {
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        margin: -5px -5px !important;
        padding: 0 !important;
    }

    .stat-card {
        padding: 8px 4px !important;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        flex: 1 1 25% !important;
        min-width: 80px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        min-height: auto !important;
        position: relative;
    }

    /* Vertical Dividers */
    .stat-card::after {
        content: "";
        position: absolute;
        right: 0;
        top: 20%;
        height: 60%;
        width: 1px;
        background: var(--border);
    }

    /* Remove divider for last item and multiples */
    .stat-card:last-child::after,
    .stat-card:nth-child(4n)::after {
        display: none;
    }

    .stat-label {
        font-size: 0.6rem !important;
        margin-bottom: 2px !important;
        line-height: 1;
        text-transform: uppercase;
        text-align: center;
        width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        padding: 0 2px;
    }

    .stat-value {
        font-size: 0.95rem !important;
        line-height: 1.2;
        text-align: center;
        word-break: break-word;
    }

    .hide-on-mobile {
        display: none !important;
    }
}

/* Mobile Player List */
.players-list-mobile {
    display: none;
}

@media (max-width: 768px) {
    .players-table-desktop {
        display: none !important;
    }

    .players-list-mobile {
        display: flex;
        flex-direction: column;
        gap: 10px;
        margin-bottom: 20px;
    }

    .player-card {
        background: white;
        border: 1px solid var(--border);
        border-radius: 8px;
        padding: 12px;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    }

    .player-card-header {
        display: flex;
        align-items: center;
        gap: 10px;
        margin-bottom: 10px;
        border-bottom: 1px solid var(--light);
        padding-bottom: 8px;
    }

    .player-card-header .player-number {
        font-weight: 700;
        color: var(--primary);
        min-width: 25px;
    }

    .player-card-header .player-name {
        font-weight: 600;
        flex: 1;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 0.95rem;
    }

    .player-card-header .player-cossy {
        font-size: 0.85rem;
        color: #64748b;
        white-space: nowrap;
    }

    .player-card-body {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
    }

    .player-card-body .player-deck {
        flex: 1;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .player-card-body .player-actions .btn {
        width: auto !important;
        /* Override full width in mobile */
        padding: 6px 12px;
        font-size: 0.85rem;
        margin: 0;
    }
}

/* Mobile Decks List */
.decks-list-mobile {
    display: none;
}

@media (max-width: 768px) {
    .decks-table-desktop {
        display: none !important;
    }

    .decks-list-mobile {
        display: flex;
        flex-direction: column;
        gap: 8px;
        margin-bottom: 20px;
    }

    .deck-card.compact {
        background: white;
        border: 1px solid var(--border);
        border-radius: 6px;
        padding: 10px 12px;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
        display: flex;
        align-items: center;
        gap: 10px;
        height: auto;
    }

    .deck-rank {
        font-weight: 700;
        color: var(--primary);
        font-size: 0.95rem;
        min-width: 25px;
        flex-shrink: 0;
    }

    .deck-name {
        flex: 1;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 0.9rem;
        margin-right: 5px;
        text-align: left;
    }

    .deck-stats-compact {
        flex-shrink: 0;
        text-align: right;
        font-size: 0.9rem;
        white-space: nowrap;
    }
}