/* ============================================================
   Unidos in Power Cup — Frontend Styles v0.4
   Brand: #282a75 (navy) | #eb493a (red) | Open Sans
   ============================================================ */

/* ── Reset / Base ───────────────────────────────────────────── */
.uipc-app {
    --navy:    #282a75;
    --red:     #eb493a;
    --white:   #ffffff;
    --light:   #f4f5fb;
    --text:    #2c3e50;
    --muted:   #7f8c8d;
    --border:  #dde1f0;
    --radius:  12px;
    --shadow:  0 4px 24px rgba(40,42,117,.10);

    font-family: 'Open Sans', sans-serif;
    color: var(--text);
    max-width: 900px;
    margin: 0 auto;
    padding: 0 16px 60px;
}

.uipc-app *, .uipc-app *::before, .uipc-app *::after {
    box-sizing: border-box;
}

/* ── Language Toggle ────────────────────────────────────────── */
.uipc-lang-toggle {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 0 0;
}

.uipc-lang-btn {
    padding: 6px 18px;
    border: 2px solid var(--navy);
    border-radius: 20px;
    background: transparent;
    color: var(--navy);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
}

.uipc-lang-btn.active,
.uipc-lang-btn:hover {
    background: var(--navy);
    color: var(--white);
}

/* ── Hero ───────────────────────────────────────────────────── */
/* Photo sits behind gradient — background-image set inline by PHP */
.uipc-header {
    background: linear-gradient(135deg, var(--navy) 0%, #1a1c5e 100%);
    background-size: cover;
    background-position: center;
    border-radius: var(--radius);
    text-align: center;
    padding: 56px 24px;
    margin: 16px 0 0;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 360px;
}

/* Hex pattern overlay */
.uipc-header::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
}

.uipc-logo {
    max-height: 64px;
    width: auto;
    margin-bottom: 32px;
    position: relative;
    z-index: 1;
    filter: brightness(0) invert(1); /* force white — remove if logo is already white */
}

.uipc-title {
    font-size: clamp(28px, 5vw, 48px) !important;
    font-weight: 800 !important;
    color: #ffffff !important;
    margin: 0 !important;
    letter-spacing: -0.5px;
    position: relative;
    z-index: 1;
    text-shadow: 0 2px 8px rgba(0,0,0,.35);
}

/* ── Hero intro (subtitle + description + stats — outside hero) ── */
.uipc-hero-intro {
    text-align: center;
    padding: 28px 8px 32px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 36px;
}

.uipc-subtitle {
    font-size: 19px;
    font-weight: 700;
    color: var(--navy);
    margin: 0 0 14px;
}

.uipc-description {
    font-size: 15px;
    color: var(--muted);
    line-height: 1.65;
    max-width: 640px;
    margin: 0 auto 20px;
}

.uipc-stats-bar {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--light);
    border: 1px solid var(--border);
    border-radius: 30px;
    padding: 8px 22px;
    font-size: 14px;
    color: var(--text);
    font-weight: 600;
}

.uipc-stats-bar strong {
    font-size: 22px;
    font-weight: 800;
    color: var(--navy);
}

/* ── Ranking section ────────────────────────────────────────── */
.uipc-ranking-section {
    margin-bottom: 40px;
}

.uipc-ranking-title {
    font-size: 28px;
    font-weight: 800;
    color: var(--navy);
    margin: 0 0 8px;
    text-align: left;
}

.uipc-ranking-subtitle {
    font-size: 16px;
    color: var(--muted);
    margin: 0 0 24px;
    text-align: left;
}

.uipc-ranking-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
}

@media (max-width: 640px) {
    .uipc-ranking-grid { grid-template-columns: 1fr; }
}

.uipc-ranking-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid #6b7280 !important;
    border-color: #6b7280 !important;
    outline: 0 !important;
    overflow: hidden;
}

/* Extra specificity in case theme overrides */
.uipc-app .uipc-ranking-section .uipc-ranking-card {
    border: 1px solid #6b7280 !important;
    border-color: #6b7280 !important;
}

.uipc-ranking-card h3 {
    font-size: 17px;
    font-weight: 800;
    color: var(--navy);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: .5px;
    padding: 20px 20px 14px;
    border-bottom: 3px solid var(--red);
}

