/* Palette, type and shapes follow the ACAP corporate site (acapca.org). */
:root {
    --teal-900: #134e4a;
    --teal-800: #115e59;
    --teal-700: #0f766e;
    --teal-600: #0d9488;
    --teal-500: #14b8a6;
    --teal-100: #ccfbf1;
    --teal-50: #f0fdfa;
    --amber: #d97706;

    --bg: #f9fafb;
    --surface: #ffffff;
    --text: #111827;
    --muted: #4b5563;
    --subtle: #6b7280;
    --border: #e5e7eb;
    --border-strong: #d1d5db;
    --danger: #b42318;
    --danger-soft: #fdecea;

    --radius: 0.75rem;
    --radius-sm: 0.25rem;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-raised: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

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

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 "Plus Jakarta Sans", Arial, Helvetica, sans-serif;
}

a {
    color: var(--teal-700);
}

a:hover {
    color: var(--teal-900);
}

h1 {
    margin: 0;
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.2;
}

h2 {
    margin: 0 0 1.25rem;
    font-size: 1.15rem;
    font-weight: 700;
}

hr {
    margin: 2rem 0;
    border: 0;
    border-top: 1px solid var(--border);
}

[hidden] {
    display: none !important;
}

.muted {
    margin-top: 0;
    color: var(--muted);
}

/* Layout */

.container {
    width: 80%;
    margin: 0 auto;
}

.container.narrow {
    max-width: 460px;
}

.topbar {
    background: var(--teal-900);
    color: #fff;
    font-size: 0.85rem;
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 36px;
}

.topbar a,
.topbar .link-button {
    color: #fff;
    text-decoration: none;
}

.topbar a:hover,
.topbar .link-button:hover {
    color: var(--teal-100);
    text-decoration: underline;
}

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar-user {
    color: var(--teal-100);
}

.site-header {
    background: var(--surface);
    box-shadow: var(--shadow);
    position: relative;
}

.site-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

.brand {
    display: block;
    line-height: 0;
}

.brand img {
    width: auto;
    height: 52px;
    max-width: 100%;
}

.site-header-label {
    color: var(--teal-700);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-align: right;
    text-transform: uppercase;
}

.site-nav {
    display: flex;
    gap: 1.75rem;
}

.site-nav a {
    padding: 0.35rem 0;
    border-bottom: 2px solid transparent;
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-decoration: none;
    text-transform: uppercase;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
    border-bottom-color: var(--teal-700);
    color: var(--teal-700);
}

/* Teal band behind the page title; the first card overlaps its lower edge. */
.hero {
    padding: 2.5rem 0 5.5rem;
    background: var(--teal-900);
    color: #fff;
}

.hero-eyebrow {
    display: inline-block;
    margin-bottom: 0.75rem;
    padding: 0.2rem 0.7rem;
    background: rgba(17, 94, 89, 0.5);
    border: 1px solid var(--teal-500);
    border-radius: var(--radius-sm);
    color: var(--teal-100);
    font-size: 0.8rem;
    font-weight: 600;
}

.hero-eyebrow a {
    color: inherit;
    text-decoration: none;
}

.hero-eyebrow a:hover {
    color: #fff;
}

.hero-lead {
    max-width: 48rem;
    margin: 0.6rem 0 0;
    color: var(--teal-50);
}

main.container {
    flex: 1;
    margin-top: -3.5rem;
    padding-bottom: 4rem;
}

.site-footer {
    padding: 2rem 0;
    background: var(--teal-900);
    color: #fff;
    font-size: 0.9rem;
}

.site-footer-inner {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.5rem;
}

.site-footer p {
    margin: 0.35rem 0 0;
    color: var(--teal-100);
}

.site-footer a {
    color: #fff;
    font-weight: 600;
    white-space: nowrap;
}

/* Cards */

.card {
    padding: 2.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-raised);
}

/* Section headings inside a card, styled like the site's section subtitles. */
.card > h2 {
    color: var(--teal-700);
    font-size: 0.95rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.card-header h2 {
    margin-bottom: 0.25rem;
    font-size: 1.35rem;
    font-weight: 800;
}

.card-footer {
    margin: 1.5rem 0 0;
    color: var(--muted);
    font-size: 0.9rem;
    text-align: center;
}

.card.empty {
    text-align: center;
}

.card.empty h2 {
    color: var(--text);
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: none;
}

.stack > * + * {
    margin-top: 1rem;
}

.grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem 1.5rem;
    align-items: start;
}

