/* Minimal responsive foundation — Sprint 0. Extended mobile-first in
   Sprint 7 (see SPRINT_7.md): base rules below target narrow screens by
   default; min-width media queries layer on desktop enhancements rather
   than the other way around. */

* {
    box-sizing: border-box;
}

html {
    /* 1rem = 16px: keeps form inputs at 16px+, which stops iOS Safari
       from auto-zooming the page on focus (SPRINT_7.md section 8). */
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #1a1a1a;
    background-color: #f7f8fa;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Visible only when focused — lets a keyboard user jump straight past
   the nav to the page content (SPRINT_7.md section 9). */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 100;
    background-color: #1a1a1a;
    color: #ffffff;
    padding: 0.75rem 1.25rem;
    border-radius: 0 0 0.375rem 0;
}

.skip-link:focus {
    left: 0;
}

/* A visible, consistent focus ring for every interactive element,
   keyboard-only (mouse/touch clicks don't trigger :focus-visible) —
   SPRINT_7.md section 9. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid #2563eb;
    outline-offset: 2px;
}

.site-header {
    background-color: #ffffff;
    border-bottom: 1px solid #e2e5e9;
}

.site-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0.75rem 1rem;
    position: relative;
}

.site-nav__brand {
    font-weight: 600;
    text-decoration: none;
    color: #1a1a1a;
}

/* Mobile menu toggle — only rendered for authenticated pages (see
   templates/base.html). Hidden again above the mobile breakpoint, where
   the full link list is always visible instead. */
.site-nav__toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    background: none;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    cursor: pointer;
}

.site-nav__toggle-icon,
.site-nav__toggle-icon::before,
.site-nav__toggle-icon::after {
    display: block;
    width: 20px;
    height: 2px;
    background-color: #1a1a1a;
    border-radius: 1px;
}

.site-nav__toggle-icon {
    position: relative;
}

.site-nav__toggle-icon::before,
.site-nav__toggle-icon::after {
    content: "";
    position: absolute;
    left: 0;
}

.site-nav__toggle-icon::before {
    top: -6px;
}

.site-nav__toggle-icon::after {
    top: 6px;
}

/* Collapsed by default on narrow screens only once JS has confirmed it
   can actually toggle the menu (the "js-nav" class is added by
   static/js/nav.js) — with JavaScript unavailable or disabled, the full
   link list stays visible and stacked, so navigation never depends on
   the script running (SPRINT_7.md section 12). */
.js-nav .site-nav__links {
    display: none;
    flex-basis: 100%;
}

.js-nav .site-nav__links.is-open {
    display: flex;
}

.site-nav__links {
    display: flex;
    flex-direction: column;
    gap: 0;
    list-style: none;
    margin: 0.75rem 0 0;
    padding: 0;
    width: 100%;
}

.site-nav__links li {
    border-top: 1px solid #f0f1f3;
}

.site-nav__links li:first-child {
    border-top: none;
}

.site-nav__links a,
.site-nav__logout-button {
    display: flex;
    align-items: center;
    min-height: 44px;
    color: #1a1a1a;
    text-decoration: none;
}

.site-main {
    flex: 1;
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
    padding: 1.25rem 1rem;
}

.site-footer {
    text-align: center;
    padding: 1.5rem 1rem;
    color: #6b7280;
    font-size: 0.875rem;
}

/* Desktop enhancement: nav toggle hidden, links laid out horizontally
   inline with the brand, regardless of the JS-driven collapse state. */
@media (min-width: 769px) {
    .site-nav {
        flex-wrap: nowrap;
        padding: 1rem 1.5rem;
    }

    .site-nav__toggle {
        display: none;
    }

    .js-nav .site-nav__links,
    .site-nav__links {
        display: flex !important;
        flex-basis: auto;
        flex-direction: row;
        align-items: center;
        gap: 1.5rem;
        width: auto;
        margin: 0;
    }

    .site-nav__links li {
        border-top: none;
    }

    .site-nav__links a,
    .site-nav__logout-button {
        min-height: auto;
    }

    .site-main {
        padding: 2rem 1.5rem;
    }
}

/* Accounts — Sprint 1 */

.account-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.account-card {
    background-color: #ffffff;
    border: 1px solid #e2e5e9;
    border-radius: 0.5rem;
}

.account-card__link {
    display: block;
    padding: 1.25rem;
    color: inherit;
    text-decoration: none;
}

.account-card__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.account-card__type {
    font-weight: 600;
}

.account-card__status {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background-color: #eef2f7;
    color: #374151;
}