/* ── Table ──────────────────────────────────────────────────── */
.uipc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.uipc-table thead tr,
.uipc-app .uipc-table thead tr {
    background: #282a75 !important;
    background-color: #282a75 !important;
}

.uipc-table th,
.uipc-app .uipc-table th {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: rgba(255,255,255,.90) !important;
    background: transparent !important;
    text-align: left;
    padding: 9px 10px;
}

/* Count column header — centered */
.uipc-th-count {
    text-align: center !important;
}

.uipc-th-rank {
    width: 32px;
    text-align: center !important;
}

.uipc-table td {
    padding: 10px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.uipc-table tr:last-child td { border-bottom: none; }

.uipc-table tbody tr:nth-child(even) { background: #fafbff; }

/* Medal colors */
.uipc-table tbody tr:first-child .uipc-rank-num  { background: #ffd700; color: #7a6200; }
.uipc-table tbody tr:nth-child(2) .uipc-rank-num { background: #c0c0c0; color: #555; }
.uipc-table tbody tr:nth-child(3) .uipc-rank-num { background: #cd7f32; color: #fff; }

.uipc-rank-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 800;
    background: var(--light);
    color: var(--navy);
    margin: 0 auto;
}

.uipc-country-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.uipc-flag { font-size: 20px; line-height: 1; }

.uipc-count-cell {
    font-weight: 700;
    color: var(--navy);
    font-size: 15px;
    text-align: center !important;
}

.uipc-loading {
    text-align: center;
    color: var(--muted);
    padding: 24px !important;
    font-style: italic;
    font-size: 13px;
}

/* ── Card (form) ────────────────────────────────────────────── */
.uipc-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    padding: 32px;
    margin-bottom: 24px;
}

/* ── Form blocks ────────────────────────────────────────────── */
.uipc-form-block {
    margin-bottom: 28px;
}

.uipc-form-block:last-child { margin-bottom: 0; }

.uipc-form-title {
    font-size: 22px;
    font-weight: 800;
    color: var(--navy);
    margin: 0 0 4px;
    padding-bottom: 8px;
    border-bottom: 3px solid var(--red);
    display: inline-block;
}

.uipc-form-hint {
    font-size: 13px;
    color: var(--muted);
    margin: 8px 0 18px;
}

.uipc-field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 14px;
}

@media (max-width: 560px) {
    .uipc-field-row { grid-template-columns: 1fr; }
}

/* Email row — full width matching the 2-column name row */
.uipc-field-row--wide {
    grid-template-columns: 1fr;
}

.uipc-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.uipc-field label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: .5px;
}

.uipc-field input,
.uipc-field select {
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: var(--white);
    transition: border-color .2s, box-shadow .2s;
    width: 100%;
    appearance: auto;
}

.uipc-field input:focus,
.uipc-field select:focus {
    outline: none;
    border-color: var(--navy);
    box-shadow: 0 0 0 3px rgba(40,42,117,.12);
}

/* ── Field note ─────────────────────────────────────────────── */
.uipc-field-note {
    font-size: 12px;
    color: var(--muted);
    margin: 4px 0 0;
    font-style: italic;
}

/* ── Referee rows ───────────────────────────────────────────── */
.uipc-referee-row {
    background: var(--light);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 18px;
    margin-bottom: 12px;
    position: relative;
}

/* White inputs inside referee rows */
.uipc-referee-row .uipc-field input,
.uipc-referee-row .uipc-field select {
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(40,42,117,.06);
}

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

.uipc-row-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--navy);
    text-transform: uppercase;
    letter-spacing: .5px;
}

.uipc-remove-row {
    background: none;
    border: none;
    color: var(--red);
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
    opacity: .7;
    transition: opacity .2s;
}

.uipc-remove-row:hover { opacity: 1; }

/* ── Buttons ────────────────────────────────────────────────── */
.uipc-btn-primary {
    background: var(--red);
    color: var(--white);
    border: none;
    border-radius: 8px;
    padding: 14px 32px;
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background .2s, transform .1s;
    display: inline-block;
}

