/* ===========================
   DEFERRED CSS — non-critical
   Cabinet Veterinar
   Loaded async after paint
   =========================== */

/* ========== TYPOGRAPHY ========== */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -.01em;
    color: var(--warm-800);
}

h1 {
    font-size: clamp(1.6rem, 4vw, 2.5rem);
}

h2 {
    font-size: clamp(1.3rem, 3vw, 1.9rem);
    margin-bottom: .75rem;
}

h3 {
    font-size: clamp(1.1rem, 2.5vw, 1.4rem);
    margin-bottom: .5rem;
}

p {
    max-width: 70ch;
    margin-bottom: 1rem;
    color: var(--text-soft);
}

p:last-child {
    margin-bottom: 0;
}

strong {
    color: var(--warm-800);
    font-weight: 600;
}

a {
    color: var(--green-700);
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color .2s;
}

a:hover {
    color: var(--green-600);
}

a:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
    border-radius: 2px;
}

/* ========== LAYOUT ========== */
.section {
    padding: 3rem 0;
}

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

/* ========== CARDS ========== */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.75rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .25s, transform .25s;
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-3px);
}

.card-icon {
    font-size: 2.25rem;
    margin-bottom: .75rem;
    display: block;
    line-height: 1;
}

.card h3 {
    color: var(--green-700);
    margin-bottom: .5rem;
}

.card p {
    font-size: .9375rem;
    color: var(--text-muted);
    margin: 0;
    max-width: none;
}

/* ========== CONTENT (page body) ========== */
.page-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: clamp(1.5rem, 4vw, 2.5rem);
    box-shadow: var(--shadow-sm);
}

.page-content h1 {
    color: var(--green-800);
    margin-bottom: 1rem;
}

.page-content p {
    color: var(--text-soft);
}

.home-intro img {
    max-height: 450px;
    width: 100%;
    object-fit: cover;
    margin-bottom: 2rem;
    border-radius: var(--radius-md);
    display: block;
}

.home-intro h2,
.home-intro h3 {
    margin-top: 2rem;
}

/* Feature grid fallback for clean HTML */
.home-intro {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.home-intro blockquote {
    text-align: center;
    padding: 2.5rem;
    background: var(--surface-2);
    border-radius: var(--radius-lg);
    border: none;
    margin: 3rem 0;
}

.home-intro blockquote img {
    max-width: 280px;
    border-radius: 50%;
    border: 6px solid #fff;
    box-shadow: var(--shadow-lg);
    margin: 0 auto 1.5rem;
}

/* ========== SECTION LABELS ========== */
.section-label {
    display: inline-block;
    font-size: .8125rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--green-700);
    background: var(--green-100);
    padding: .25rem .75rem;
    border-radius: 99px;
    margin-bottom: .75rem;
}

/* ========== BUTTONS (non-critical variants) ========== */
.btn-outline {
    background: transparent;
    color: var(--green-700);
    border-color: var(--green-700);
}

.btn-outline:hover {
    background: var(--green-700);
    color: #fff;
    transform: translateY(-1px);
}

.btn-ghost {
    background: rgba(255, 255, 255, .15);
    color: #fff;
    border-color: rgba(255, 255, 255, .4);
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, .25);
    border-color: rgba(255, 255, 255, .6);
}

.btn-sm {
    padding: .45rem 1rem;
    font-size: .875rem;
}

.btn-lg {
    padding: .9rem 2rem;
    font-size: 1.0625rem;
}

/* ========== FORM ELEMENTS ========== */
.form-group {
    margin-bottom: 1.25rem;
}

label {
    display: block;
    font-size: .9rem;
    font-weight: 600;
    color: var(--text-soft);
    margin-bottom: .35rem;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
textarea,
select {
    width: 100%;
    padding: .65rem .875rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-main);
    font-family: inherit;
    font-size: .9375rem;
    line-height: 1.5;
    transition: border-color .18s, box-shadow .18s;
    appearance: none;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--green-600);
    box-shadow: 0 0 0 3px rgba(32, 96, 64, .15);
}

/* WCAG: error state */
input[aria-invalid="true"],
textarea[aria-invalid="true"] {
    border-color: #b91c1c;
    box-shadow: 0 0 0 3px rgba(185, 28, 28, .12);
}

textarea {
    min-height: 120px;
    resize: vertical;
}

.field-error {
    font-size: .8125rem;
    color: #b91c1c;
    margin-top: .3rem;
    display: flex;
    align-items: center;
    gap: .25rem;
}

.field-error::before {
    content: '⚠';
}

