/*
 * Bernabéu Infinito CMS, styled on Real Madrid's Cibeles design system:
 * the Cibeles UI Kit in Figma (tokens, and the "Internal apps" templates for
 * layout) and the same --rm-* tokens published by signin.realmadrid.com.
 * Token names and values follow Real Madrid's; the aliases below map them
 * onto this app's components.
 */
:root {
    /* Real Madrid (Cibeles) tokens */
    --rm-font-family-default: RMNeue, "RM Neue", arial, helvetica, sans-serif;
    --rm-font-weight-base: 400;
    --rm-font-weight-medium: 500;
    --rm-font-weight-semi-bold: 600;
    --rm-font-weight-bold: 700;

    --rm-color-primary-default: #3E31FA;
    --rm-color-primary-dark: #2115AB;
    --rm-color-primary-medium: #8FA0F5;
    --rm-color-primary-light: #DEE5FD;
    --rm-color-primary-bg: #EEF2FD;
    --rm-color-primary-white: #FFF;
    --rm-color-primary-shadow: rgb(84 77 183 / 78%);
    --rm-color-secondary-default: #8760F6;
    --rm-color-secondary-background-hover: rgb(235 236 255 / 50.2%);
    --rm-color-gradients-01-primary: linear-gradient(8deg, var(--rm-color-primary-default) 15.1%, var(--rm-color-secondary-default) 100%);
    --rm-color-gradients-02-dark: linear-gradient(198deg, var(--rm-color-primary-default) 0%, #2115AB 100%);
    /* Title band as drawn in the Internal apps templates: violet at the top left, primary blue at the bottom right */
    --rm-band-gradient: linear-gradient(172deg, var(--rm-color-secondary-default) 0%, var(--rm-color-primary-default) 100%);

    --rm-color-grayscale-off-black: #14142B;
    --rm-color-grayscale-title: #0F2145;
    --rm-color-grayscale-dark: #29395A;
    --rm-color-grayscale-body: #43526E;
    --rm-color-grayscale-label: #5E6A83;
    --rm-color-grayscale-body-light: #788398;
    --rm-color-grayscale-placehold: #8C95A6;
    --rm-color-grayscale-medium: #ACB4C1;
    --rm-color-grayscale-light: #C7CCD6;
    --rm-color-grayscale-line: #E1E5EA;
    --rm-color-grayscale-input: #EDEFF2;
    --rm-color-grayscale-bg: #F3F5F8;
    --rm-color-grayscale-off-white: #FBFDFF;

    --rm-color-success-default: #3D923D;
    --rm-color-success-dark: #026C02;
    --rm-color-success-bg: #E0F2D1;
    --rm-color-warning-dark: #946300;
    --rm-color-warning-bg: #FEEDC8;
    --rm-color-error-default: #CA024F;
    --rm-color-error-dark: #9E0038;
    --rm-color-error-bg: #FCE3EC;
    --rm-color-error-light: #FFF1F6;

    --rm-shadow-dark-medium: 0 12px 32px -8px #A9A3FF33;
    --rm-button-primary-shadow-hover: 0 1rem 3rem -1rem var(--rm-color-primary-shadow);
    --rm-radius: 12px;
    --rm-disabled-opacity: .5;

    /* CMS aliases */
    --bg: var(--rm-color-primary-white);
    --strip: var(--rm-color-grayscale-bg);
    --surface: var(--rm-color-primary-white);
    --text: var(--rm-color-grayscale-off-black);
    --title: var(--rm-color-grayscale-title);
    --body: var(--rm-color-grayscale-body);
    --muted: var(--rm-color-grayscale-label);
    --hint: var(--rm-color-grayscale-body-light);
    --line: var(--rm-color-grayscale-line);
    --accent: var(--rm-color-primary-default);
    --accent-dark: var(--rm-color-primary-dark);
    --ok: var(--rm-color-success-dark);
    --ok-bg: var(--rm-color-success-bg);
    --danger: var(--rm-color-error-default);
    --danger-bg: var(--rm-color-error-bg);
    --radius: 16px;
    --gutter: 24px;
    color-scheme: light;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: clip;
    background: var(--bg);
    color: var(--text);
    font-family: var(--rm-font-family-default);
    font-size: 16px;
    line-height: 1.25;
    font-weight: var(--rm-font-weight-base);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); font-weight: var(--rm-font-weight-semi-bold); text-decoration: none; }