.uipc-btn-primary:hover  { background: #d63c2e; transform: translateY(-1px); }
.uipc-btn-primary:active { transform: translateY(0); }

.uipc-btn-outline {
    background: none;
    color: var(--navy);
    border: 2px dashed var(--navy);
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    margin-top: 8px;
    transition: all .2s;
}

.uipc-btn-outline:hover {
    background: var(--navy);
    color: var(--white);
    border-style: solid;
}

.uipc-form-submit {
    text-align: center;
    padding-top: 8px;
}

.uipc-error {
    color: var(--red);
    font-size: 14px;
    font-weight: 600;
    margin-top: 12px;
    padding: 10px 16px;
    background: #fff5f4;
    border: 1px solid #ffd0cc;
    border-radius: 8px;
}

/* ── Loading spinner on button ──────────────────────────────── */
.uipc-btn-primary.loading {
    opacity: .7;
    cursor: wait;
    position: relative;
}

.uipc-btn-primary.loading::after {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,.5);
    border-top-color: white;
    border-radius: 50%;
    animation: uipc-spin .6s linear infinite;
    margin-left: 10px;
    vertical-align: middle;
}

@keyframes uipc-spin { to { transform: rotate(360deg); } }

/* ── Success state ──────────────────────────────────────────── */
.uipc-success-section {
    text-align: center;
    margin-bottom: 32px;
}

.uipc-success-card {
    text-align: center;
    padding: 48px 32px;
}

.uipc-trophy-anim {
    font-size: 72px;
    animation: uipc-bounce .6s ease both;
    display: block;
    margin-bottom: 16px;
}

@keyframes uipc-bounce {
    0%   { transform: scale(0.3) rotate(-10deg); opacity: 0; }
    60%  { transform: scale(1.2) rotate(5deg); }
    80%  { transform: scale(.95); }
    100% { transform: scale(1) rotate(0); opacity: 1; }
}

.uipc-success-title {
    font-size: 28px;
    font-weight: 800;
    color: var(--navy);
    margin: 0 0 12px;
}

.uipc-success-msg {
    font-size: 16px;
    color: var(--text);
    margin-bottom: 8px;
    font-weight: 600;
}

.uipc-success-cta {
    font-size: 14px;
    color: var(--muted);
    margin-bottom: 24px;
}

/* ── Custom Country Picker ──────────────────────────────────── */
.uipc-country-picker {
    position: relative;
}

.uipc-cp-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    background: #ffffff;
    cursor: pointer;
    transition: border-color .2s, box-shadow .2s;
    font-size: 14px;
    color: var(--text);
    font-family: inherit;
    user-select: none;
    min-height: 42px;
    box-shadow: 0 1px 3px rgba(40,42,117,.06);
}

.uipc-cp-trigger:hover,
.uipc-country-picker.open .uipc-cp-trigger {
    border-color: var(--navy);
    box-shadow: 0 0 0 3px rgba(40,42,117,.12);
}

.uipc-cp-sel-flag { font-size: 20px; line-height: 1; flex-shrink: 0; }

.uipc-cp-sel-label {
    flex: 1;
    color: var(--muted);
    font-size: 14px;
}

.uipc-country-picker.has-value .uipc-cp-sel-label {
    color: var(--text);
    font-weight: 600;
}

.uipc-cp-chevron {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--muted);
    transition: transform .2s;
}

.uipc-country-picker.open .uipc-cp-chevron { transform: rotate(180deg); }

.uipc-cp-panel {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(40,42,117,.18);
    z-index: 200;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    transition: opacity .15s ease, transform .15s ease;
}

.uipc-country-picker.open .uipc-cp-panel {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.uipc-cp-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    padding: 10px;
    max-height: 240px;
    overflow-y: auto;
}

.uipc-cp-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    padding: 8px 4px;
    border: none;
    background: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background .12s;
    font-family: inherit;
    text-align: center;
}

.uipc-cp-option:hover  { background: var(--light); }
.uipc-cp-option.selected { background: var(--navy); }
.uipc-cp-option.selected .uipc-cp-opt-name { color: #fff; }

.uipc-cp-opt-flag { font-size: 28px; line-height: 1; display: block; }

.uipc-cp-opt-name {
    font-size: 10px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.2;
    word-break: break-word;
    hyphens: auto;
}

.uipc-cp-grid::-webkit-scrollbar { width: 4px; }
.uipc-cp-grid::-webkit-scrollbar-track { background: transparent; }
.uipc-cp-grid::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