.span-2 {
    grid-column: 1 / -1;
}

/* Forms */

.field,
fieldset.field {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.field > label,
.field > legend {
    display: block;
    margin-bottom: 0.4rem;
    padding: 0;
    font-size: 0.9rem;
    font-weight: 600;
}

.hint {
    display: block;
    color: var(--subtle);
    font-size: 0.8rem;
    font-weight: 400;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="password"],
select,
textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: inherit;
    font: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea {
    resize: vertical;
}

input[type="file"] {
    max-width: 100%;
    font: inherit;
    font-size: 0.9rem;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--teal-600);
    box-shadow: 0 0 0 3px var(--teal-100);
    outline: none;
}

.btn:focus-visible,
.link-button:focus-visible,
a:focus-visible,
input[type="radio"]:focus-visible,
input[type="checkbox"]:focus-visible,
input[type="file"]:focus-visible {
    outline: 2px solid var(--teal-500);
    outline-offset: 2px;
}

[aria-invalid="true"] {
    border-color: var(--danger);
}

.field-error {
    margin: 0.35rem 0 0;
    color: var(--danger);
    font-size: 0.85rem;
}

.split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0.5rem;
}

.split-phone {
    grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
}

.with-suffix {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.with-suffix input {
    max-width: 8rem;
}

.choices {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1.25rem;
    padding: 0.35rem 0;
}

.choice {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 400;
}

.choice input {
    width: 1rem;
    height: 1rem;
    margin: 0;
    accent-color: var(--teal-700);
}

.nested {
    margin-top: 0.9rem;
    padding: 1rem;
    background: var(--teal-50);
    border-left: 3px solid var(--teal-500);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.language-row + .language-row {
    margin-top: 0.9rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 2rem;
}

/* Buttons */

.btn {
    display: inline-block;
    padding: 0.7rem 1.5rem;
    background: var(--surface);
    border: 2px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text);
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.btn:hover {
    border-color: var(--teal-700);
    color: var(--teal-900);
}

.btn-primary {
    background: var(--teal-700);
    border-color: var(--teal-700);
    color: #fff;
}

.btn-primary:hover {
    background: var(--teal-900);
    border-color: var(--teal-900);
    color: #fff;
}

.btn-block {
    width: 100%;
}

.link-button {
    padding: 0;
    background: none;
    border: 0;
    color: var(--teal-700);
    cursor: pointer;
    font: inherit;
}

/* Feedback */

.alert {
    margin-bottom: 1.25rem;
    padding: 0.8rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
}

.alert-success {
    background: var(--teal-100);
    border-left: 3px solid var(--teal-600);
    color: var(--teal-800);
}

.alert-error {
    background: var(--danger-soft);
    border-left: 3px solid var(--danger);
    color: var(--danger);
}

/* Alerts that sit on the teal band rather than inside a card need a lift. */
main > .alert {
    box-shadow: var(--shadow);
}

.badge {
    padding: 0.25rem 0.75rem;
    background: var(--teal-100);
    border-radius: 999px;
    color: var(--teal-800);
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
}

.badge-administrador {
    background: var(--teal-900);
    color: #fff;
}

.badge-gestor {
    background: #fef3c7;
    color: #92400e;
}

.badge-institucion {
    background: #f3f4f6;
    color: var(--muted);
}

/* Tables */

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.filter {
    padding: 0.35rem 0.8rem;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
}

.filter span {
    margin-left: 0.25rem;
    color: var(--subtle);
    font-weight: 400;
}

.filter:hover {
    border-color: var(--teal-700);
}

.filter.is-active {
    background: var(--teal-700);
    border-color: var(--teal-700);
    color: #fff;
}

.filter.is-active span {
    color: var(--teal-100);
}

.table-wrap {
    margin-top: 1.5rem;
    overflow-x: auto;
}

.table-empty {
    margin: 2rem 0 0;
    text-align: center;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.table th,
.table td {
    padding: 0.8rem 0.75rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

.table th {
    color: var(--teal-700);
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    white-space: nowrap;
}

.table tbody tr:hover {
    background: var(--teal-50);
}

.table tbody tr:last-child td {
    border-bottom: 0;
}

.table-actions {
    white-space: nowrap;
    text-align: right;
}

.table-actions form {
    display: inline;
    margin-left: 1rem;
}

.table-actions a,
.table-actions .link-button {
    font-weight: 600;
    text-decoration: none;
}

.table-actions a:hover,
.table-actions .link-button:hover {
    text-decoration: underline;
}

.table-link {
    font-weight: 700;
    text-decoration: none;
}

.table-link:hover {
    text-decoration: underline;
}

.table-sub {
    display: block;
    color: var(--subtle);
    font-size: 0.8rem;
}

.table-clamp {
    min-width: 14rem;
    max-width: 24rem;
}

/* Filters above a listing */

.filter-form {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 1rem;
    align-items: end;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.filter-search {
    grid-column: span 2;
}

.filter-actions {
    display: flex;
    gap: 0.5rem;
}

.filter-actions .btn {
    padding: 0.5rem 1.1rem;
}

.result-count {
    margin: 1.25rem 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

/* Peer evaluator detail: data on the left, change history on the right */

.detail {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: 1.5rem;
    align-items: start;
}

.detail .summary {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

.detail .summary:not(:last-child) {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border);
}

.timeline,
.changes {
    margin: 0;
    padding: 0;
    list-style: none;
}

.timeline > li {
    position: relative;
    padding: 0 0 1.5rem 1.25rem;
    border-left: 2px solid var(--teal-100);
}

.timeline > li:last-child {
    padding-bottom: 0;
}

.timeline > li::before {
    position: absolute;
    top: 0.3rem;
    left: -7px;
    width: 12px;
    height: 12px;
    background: var(--teal-600);
    border: 2px solid var(--surface);
    border-radius: 50%;
    content: "";
}

.timeline-head {
    margin: 0;
}

.timeline-head span {
    display: block;
    color: var(--subtle);
    font-size: 0.8rem;
}

.changes li {
    margin-top: 0.75rem;
    font-size: 0.9rem;
    overflow-wrap: anywhere;
}

.change-field {
    display: block;
    color: var(--amber);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.change-old,
.change-new {
    display: block;
}

.change-old {
    color: var(--subtle);
    text-decoration: line-through;
}

.link-danger {
    color: var(--danger);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem 1.5rem;
    margin: 1.5rem 0;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.summary dt {
    color: var(--amber);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.summary dd {
    margin: 0;
    overflow-wrap: anywhere;
}

/* 80% leaves too little room on small screens, so the container goes full width there. */
@media (max-width: 900px) {
    .container {
        width: 100%;
        padding: 0 1rem;
    }

    .card-header {
        flex-wrap: wrap;
    }

    .detail {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 640px) {
    h1 {
        font-size: 1.6rem;
    }

    .site-nav {
        gap: 1rem;
    }

    .grid,
    .summary {
        grid-template-columns: minmax(0, 1fr);
    }

    .card {
        padding: 1.5rem 1.25rem;
    }

    .brand img {
        height: 40px;
    }

    .site-header-label,
    .topbar-user {
        display: none;
    }

    .site-footer-inner {
        flex-direction: column;
    }
}

/* One-time code field on the verification step */
input.code-input {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.4em;
    text-align: center;
}

.card-footer + .card-footer {
    margin-top: 0.5rem;
}

.alert-detail {
    display: block;
    margin-top: 0.25rem;
    font-weight: 600;
}

/* Role and permission management */

.matrix th,
.matrix td {
    vertical-align: top;
}

.matrix .matrix-role,
.matrix .matrix-cell {
    min-width: 7.5rem;
    text-align: center;
}

.matrix .matrix-role {
    font-size: 0.85rem;
    letter-spacing: 0;
    text-transform: none;
    white-space: normal;
}

.matrix .matrix-group th {
    padding-top: 1.25rem;
    background: var(--teal-50);
}

.matrix .matrix-permission {
    min-width: 16rem;
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
    white-space: normal;
}

.matrix tbody tr.matrix-group:hover {
    background: none;
}

.matrix-yes {
    color: var(--teal-700);
    font-weight: 800;
}

.matrix-no {
    color: var(--border-strong);
}

.permission-groups {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.5rem;
}

.permission-groups legend {
    color: var(--teal-700);
}

.choice.permission {
    display: flex;
    align-items: flex-start;
    margin-top: 0.5rem;
}

.choice.permission input {
    flex: none;
    margin-top: 0.25rem;
}

.danger-zone {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1.5rem;
    box-shadow: var(--shadow);
}

.danger-zone h2 {
    margin-bottom: 0.25rem;
    color: var(--danger);
}

.danger-zone .muted {
    margin: 0;
}

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

.btn-danger:hover:not(:disabled) {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

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

.dashboard-sections:not(:first-child) {
    margin-top: 1.5rem;
}

@media (max-width: 900px) {
    .permission-groups {
        grid-template-columns: minmax(0, 1fr);
    }

    .danger-zone {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* "Otros idiomas": one row per language */
.language-row {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto;
    gap: 0.75rem;
    align-items: end;
}

.language-row [data-language-remove] {
    padding-bottom: 0.7rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.btn-small {
    margin-top: 0.9rem;
    padding: 0.4rem 0.9rem;
    font-size: 0.9rem;
}

@media (max-width: 640px) {
    .language-row {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.4rem;
    }

    .language-row [data-language-remove] {
        justify-self: start;
        padding-bottom: 0;
    }
}

/* Result count and export button above the peers table */
.result-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

.result-bar .result-count,
.result-bar .btn-small {
    margin: 0;
}

/* Per-user permission overrides on the user form */
.override-groups {
    display: grid;
    gap: 1.5rem;
}

.override-groups legend {
    color: var(--teal-700);
}

.override {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 13rem;
    gap: 0.5rem 1rem;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
}

.override + .override {
    border-top: 1px solid var(--border);
}

.override label {
    font-size: 0.9rem;
}

.override.is-overridden {
    background: var(--teal-50);
}

.override.is-overridden select {
    border-color: var(--teal-600);
    font-weight: 600;
}

.override select:disabled {
    background: var(--bg);
    color: var(--subtle);
}

.table-sub + .table-sub,
.badge + .table-sub {
    margin-top: 0.25rem;
}

@media (max-width: 640px) {
    .override {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Activity log */
.nowrap {
    white-space: nowrap;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

.pagination .btn-small {
    margin: 0;
}

/* "Mi cuenta" */
.account .card {
    align-self: stretch;
}

.account .card > h2,
.account .card-header h2 {
    margin-bottom: 0;
}

.account-confirm {
    max-width: 32rem;
    margin: 0 auto 1.5rem;
    border-color: var(--teal-500);
}

.account-inline {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1rem;
}

.account-inline .field {
    flex: 1 1 16rem;
    max-width: 24rem;
}

.alert-info {
    background: var(--teal-50);
    border-left: 3px solid var(--teal-500);
    color: var(--teal-900);
}

.topbar a.topbar-user {
    color: var(--teal-100);
}

/* Searchable lists (public/js/combobox.js) */
.combo {
    position: relative;
    min-width: 0;
}

.combo-input {
    padding-right: 2rem !important;
    background-image: linear-gradient(45deg, transparent 50%, var(--subtle) 50%), linear-gradient(135deg, var(--subtle) 50%, transparent 50%) !important;
    background-position: calc(100% - 1rem) 50%, calc(100% - 0.7rem) 50% !important;
    background-size: 0.3rem 0.3rem !important;
    background-repeat: no-repeat !important;
    text-overflow: ellipsis;
}

.combo-list {
    position: absolute;
    z-index: 20;
    top: calc(100% + 0.25rem);
    left: 0;
    min-width: 100%;
    max-width: min(28rem, 90vw);
    max-height: 16rem;
    margin: 0;
    padding: 0.25rem;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-raised);
    list-style: none;
}

.combo-option,
.combo-empty {
    padding: 0.45rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 400;
    white-space: nowrap;
}

.combo-option {
    cursor: pointer;
}

.combo-option:hover,
.combo-option.is-active {
    background: var(--teal-50);
    color: var(--teal-900);
}

.combo-option[aria-selected="true"] {
    font-weight: 700;
}

.combo-empty {
    color: var(--subtle);
}

.combo-hint {
    margin-left: 0.5rem;
    color: var(--subtle);
    font-size: 0.85rem;
}