a:hover { color: var(--accent-dark); text-decoration: underline; }
h1, h2, h3 { color: var(--title); font-weight: var(--rm-font-weight-bold); }
h1 { font-size: 2rem; line-height: 2.25rem; letter-spacing: -.5px; margin: 0; }          /* Heading H3 Medium Bold */
h2 { font-size: 1.5rem; line-height: 1.625rem; letter-spacing: -.5px; margin: 0 0 20px; } /* Heading H4 Small Bold */
h3 { font-size: 1.125rem; line-height: 1.5rem; margin: 24px 0 10px; }
p { color: var(--body); line-height: 1.4; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

.muted { color: var(--muted); }
.small { font-size: .8125rem; }    /* Caption Small */

/* Shown when Cms:EnvironmentLabel is set, e.g. a local CMS working on DEV data */
.env-strip {
    padding: 6px var(--gutter);
    background: var(--rm-color-warning-bg);
    color: var(--rm-color-warning-dark);
    font-size: .8125rem;
    font-weight: var(--rm-font-weight-semi-bold);
    text-align: center;
}

/* Top bar (Cibeles internal apps) */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    height: 56px;
    padding: 0 var(--gutter);
    background: var(--surface);
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--title);
    font-size: 1.25rem;
    letter-spacing: -.5px;
    font-weight: var(--rm-font-weight-bold);
    white-space: nowrap;
}
.brand:hover { color: var(--title); text-decoration: none; }
.brand img { width: 24px; height: 34px; }
.brand em { font-style: normal; font-weight: var(--rm-font-weight-base); color: var(--hint); }
.signout { display: flex; align-items: center; gap: 16px; color: var(--muted); font-size: .875rem; }
.account-link { color: var(--muted); font-weight: var(--rm-font-weight-base); }
.account-link.active, .account-link:hover { color: var(--accent); }
.narrow-panel { max-width: 560px; }

/* Section tabs */
.sections {
    display: flex;
    gap: 8px;
    padding: 0 var(--gutter);
    background: var(--surface);
    border-top: 1px solid var(--line);
    overflow-x: auto;
}
.sections a {
    position: relative;
    padding: 16px 18px;
    color: var(--hint);
    font-size: 1rem;
    font-weight: var(--rm-font-weight-semi-bold);
    white-space: nowrap;
}
.sections a:hover { color: var(--accent); text-decoration: none; }
.sections a.active { color: var(--accent); }
.sections a.active::after {
    content: "";
    position: absolute;
    left: 18px;
    right: 18px;
    bottom: 0;
    height: 3px;
    border-radius: 3px 3px 0 0;
    background: var(--accent);
}

/* Page with a full-width gradient title band */
.page {
    width: 100%;
    max-width: calc(1248px + 2 * var(--gutter));
    margin: 0 auto;
    padding: 0 var(--gutter) 80px;
    flex: 1;
    display: flex;
    flex-direction: column;
}
.page > * { min-width: 0; }
.pagehead {
    order: -1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    margin: 0 calc(50% - 50vw) 32px;
    padding: 24px calc(50vw - 50%);
    min-height: 96px;
    background: var(--rm-color-primary-default) var(--rm-band-gradient);
    color: var(--rm-color-primary-white);
}
.pagehead h1 { color: var(--rm-color-primary-white); }
.pagehead p, .pagehead .muted { margin: 4px 0 0; max-width: 760px; color: rgb(255 255 255 / 88%); font-size: 1.125rem; line-height: 1.5rem; }
.pagehead .crumb { margin: 0 0 6px; font-size: 1rem; }
.pagehead .crumb a { color: var(--rm-color-primary-white); font-weight: var(--rm-font-weight-semi-bold); }
.pagehead .crumb a::before { content: "← "; }
.pagehead .tag { background: rgb(255 255 255 / 18%); color: var(--rm-color-primary-white); border-color: rgb(255 255 255 / 35%); }
.pagehead .tag.ok { background: var(--rm-color-primary-white); color: var(--ok); border-color: transparent; }
.pagehead form { margin: 0; }
.pagehead .button, .pagehead button { border-color: rgb(255 255 255 / 70%); background: transparent; color: var(--rm-color-primary-white); }
.pagehead .button:hover, .pagehead button:hover { background: rgb(255 255 255 / 14%); border-color: var(--rm-color-primary-white); color: var(--rm-color-primary-white); }
.pagehead .button.primary, .pagehead button.primary {
    background: var(--rm-color-primary-white);
    border-color: var(--rm-color-primary-white);
    color: var(--accent);
    box-shadow: var(--rm-shadow-dark-medium);
}
.pagehead .button.primary:hover, .pagehead button.primary:hover { background: var(--rm-color-primary-bg); color: var(--accent-dark); }

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 28px;
    margin-bottom: 20px;
}
.panel h2 { font-size: 1.25rem; line-height: 1.5rem; margin-bottom: 16px; }