/* ========== ALERT / NOTICE ========== */
.alert {
    border-radius: var(--radius-sm);
    padding: .875rem 1rem;
    font-size: .9375rem;
    border: 1px solid transparent;
    margin-bottom: 1rem;
    display: flex;
    align-items: flex-start;
    gap: .625rem;
}

.alert-success {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #065f46;
}

.alert-error {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.alert-info {
    background: #fdfcf6;
    border-color: var(--border);
    color: var(--text-main);
    box-shadow: var(--shadow-sm);
}

.alert-info strong {
    color: var(--green-800);
}

/* ========== TABLE ========== */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

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

thead th {
    background: var(--surface-2);
    padding: .75rem 1rem;
    text-align: left;
    font-size: .8rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background .15s;
}

tbody tr:last-child {
    border-bottom: none;
}

tbody tr:hover {
    background: var(--surface-2);
}

tbody td {
    padding: .75rem 1rem;
    color: var(--text-soft);
    vertical-align: middle;
}

tbody td:first-child {
    font-weight: 500;
    color: var(--text-main);
}

/* ========== ADMIN ========== */
.admin-wrap {
    max-width: 90%;
    margin: 0 auto;
}

.admin-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: clamp(1.5rem, 4vw, 2.5rem);
    box-shadow: var(--shadow-md);
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.admin-header h1 {
    font-size: 1.4rem;
    color: var(--green-800);
    margin: 0;
}

/* Login card */
.login-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - var(--header-h) - 120px);
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: clamp(2rem, 5vw, 3rem);
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.login-card .card-logo {
    font-size: 3rem;
    margin-bottom: .5rem;
    display: block;
}

.login-card h1 {
    font-size: 1.5rem;
    color: var(--green-800);
    margin-bottom: .25rem;
}

.login-card .subtitle {
    color: var(--text-muted);
    font-size: .9rem;
    margin-bottom: 2rem;
}

.login-card form {
    text-align: left;
}

.login-card .btn {
    width: 100%;
    justify-content: center;
    margin-top: .5rem;
}

/* ========== FOOTER ========== */
footer {
    background: var(--warm-800);
    color: rgba(255, 253, 249, .7);
    padding: 2.5rem 1.25rem;
    margin-top: auto;
}

footer .container {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

footer .footer-brand {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--warm-100);
}

footer p {
    color: rgba(255, 253, 249, .65);
    font-size: .875rem;
    margin: 0;
    max-width: none;
}

footer a {
    color: var(--warm-300);
}

footer a:hover {
    color: var(--warm-100);
}

/* ========== BREADCRUMB ========== */
.breadcrumb {
    font-size: .85rem;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: .4rem;
    flex-wrap: wrap;
}

.breadcrumb a {
    color: var(--green-700);
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

.breadcrumb span[aria-hidden] {
    color: var(--border);
}

/* ========== BADGE ========== */
.badge {
    display: inline-flex;
    align-items: center;
    font-size: .75rem;
    font-weight: 700;
    padding: .15rem .5rem;
    border-radius: 99px;
    background: var(--green-100);
    color: var(--green-700);
}

/* ========== DIVIDER ========== */
.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2rem 0;
}

/* ========== ANIMATIONS ========== */
@media (prefers-reduced-motion: no-preference) {
    .fade-up {
        opacity: 0;
        transform: translateY(20px);
        animation: fadeUp .5s ease forwards;
    }

    @keyframes fadeUp {
        to {
            opacity: 1;
            transform: none;
        }
    }

    .card {
        transition: box-shadow .25s, transform .25s;
    }
}

/* ========== PRINT ========== */
@media print {

    header,
    footer,
    .btn,
    nav {
        display: none !important;
    }

    body {
        background: #fff;
        color: #000;
    }

    .page-content {
        box-shadow: none;
        border: none;
    }
}

/* ========== RESPONSIVE ========== */
@media (max-width: 640px) {
    main {
        padding: 1.25rem 1rem;
    }

    .hero {
        border-radius: var(--radius-md);
        margin-bottom: 1.5rem;
    }

    .cards-grid {
        grid-template-columns: 1fr;
    }

    .admin-header {
        flex-direction: column;
        align-items: flex-start;
    }

    footer .container {
        flex-direction: column;
        text-align: center;
    }
}

@media (min-width: 641px) and (max-width: 900px) {
    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ========== FORCED COLOURS (WCAG 1.4.11) ========== */
@media (forced-colors: active) {

    .btn-primary,
    .btn-outline {
        border: 2px solid ButtonText;
    }

    .card {
        border: 1px solid ButtonText;
    }
}