/* --- Theme Variables --- */
:root {
    --color-bg: #f4f4f4;
    --color-text: #333333;
    --color-primary: #d9534f;
    --color-primary-2: #c0433f;
    --color-success: #5cb85c;
    --color-info: #0275d8;
    --color-card-bg: #ffffff;
    --color-border: #e0e0e0;
    --color-muted: #666666;
    --color-table-alt: #f9f9f9;
    --color-warning-bg: #fff3cd;
    --color-warning-border: #ffeeba;
    --color-footer-bg: #333333;
    --color-header-text: #ffffff;
    --color-link: #aed6f1;
}

[data-theme="dark"] {
    --color-bg: #121212;
    --color-text: #e9e9e9;
    --color-primary: #d9534f; /* keep brand */
    --color-primary-2: #a63a37;
    --color-success: #5cb85c;
    --color-info: #4aa3ff;
    --color-card-bg: #1e1e1e;
    --color-border: #333333;
    --color-muted: #b0b0b0;
    --color-table-alt: #161616;
    --color-warning-bg: #2b2620;
    --color-warning-border: #4a4032;
    --color-footer-bg: #0e0e0e;
    --color-header-text: #ffffff;
    --color-link: #8ecbff;
}

/* --- General Styles --- */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    background-color: var(--color-bg);
    color: var(--color-text);
    transition: background-color 200ms ease, color 200ms ease;
    /* Added padding to prevent fixed footer from overlapping content */
    padding-bottom: 5rem; 
}

/* Prevent stray horizontal scrollbars */
html, body { overflow-x: hidden; }
*, *::before, *::after { box-sizing: border-box; }

header {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-2));
    color: var(--color-header-text);
    padding: 1rem;
    text-align: left;
}

/* remove pseudo-element logo, using real <img> */

/* Header layout enhancements */
.header-inner {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.brand { display: flex; align-items: center; gap: 0.75rem; }
.brand .logo { width: 100px; height: 40px; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; }

.site-title {
    margin: 0;
    font-size: 1.6rem;
    line-height: 1.3;
    letter-spacing: 0.2px;
}

.site-tagline {
    margin: 0.15rem 0 0;
    opacity: 0.95;
}

.last-updated { white-space: nowrap; }

/* Theme toggle button */
.theme-toggle {
    border: 1px solid rgba(255,255,255,0.6);
    color: var(--color-header-text);
    background: transparent;
    border-radius: 20px;
    padding: 0.25rem 0.6rem;
    font-size: 0.9rem;
    cursor: pointer;
    margin-right: 0.5rem;
}
.theme-toggle:hover { background: rgba(255,255,255,0.12); }

header #last-updated {
    font-size: 0.9rem;
    opacity: 0.9;
}

main {
    padding: 1rem;
    max-width: 900px;
    margin: 0 auto;
}

.intro-text {
    font-size: 1.1rem;
    line-height: 1.7;
    background-color: var(--color-warning-bg);
    border-left: 5px solid var(--color-warning-border);
    padding: 1rem;
    margin-bottom: 2rem;
    border-radius: 8px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.08);
}

.loading {
    text-align: center;
    font-size: 1.2rem;
    color: #666;
}

/* --- Collapsible Section Styles --- */
.blood-category {
    background-color: var(--color-card-bg);
    border-radius: 8px;
    margin-bottom: 1rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    border: 1px solid var(--color-border);
}

.blood-category summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    outline: none;
    flex-wrap: wrap;
    gap: 0.5rem;
    transition: background-color 160ms ease;
}

.blood-category summary::after {
    content: '▼';
    font-size: 0.8em;
    color: #888;
    transition: transform 0.2s ease-in-out;
}

.blood-category[open] > summary::after { transform: rotate(180deg); }
.blood-category summary::-webkit-details-marker { display: none; }

.blood-category:hover > summary { background: rgba(0,0,0,0.03); }

/* Animate open/close body */
.blood-category .request-list { max-height: 0; overflow: hidden; opacity: 0; transition: max-height 250ms ease, opacity 180ms ease; }
.blood-category[open] .request-list { max-height: 1000px; opacity: 1; }

.blood-type-badge { color: var(--color-primary); }
.request-count-badge { background-color: var(--color-table-alt); color: var(--color-text); padding: 0.3rem 0.7rem; border-radius: 20px; font-size: 1rem; border: 1px solid var(--color-border); }