.account-card__status--active {
    background-color: #e6f6ec;
    color: #1a7f42;
}

.account-card__status--frozen,
.account-card__status--suspended {
    background-color: #fdeeea;
    color: #b3401f;
}

.account-card__status--closed {
    background-color: #eceef1;
    color: #6b7280;
}

.account-card__number {
    color: #6b7280;
    margin-bottom: 0.5rem;
}

.account-card__balance {
    font-size: 1.5rem;
    font-weight: 700;
}

.account-card__available {
    color: #6b7280;
    font-size: 0.875rem;
}

.account-detail {
    background-color: #ffffff;
    border: 1px solid #e2e5e9;
    border-radius: 0.5rem;
    padding: 1.25rem 1.5rem;
    max-width: 420px;
}

.account-detail dt {
    color: #6b7280;
    font-size: 0.8rem;
    margin-top: 0.75rem;
}

.account-detail dd {
    margin: 0;
    font-size: 1.05rem;
    overflow-wrap: break-word;
    word-break: break-word;
}

.account-activity {
    margin-top: 2rem;
}

.empty-state {
    color: #6b7280;
}

/* Auth-aware nav — Sprint 2 */

.site-nav__logout-form {
    margin: 0;
}

.site-nav__logout-button {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    color: inherit;
    cursor: pointer;
    text-decoration: underline;
}

.site-messages {
    list-style: none;
    margin: 0 0 1.5rem;
    padding: 0;
}

.site-messages__item {
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    background-color: #eef2f7;
    margin-bottom: 0.5rem;
}

.site-messages__item--error {
    background-color: #fdeeea;
    color: #b3401f;
}

.site-messages__item--success {
    background-color: #e6f6ec;
    color: #1a7f42;
}

/* Auth forms — Sprint 2 */

.auth-form-container {
    max-width: 400px;
    margin: 1.5rem auto;
    background-color: #ffffff;
    border: 1px solid #e2e5e9;
    border-radius: 0.5rem;
    padding: 1.5rem;
}

@media (min-width: 480px) {
    .auth-form-container {
        margin: 2rem auto;
        padding: 2rem;
    }
}

.auth-form-container h1 {
    margin-top: 0;
    font-size: 1.5rem;
}

.form-field {
    margin-bottom: 1.25rem;
}

.form-field label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.375rem;
}

.form-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 1rem;
    min-height: 44px;
}

.form-errors {
    color: #b3401f;
    font-size: 0.875rem;
    margin: 0.25rem 0 0;
    padding: 0;
    list-style: none;
}

.form-submit {
    width: 100%;
    padding: 0.75rem;
    min-height: 48px;
    background-color: #1a1a1a;
    color: #ffffff;
    border: none;
    border-radius: 0.375rem;
    font-size: 1rem;
    cursor: pointer;
}

.form-submit:hover {
    background-color: #333333;
}

.auth-form-links {
    margin-top: 1rem;
    font-size: 0.875rem;
}

/* Dashboard/transactions/transfer — Sprint 4 */

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.button {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0.6rem 1.1rem;
    border-radius: 0.375rem;
    font-size: 0.9rem;
    text-decoration: none;
    border: 1px solid transparent;
}

.button--primary {
    background-color: #1a1a1a;
    color: #ffffff;
}

.button--primary:hover {
    background-color: #333333;
}

.dashboard-section {
    margin-top: 2.5rem;
}

.dashboard-section__header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    margin-bottom: 0.75rem;
}

.dashboard-section__header h2 {
    margin: 0;
    font-size: 1.1rem;
}

.transaction-list {
    list-style: none;
    margin: 0;
    padding: 0;
    background-color: #ffffff;
    border: 1px solid #e2e5e9;
    border-radius: 0.5rem;
    overflow: hidden;
}

.transaction-row + .transaction-row {
    border-top: 1px solid #e2e5e9;
}

.transaction-row__link {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
        "description amount"
        "date status"
        "reference reference";
    gap: 0.25rem 0.75rem;
    padding: 0.9rem 1rem;
    color: inherit;
    text-decoration: none;
    align-items: center;
    min-height: 44px;
}

.transaction-row__date {
    grid-area: date;
    color: #6b7280;
    font-size: 0.8rem;
}

.transaction-row__description {
    grid-area: description;
    font-weight: 500;
    word-break: break-word;
}

.transaction-row__amount {
    grid-area: amount;
    font-weight: 700;
    text-align: right;
    white-space: nowrap;
}

.transaction-row__amount--debit {
    color: #b3401f;
}