.flash, .problems {
    border-radius: var(--rm-radius);
    padding: 14px 18px;
    margin-bottom: 24px;
    font-weight: var(--rm-font-weight-medium);
}
.flash { background: var(--rm-color-primary-bg); color: var(--accent-dark); border: 1px solid var(--rm-color-primary-light); }
.problems { background: var(--rm-color-error-light); color: var(--rm-color-error-dark); border: 1px solid var(--danger-bg); }
.problems ul { margin: 6px 0 0; padding-left: 20px; font-weight: var(--rm-font-weight-base); }

/* Dashboard */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 24px;
    background: var(--strip);
    border: 1px solid transparent;
    border-radius: var(--radius);
    color: var(--text);
    font-weight: var(--rm-font-weight-base);
    transition: border-color .15s, box-shadow .15s, background-color .15s;
}
a.stat:hover { background: var(--surface); border-color: var(--rm-color-primary-light); box-shadow: var(--rm-shadow-dark-medium); text-decoration: none; color: var(--text); }
.stat strong { font-size: 2rem; line-height: 2.25rem; letter-spacing: -.5px; color: var(--title); font-weight: var(--rm-font-weight-bold); }
.stat span { color: var(--muted); font-size: .875rem; line-height: 1.125rem; }
.steps { color: var(--body); padding-left: 22px; line-height: 1.5; }
.steps li { margin-bottom: 8px; }

