/* ═══════════════════════════════════════════════════════════
   FoodBridge — Main Stylesheet
   ═══════════════════════════════════════════════════════════ */

:root {
    --primary:       #1a6b3c;
    --primary-dark:  #0f4225;
    --primary-light: #e8f5ee;
    --accent:        #2d9e5f;
    --bg:            #f2f6f4;
    --card:          #ffffff;
    --border:        #d5e8dd;
    --text:          #1a1a1a;
    --muted:         #6b7280;
    --danger:        #dc2626;
    --danger-light:  #fef2f2;
    --warn:          #d97706;
    --warn-light:    #fffbeb;
    --info:          #2563eb;
    --info-light:    #eff6ff;
    --success:       #16a34a;
    --success-light: #f0fdf4;
    --purple:        #7c3aed;
    --purple-light:  #f5f3ff;
    --radius:        10px;
    --radius-lg:     16px;
    --shadow:        0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.06);
    --shadow-md:     0 4px 16px rgba(0,0,0,.12);
    --transition:    .18s ease;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

/* ── Navbar ────────────────────────────────────────────────── */
.navbar {
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    height: 58px;
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
    position: sticky;
    top: 0;
    z-index: 200;
}
.nav-brand {
    font-size: 20px;
    font-weight: 800;
    color: #fff;
    letter-spacing: -.3px;
    text-decoration: none;
}
.nav-links {
    display: flex;
    align-items: center;
    gap: 14px;
}
.nav-links a {
    color: rgba(255,255,255,.85);
    font-size: 14px;
    transition: color var(--transition);
    text-decoration: none;
}
.nav-links a:hover { color: #fff; }
.nav-highlight {
    background: rgba(255,255,255,.15);
    padding: 5px 12px;
    border-radius: 6px;
    font-weight: 600;
}
.nav-user-info { display: flex; align-items: center; gap: 6px; }
.nav-user { color: rgba(255,255,255,.75); font-size: 13px; }
.notif-btn {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    position: relative;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background var(--transition);
}
.notif-btn:hover { background: rgba(255,255,255,.1); }
.notif-badge {
    position: absolute;
    top: -2px; right: -2px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
}
.btn-logout {
    background: rgba(255,255,255,.1);
    color: rgba(255,255,255,.9) !important;
    padding: 5px 14px;
    border-radius: 7px;
    font-size: 13px;
    transition: background var(--transition);
    text-decoration: none !important;
}
.btn-logout:hover { background: rgba(255,255,255,.2); }

/* ── Flash messages ────────────────────────────────────────── */
.flash {
    padding: 13px 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.flash-success { background: var(--success-light); color: #14532d; border-bottom: 3px solid var(--success); }
.flash-error   { background: var(--danger-light);  color: #7f1d1d; border-bottom: 3px solid var(--danger); }
.flash-info    { background: var(--info-light);    color: #1e3a8a; border-bottom: 3px solid var(--info); }
.flash-close {
    background: none; border: none; cursor: pointer; font-size: 16px;
    opacity: .6; transition: opacity .15s;
}
.flash-close:hover { opacity: 1; }

/* ── Container ─────────────────────────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 28px 24px; flex: 1; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 20px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: all var(--transition);
    line-height: 1.2;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary   { background: var(--primary);  color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success   { background: var(--success);  color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger    { background: var(--danger);   color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-info      { background: var(--info);     color: #fff; }
.btn-info:hover { background: #1d4ed8; }
.btn-secondary { background: #f3f4f6; color: #374151; border: 1px solid #d1d5db; }
.btn-secondary:hover { background: #e5e7eb; }
.btn-full  { width: 100%; }
.btn-sm    { padding: 5px 12px; font-size: 12px; }

/* ── Auth pages ────────────────────────────────────────────── */
.auth-page { background: linear-gradient(135deg, var(--primary) 0%, #0a3320 100%); }
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.auth-card {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 40px 36px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.auth-card-wide { max-width: 620px; }
.auth-logo { font-size: 48px; text-align: center; margin-bottom: 8px; }
.auth-title { text-align: center; font-size: 24px; color: var(--primary); margin-bottom: 4px; }
.auth-subtitle { text-align: center; color: var(--muted); font-size: 14px; margin-bottom: 24px; }
.auth-link { text-align: center; margin-top: 20px; font-size: 13px; color: var(--muted); }
.auth-link a { color: var(--primary); font-weight: 600; }
.demo-accounts { margin-top: 24px; background: var(--primary-light); border-radius: 8px; padding: 14px; }
.demo-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-bottom: 8px; font-weight: 600; }
.demo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-size: 12px; }
.demo-item { background: #fff; border-radius: 6px; padding: 8px; }
.demo-pass { font-size: 12px; color: var(--muted); margin-top: 6px; }
.demo-pass code { background: #f3f4f6; padding: 2px 6px; border-radius: 4px; font-family: monospace; color: var(--primary); }

/* ── Forms ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 13px;
    color: #374151;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 13px;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
    background: #fff;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(45,158,95,.12);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow);
}
.form-section-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--primary);
    margin: 24px 0 14px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--border);
}
.hint { color: var(--muted); font-size: 12px; font-weight: 400; }
.field-hint { display: block; margin-top: 4px; font-size: 12px; color: var(--muted); }
.location-row { display: flex; gap: 10px; align-items: flex-start; }
.location-row input { flex: 1; }

/* Upload area */
.upload-area {
    border: 2px dashed #d1d5db;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    transition: border-color var(--transition);
    cursor: pointer;
    position: relative;
}
.upload-area:hover { border-color: var(--accent); }
.upload-area input[type="file"] {
    position: absolute; inset: 0; opacity: 0; cursor: pointer;
    width: 100%; height: 100%; padding: 0; border: none;
}
.upload-placeholder { display: flex; flex-direction: column; gap: 4px; pointer-events: none; }
.upload-icon { font-size: 32px; }
.image-preview-wrap { margin-top: 12px; position: relative; display: inline-block; }
.image-preview-wrap img { max-height: 250px; border-radius: 8px; border: 2px solid var(--border); }
.remove-img { position: absolute; top: 6px; right: 6px; }
.ai-notice {
    background: var(--info-light);
    border-left: 4px solid var(--info);
    padding: 11px 14px;
    border-radius: 4px;
    font-size: 13px;
    color: #1e3a8a;
    margin: 16px 0;
}

/* ── Alerts ────────────────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 18px;
    font-size: 14px;
    border-left: 4px solid;
}
.alert-success { background: var(--success-light); border-color: var(--success); color: #14532d; }
.alert-error   { background: var(--danger-light);  border-color: var(--danger);  color: #7f1d1d; }
.alert-info    { background: var(--info-light);    border-color: var(--info);    color: #1e3a8a; }

/* ── Page Header ───────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
}
.page-header h1 { font-size: 24px; color: var(--primary); font-weight: 700; }
.page-sub { color: var(--muted); font-size: 14px; margin-top: 3px; }
.header-stats { display: flex; gap: 10px; flex-wrap: wrap; }
.hstat {
    background: var(--card);
    border: 1px solid var(--border);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    color: var(--muted);
}
.hstat.warn { border-color: var(--warn); color: var(--warn); }
.hstat.purple { border-color: var(--purple); color: var(--purple); }
.hstat.green { border-color: var(--success); color: var(--success); }
.hstat strong { color: var(--text); }

/* ── Cards ─────────────────────────────────────────────────── */
.card, .section-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 22px;
}
.section-card { padding: 22px 24px; }
.section-card h2 {
    font-size: 16px;
    color: var(--primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.section-card h3 { font-size: 15px; color: #374151; margin-bottom: 14px; }
.warn-card { border-left: 4px solid var(--warn); }
.badge-count {
    background: var(--primary-light);
    color: var(--primary);
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 700;
}
.empty-inline { color: var(--muted); font-size: 14px; padding: 8px 0; }
.action-card { border-top: 3px solid var(--primary); }
.approve-form { margin-bottom: 16px; }
.reject-divider {
    text-align: center;
    color: var(--muted);
    font-size: 12px;
    margin: 14px 0;
    position: relative;
}
.reject-divider::before, .reject-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 42%;
    height: 1px;
    background: var(--border);
}
.reject-divider::before { left: 0; }
.reject-divider::after  { right: 0; }

/* Donation cards */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 20px; }
.donation-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: box-shadow var(--transition);
}
.donation-card:hover { box-shadow: var(--shadow-md); }
.card-active { border-top: 3px solid var(--primary); }
.donation-card-img { height: 160px; overflow: hidden; background: var(--bg); }
.donation-card-img img { width: 100%; height: 100%; object-fit: cover; }
.no-img-placeholder {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    color: var(--border);
}
.donation-card-body { padding: 16px; flex: 1; }
.card-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 10px;
}
.card-title-row h3 { font-size: 15px; }
.card-meta {
    list-style: none;
    font-size: 13px;
    color: var(--muted);
    line-height: 2;
}
.donation-card-footer {
    padding: 12px 16px;
    background: var(--bg);
    border-top: 1px solid var(--border);
}
.delivered-at { font-size: 12px; color: var(--success); margin-top: 8px; font-weight: 600; }

/* ── Tables ────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
    background: var(--primary);
    color: #fff;
    padding: 10px 13px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    letter-spacing: .3px;
    white-space: nowrap;
}
.data-table td {
    padding: 10px 13px;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #fafbfa; }
.id-col { color: var(--muted); font-size: 12px; }
.location-col { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.expiry-soon { color: var(--warn); font-weight: 700; }
.expired-text { color: var(--danger); }
.text-muted { color: var(--muted); font-size: 12px; }

/* Detail table */
.detail-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.detail-table th {
    padding: 9px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    text-align: left;
    width: 38%;
    border-bottom: 1px solid var(--border);
}
.detail-table td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
}
.detail-table tr:last-child th,
.detail-table tr:last-child td { border-bottom: none; }
.ai-conf { font-size: 12px; color: var(--muted); margin-left: 6px; }
.img-caption { font-size: 12px; color: var(--muted); margin-top: 8px; }
.no-image {
    background: var(--bg);
    border-radius: 8px;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 13px;
}

/* Review layout */
.review-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.review-left, .review-right { display: flex; flex-direction: column; gap: 22px; }
.review-img { width: 100%; border-radius: 8px; border: 1px solid var(--border); }
.section-hint { font-size: 13px; color: var(--muted); margin-bottom: 14px; }

/* Admin layout */
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin-bottom: 22px; }

/* ── Stats Grid ─────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 18px 14px;
    text-align: center;
    box-shadow: var(--shadow);
    border-top: 3px solid var(--primary);
}
.stat-value { font-size: 30px; font-weight: 800; color: var(--primary); line-height: 1; }
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; margin-top: 6px; }
.stat-pending   { border-color: var(--warn);    } .stat-pending   .stat-value { color: var(--warn);    }
.stat-approved  { border-color: var(--success); }
.stat-assigned  { border-color: var(--info);    } .stat-assigned  .stat-value { color: var(--info);    }
.stat-delivered { border-color: var(--purple);  } .stat-delivered .stat-value { color: var(--purple);  }
.stat-completed { border-color: var(--success); }
.stat-rejected  { border-color: var(--danger);  } .stat-rejected  .stat-value { color: var(--danger);  }
.stat-expired   { border-color: #9ca3af;        } .stat-expired   .stat-value { color: #9ca3af;        }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    white-space: nowrap;
}
/* AI */
.ai-safe       { background: #dcfce7; color: #14532d; }
.ai-unsafe     { background: #fee2e2; color: #7f1d1d; }
.ai-error      { background: #fef3c7; color: #78350f; }
.ai-pending_ai { background: #dbeafe; color: #1e3a8a; }
/* Status */
.status-pending            { background: #fef3c7; color: #92400e; }
.status-approved           { background: #d1fae5; color: #065f46; }
.status-rejected           { background: #fee2e2; color: #991b1b; }
.status-volunteer-assigned { background: #dbeafe; color: #1e3a8a; }
.status-delivered          { background: #ede9fe; color: #4c1d95; }
.status-completed          { background: #d1fae5; color: #064e3b; border: 1px solid #6ee7b7; }
.status-expired            { background: #f3f4f6; color: #6b7280; }
/* Roles */
.role-donor     { background: #dbeafe; color: #1e3a8a; }
.role-trustee   { background: #d1fae5; color: #065f46; }
.role-ngo       { background: #fef3c7; color: #78350f; }
.role-volunteer { background: #ede9fe; color: #4c1d95; }
.role-admin     { background: #fee2e2; color: #991b1b; }
/* Role navbar */
.nav-role-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 8px;
    text-transform: uppercase;
}

/* ── Empty state ────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 60px 24px;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.empty-icon { font-size: 56px; margin-bottom: 16px; }
.empty-state h3 { font-size: 20px; color: #374151; margin-bottom: 8px; }
.empty-state p  { color: var(--muted); font-size: 14px; margin-bottom: 20px; }

/* ── Footer ─────────────────────────────────────────────────── */
.site-footer {
    background: var(--card);
    border-top: 1px solid var(--border);
    padding: 16px 28px;
    margin-top: auto;
}
.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--muted);
    flex-wrap: wrap;
    gap: 8px;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
    .form-row      { grid-template-columns: 1fr; }
    .review-layout { grid-template-columns: 1fr; }
    .admin-grid    { grid-template-columns: 1fr; }
    .stats-grid    { grid-template-columns: repeat(4, 1fr); }
    .navbar        { padding: 0 16px; }
    .container     { padding: 18px 16px; }
    .nav-user-info { display: none; }
    .location-row  { flex-direction: column; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .card-grid  { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; }
}