.transaction-row__amount--credit {
    color: #1a7f42;
}

.transaction-row__reference {
    grid-area: reference;
    color: #9ca3af;
    font-size: 0.75rem;
    word-break: break-all;
}

.transaction-row__status {
    grid-area: status;
    color: #6b7280;
    font-size: 0.75rem;
    text-align: right;
}

@media (min-width: 560px) {
    .transaction-row__link {
        grid-template-columns: auto 1fr auto;
        grid-template-areas:
            "date description amount"
            "reference reference status";
    }

    .transaction-row__reference {
        word-break: normal;
    }
}

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

.pagination a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 0.25rem;
}

.receipt {
    max-width: 480px;
    margin: 1.5rem auto;
    background-color: #ffffff;
    border: 1px solid #e2e5e9;
    border-radius: 0.5rem;
    padding: 1.5rem;
    text-align: center;
}

@media (min-width: 480px) {
    .receipt {
        padding: 2rem;
    }
}

.receipt__amount {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    word-break: break-word;
}

@media (min-width: 480px) {
    .receipt__amount {
        font-size: 2rem;
    }
}

.receipt__amount--debit {
    color: #b3401f;
}

.receipt__amount--credit {
    color: #1a7f42;
}

.receipt__details {
    text-align: left;
}

.receipt__details dt {
    color: #6b7280;
    font-size: 0.8rem;
    margin-top: 0.75rem;
}

.receipt__details dd {
    margin: 0;
    font-size: 1.05rem;
    overflow-wrap: break-word;
    word-break: break-word;
}

.transfer-form-container {
    max-width: 480px;
}

.form-submit--secondary {
    background-color: #ffffff;
    color: #1a1a1a;
    border: 1px solid #d1d5db;
    margin-bottom: 0.75rem;
}

.form-submit--secondary:hover {
    background-color: #f3f4f6;
}

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

.recipient-confirmation {
    background-color: #e6f6ec;
    border-radius: 0.375rem;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

#transfer-result {
    margin-top: 1rem;
}

.transfer-result__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    margin-top: 1rem;
}

/* Dashboard primary actions — Sprint 8 */

.primary-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin: 1.5rem 0 2rem;
}

.primary-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-height: 64px;
    padding: 0.9rem;
    background-color: #ffffff;
    border: 1px solid #e2e5e9;
    border-radius: 0.5rem;
    color: #1a1a1a;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    text-align: center;
}

.primary-action__icon {
    font-size: 1.3rem;
}

.primary-action--main {
    background-color: #1a1a1a;
    color: #ffffff;
    border-color: #1a1a1a;
}

.empty-state-panel {
    text-align: center;
    padding: 2rem 1.5rem;
    background-color: #ffffff;
    border: 1px dashed #d1d5db;
    border-radius: 0.5rem;
}

.empty-state-panel__title {
    font-weight: 600;
    font-size: 1.05rem;
    margin-bottom: 0.25rem;
}

.empty-state-panel .button {
    margin-top: 1rem;
}

/* Beneficiaries — Sprint 6 */

.beneficiary-list {
    list-style: none;
    margin: 0;
    padding: 0;
    background-color: #ffffff;
    border: 1px solid #e2e5e9;
    border-radius: 0.5rem;
    overflow: hidden;
}

.beneficiary-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
}

.beneficiary-card + .beneficiary-card {
    border-top: 1px solid #e2e5e9;
}

.beneficiary-card--inactive {
    opacity: 0.6;
}

.beneficiary-card__name {
    font-weight: 600;
    word-break: break-word;
}

.beneficiary-card__nickname {
    font-weight: 400;
    color: #6b7280;
    margin-left: 0.4rem;
}

.beneficiary-card__badge {
    margin-left: 0.5rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    background-color: #eceef1;
    color: #6b7280;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
}

.beneficiary-card__details {
    color: #6b7280;
    font-size: 0.875rem;
    margin-top: 0.2rem;
    word-break: break-word;
}

.beneficiary-card__actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.25rem;
    font-size: 0.875rem;
    width: 100%;
}

.beneficiary-card__actions a,
.beneficiary-card__actions .link-button {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

.beneficiary-card__form {
    margin: 0;
    display: inline;
}

@media (min-width: 560px) {
    .beneficiary-card {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .beneficiary-card__actions {
        width: auto;
    }
}

.link-button {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    color: #1a1a1a;
    text-decoration: underline;
    cursor: pointer;
}

.link-button--danger {
    color: #b3401f;
}