/* Tables: grey header, striped rows */
.grid { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); margin-bottom: 20px; font-size: .875rem; line-height: 1.125rem; }
.grid th, .grid td { text-align: left; padding: 16px; vertical-align: middle; color: var(--rm-color-grayscale-dark); }
.grid th {
    background: var(--rm-color-grayscale-input);
    color: var(--text);
    font-size: .9375rem;
    font-weight: var(--rm-font-weight-semi-bold);
}
.grid th:first-child { border-top-left-radius: var(--rm-radius); }
.grid th:last-child { border-top-right-radius: var(--rm-radius); }
.grid tbody tr:nth-child(even) td { background: var(--strip); }
.grid tbody tr:hover td { background: var(--rm-color-primary-bg); }
.grid td.empty { color: var(--muted); text-align: center; padding: 40px; }
.grid.rows td { vertical-align: top; }
.grid .titles input { margin-bottom: 6px; }
.grid td a { font-weight: var(--rm-font-weight-semi-bold); }
.grid button:not(.link) { min-height: 40px; padding: 6px 16px; font-size: .875rem; }
.actions { display: flex; gap: 12px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.actions form { margin: 0; }
.teams { display: flex; align-items: center; gap: 8px; font-weight: var(--rm-font-weight-medium); color: var(--text); }
.teams img { width: 24px; height: 24px; object-fit: contain; }

/* Forms (Cibeles filled inputs) */
label { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
label > span { font-size: 1rem; line-height: 1.25rem; color: var(--muted); font-weight: var(--rm-font-weight-base); }
input, select, textarea {
    font: inherit;
    color: var(--text);
    background: var(--rm-color-grayscale-input);
    border: 2px solid var(--rm-color-grayscale-input);
    border-radius: var(--rm-radius);
    padding: 12px 18px;
    min-height: 48px;
    width: 100%;
    transition: background-color .15s, border-color .15s;
}
textarea { resize: vertical; min-height: 108px; line-height: 1.4; }
input::placeholder, textarea::placeholder { color: var(--rm-color-grayscale-placehold); }
input:hover, select:hover, textarea:hover { border-color: var(--rm-color-grayscale-light); }
input:focus, select:focus, textarea:focus { outline: none; background: var(--surface); border-color: var(--accent); }
select {
    appearance: none;
    padding-right: 48px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2314142B' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m3 6 5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 18px center;
}
input[type=checkbox] { width: 20px; height: 20px; min-height: 0; padding: 0; accent-color: var(--accent); }
input[type=file] { padding: 14px 18px; background: var(--strip); border: 2px dashed var(--rm-color-primary-medium); color: var(--muted); }
input[type=file]::file-selector-button {
    font: inherit;
    font-weight: var(--rm-font-weight-semi-bold);
    color: var(--accent);
    background: var(--surface);
    border: 2px solid var(--accent);
    border-radius: 10px;
    padding: 6px 14px;
    margin-right: 14px;
    cursor: pointer;
}
input.narrow { width: 100px; }

/* Buttons: primary = gradient, default = outlined primary */
button, .button {
    font: inherit;
    font-weight: var(--rm-font-weight-semi-bold);
    letter-spacing: .25px;
    min-height: 48px;
    padding: 10px 22px;
    border-radius: var(--rm-radius);
    border: 2px solid var(--accent);
    background: var(--surface);
    color: var(--accent);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
    transition: background-color .15s, border-color .15s, box-shadow .15s, color .15s;
}
button:hover, .button:hover { background: var(--rm-color-secondary-background-hover); border-color: var(--accent-dark); color: var(--accent-dark); text-decoration: none; }
button:focus-visible, .button:focus-visible, a:focus-visible { outline: 3px solid var(--rm-color-primary-medium); outline-offset: 2px; }
button:disabled { opacity: var(--rm-disabled-opacity); cursor: default; filter: grayscale(100%); }
button.primary, .button.primary {
    background: var(--rm-color-primary-default) var(--rm-color-gradients-01-primary);
    border-color: transparent;
    color: var(--rm-color-primary-white);
}
button.primary:hover, .button.primary:hover { background-image: var(--rm-color-gradients-02-dark); box-shadow: var(--rm-button-primary-shadow-hover); color: var(--rm-color-primary-white); }
button.danger { color: var(--danger); border-color: var(--danger); }
button.danger:hover { background: var(--rm-color-error-light); color: var(--rm-color-error-dark); border-color: var(--rm-color-error-dark); }
button.link {
    border: 0;
    background: none;
    min-height: 0;
    padding: 0;
    color: var(--accent);
    letter-spacing: 0;
}
button.link:hover { background: none; color: var(--accent-dark); text-decoration: underline; }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.inline { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; }
.inline label { margin-bottom: 0; }
.inline .grow { flex: 1; min-width: 240px; }
.inline.compact select { width: auto; min-height: 40px; padding: 6px 40px 6px 14px; background-position: right 12px center; }
.check { flex-direction: row; align-items: center; gap: 10px; margin: 0; font-size: 1rem; color: var(--text); }

.langs { border: 0; padding: 0; margin: 0 0 20px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 24px; }
.langs legend { font-weight: var(--rm-font-weight-bold); color: var(--title); font-size: 1.125rem; margin-bottom: 14px; padding: 0; }

/* Read-only facts (Cibeles detail template: grey label, dark value) */
.facts { display: grid; grid-template-columns: 200px 1fr; gap: 14px 24px; margin: 0 0 20px; }
.facts dt { color: var(--muted); font-size: .875rem; line-height: 1.25rem; }
.facts dd { margin: 0; color: var(--text); line-height: 1.25rem; }

.image-row { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; }
.image-field { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.image-field img { border-radius: var(--rm-radius); border: 1px solid var(--line); background: var(--strip); }
.thumb { width: 320px; max-width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.banner { width: 100%; aspect-ratio: 3 / 1; object-fit: cover; }
.artwork { max-height: 96px; max-width: 100%; object-fit: contain; padding: 12px; background: var(--title) !important; }

.actions-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.actions-bar > div { display: flex; gap: 12px; }
.editor .actions-bar.panel { position: sticky; bottom: 16px; box-shadow: var(--rm-shadow-dark-medium); }

.tag {
    display: inline-flex;
    align-items: center;
    font-size: .75rem;
    line-height: 1rem;
    font-weight: var(--rm-font-weight-semi-bold);
    letter-spacing: .25px;
    padding: 4px 12px;
    border-radius: 80px;
    background: var(--strip);
    color: var(--muted);
    border: 1px solid var(--line);
}
.tag.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }

/* Home rows */
.row-items { border-top: 1px solid var(--line); padding: 18px 0 0; margin-top: 18px; }
.row-items summary { cursor: pointer; font-weight: var(--rm-font-weight-bold); color: var(--title); }
.row-items ul { list-style: none; padding: 0; margin: 12px 0 0; }
.row-items li { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 10px; }
.row-items li:nth-child(even) { background: var(--strip); }
.row-items li > span:first-child { flex: 1; }
.row-items li.hidden-item > span:first-child { color: var(--hint); text-decoration: line-through; }

/* Toolbar strip (Add a match search) */
.picker-tools { margin-bottom: 16px; padding: 20px 24px; background: var(--strip); border-radius: var(--radius); }
.picker-tools input { background: var(--surface); border-color: var(--surface); }
.picker-tools input:focus { border-color: var(--accent); }
.picker-tabs { margin-bottom: 20px; align-items: center; }
.picker-tabs .toggle { margin-left: auto; color: var(--accent); }
.grid tr.added td { color: var(--hint); }
.grid tr.added .teams { color: var(--hint); }
.grid tr.added .teams img { opacity: .5; }

/* Dashboard import status */
.import-status { display: flex; justify-content: space-between; align-items: center; gap: 24px; background: var(--rm-color-primary-bg); border-color: var(--rm-color-primary-light); }
.import-status h2 { margin-bottom: 4px; }
.import-status p { margin: 6px 0 0; }
.import-status.failed { background: var(--rm-color-error-light); border-color: var(--danger-bg); }
.import-status.failed h2 { color: var(--rm-color-error-dark); }

/* Segmented control (Preview languages, Add a match tabs) */
.tabs { display: inline-flex; gap: 4px; padding: 4px; background: var(--strip); border-radius: 80px; }
.tabs a {
    padding: 10px 20px;
    border-radius: 80px;
    color: var(--muted);
    font-size: .875rem;
    line-height: 1.125rem;
    letter-spacing: .25px;
}
.tabs a:hover { color: var(--accent); text-decoration: none; }
.tabs a.active { color: var(--rm-color-primary-white); background: var(--accent); }
.pagehead .tabs { background: rgb(255 255 255 / 16%); }
.pagehead .tabs a { color: var(--rm-color-primary-white); }
.pagehead .tabs a.active { background: var(--rm-color-primary-white); color: var(--accent); }
.picker-tabs { display: flex; width: 100%; background: none; padding: 0; }
.picker-tabs a:not(.toggle) { background: var(--strip); }
.picker-tabs a.active { background: var(--accent); }
.card-preview img { width: 100%; max-width: 600px; aspect-ratio: 3 / 1; object-fit: cover; border-radius: var(--rm-radius); }
.json { max-height: 520px; overflow: auto; background: var(--rm-color-grayscale-off-white); border: 1px solid var(--line); padding: 16px; border-radius: var(--rm-radius); margin: 0; }

/* Footer strip */
.app-footer {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 20px var(--gutter);
    border-top: 1px solid var(--line);
    background: var(--surface);
    color: var(--muted);
    font-size: .8125rem;
}

/* Sign in (signin.realmadrid.com layout) */
.login {
    width: 100%;
    max-width: 490px;
    margin: 0 auto;
    padding: 48px 24px 64px;
    flex: 1;
    text-align: center;
}
.login-crest { width: 34px; height: 48px; margin-bottom: 32px; }
.login-title { font-size: 1.5rem; line-height: 1.625rem; margin-bottom: 8px; }
.login-title span { color: var(--hint); font-weight: var(--rm-font-weight-base); }
.login p { margin: 0 0 32px; color: var(--muted); }
.login form { text-align: left; }
.login input { min-height: 56px; }
.login button { width: 100%; min-height: 56px; margin-top: 12px; font-size: 1.125rem; letter-spacing: .75px; }
.site-footer {
    background: var(--strip);
    color: var(--muted);
    font-size: .875rem;
    padding: 32px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}
.site-footer img { width: 20px; height: 28px; opacity: .8; }

@media (max-width: 960px) {
    :root { --gutter: 16px; }
}

@media (max-width: 720px) {
    .row2, .langs, .image-row { grid-template-columns: 1fr; }
    .pagehead { flex-direction: column; align-items: flex-start; }
    .facts { grid-template-columns: 1fr; }
    .grid th, .grid td { padding: 12px 10px; }
    .account-link { display: none; }
    .brand { font-size: 1.0625rem; }
}