/* --- New Table Styles --- */
.request-list {
    padding: 0; /* Remove padding for full-width table */
    border-top: 1px solid var(--color-border);
}

.request-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed; /* Helps avoid overflow on long content */
}

.request-table th, .request-table td {
    padding: 0.8rem 1.5rem;
    text-align: left;
    word-break: break-word;
}

.request-table thead {
    background-color: var(--color-table-alt);
    border-bottom: 2px solid var(--color-border);
}

.request-table th {
    font-size: 0.9rem;
    color: #666;
    text-transform: uppercase;
}

.request-table tbody tr:not(:last-child) {
    border-bottom: 1px solid var(--color-border);
}

.request-table tbody tr:nth-child(even) {
    background-color: var(--color-table-alt);
}

.request-table tbody tr:hover { background: rgba(0,0,0,0.05); }
[data-theme="dark"] .request-table tbody tr:hover { background: rgba(255,255,255,0.06); }

.pledge-button {
    width: 100%;
    padding: 0.5rem 0.8rem;
    background-image: linear-gradient(135deg, var(--color-success), #4cae4c);
    color: var(--color-header-text);
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: bold;
    transition: background-color 0.2s, transform 120ms ease;
}

.pledge-button:hover { transform: translateY(-1px) scale(1.01); }
.pledge-button:active { transform: translateY(0); }

/* Responsive styles for the table on small screens */
@media screen and (max-width: 820px) {
    .brand .logo { width: 80px; height: 32px; }

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

    .last-updated { align-self: flex-end; }

    .request-table thead {
        display: none;
    }
    .request-table, .request-table tbody, .request-table tr, .request-table td {
        display: block;
        width: 100%;
    }
    .request-table tr {
        margin-bottom: 1rem;
        border-bottom: 2px solid var(--color-primary);
    }
    .request-table tr:nth-child(even) { background-color: var(--color-table-alt); }
    .request-table td {
        text-align: right;
        padding-left: 50%;
        position: relative;
        border-bottom: 1px solid #eee;
    }
    .request-table td:last-child {
        border-bottom: 0;
    }
    .request-table td::before {
        content: attr(data-label);
        position: absolute;
        left: 1.5rem;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        text-align: left;
        font-weight: bold;
    }
    .pledge-button {
        width: auto;
    }
}


/* --- Modal Styles --- */
.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.5); }
.modal.open { display: block; }
.modal-content { background-color: var(--color-card-bg); margin: 15% auto; padding: 20px; border: 1px solid var(--color-border); width: 80%; max-width: 500px; border-radius: 5px; outline: none; transform: translateY(8px) scale(0.98); opacity: 0; transition: transform 160ms ease, opacity 160ms ease; position: relative; }
.modal.open .modal-content { transform: translateY(0) scale(1); opacity: 1; }
.close-button { color: #888; position: absolute; top: 10px; right: 12px; font-size: 22px; line-height: 1; font-weight: bold; cursor: pointer; border: none; background: transparent; padding: 4px; width: auto; height: auto; }
.close-button:hover { color: #555; }
.close-button:focus-visible { outline: 2px solid var(--color-info); outline-offset: 2px; border-radius: 4px; }
.modal-content input, .modal-content button:not(.close-button) { width: 100%; padding: 10px; margin-bottom: 10px; border: 1px solid var(--color-border); border-radius: 4px; box-sizing: border-box; background: transparent; color: inherit; }
.modal-content button:not(.close-button) { background-color: var(--color-info); color: white; border: none; }
.small-text { font-size: 0.8rem; color: #666; text-align: center; margin-top: 1rem; }

/* --- UPDATED Footer Styles --- */
footer {
    /* Make it smaller */
    padding: 1rem; 
    
    /* Fix to bottom of the viewport */
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100%;

    /* Original styles */
    text-align: center;
    background: var(--color-footer-bg);
    color: var(--color-header-text);
    box-sizing: border-box; /* Ensures padding is included in the width */
}
footer a {
    color: var(--color-link);
    text-decoration: none;
}
footer a:hover {
    text-decoration: underline;
}

/* Animations */
.fade-in { animation: fadeIn 220ms ease-out both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Section title */
.section-title {
    font-size: 1.8rem;
    margin: 0.5rem 0 1rem;
    position: relative;
}
.section-title::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -6px;
    width: 80px;
    height: 4px;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--color-primary), var(--color-primary-2));
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}
