/* style.css — Foodbank Viability System */
/* Clean, utilitarian design. Function first, form second. */

/* ---------------------------------------------------------------------------
   Variables
--------------------------------------------------------------------------- */
:root {
    --bg:           #f7f7f5;
    --surface:      #ffffff;
    --border:       #e2e2dc;
    --border-dark:  #c8c8c0;
    --text:         #1a1a18;
    --text-muted:   #6b6b65;
    --text-faint:   #9b9b94;

    --primary:      #2d6a4f;
    --primary-dark: #1b4332;
    --primary-light:#d8f3dc;

    --accent:       #e76f51;
    --warning-bg:   #fff3cd;
    --warning-text: #856404;
    --error-bg:     #fde8e8;
    --error-text:   #c0392b;
    --success-bg:   #d8f3dc;
    --success-text: #1b4332;
    --info-bg:      #e8f4fd;
    --info-text:    #1a5276;

    --sidebar-w:    220px;
    --radius:       6px;
    --shadow:       0 1px 3px rgba(0,0,0,0.08);
    --shadow-md:    0 4px 12px rgba(0,0,0,0.10);

    --font-body:    'Georgia', serif;
    --font-ui:      system-ui, -apple-system, sans-serif;
    --font-mono:    'Courier New', monospace;
}

/* ---------------------------------------------------------------------------
   Reset & base
--------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
    font-family:      var(--font-ui);
    background-color: var(--bg);
    color:            var(--text);
    line-height:      1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------------------
   Layout — sidebar + main
--------------------------------------------------------------------------- */
.sidebar {
    position:   fixed;
    top:        0;
    left:       0;
    width:      var(--sidebar-w);
    height:     100vh;
    background: var(--primary-dark);
    color:      #e8f5e9;
    display:    flex;
    flex-direction: column;
    z-index:    100;
    overflow-y: auto;
}

.main-content {
    margin-left: var(--sidebar-w);
    min-height:  100vh;
    padding:     2rem 2.5rem;
    max-width:   1200px;
}

/* ---------------------------------------------------------------------------
   Sidebar internals
--------------------------------------------------------------------------- */
.sidebar-header {
    display:     flex;
    align-items: center;
    gap:         0.6rem;
    padding:     1.4rem 1.2rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-icon { font-size: 1.6rem; }

.sidebar-title {
    font-size:   0.8rem;
    font-weight: 700;
    line-height: 1.3;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #b7e4c7;
}

.sidebar-user {
    padding:       0.9rem 1.2rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.user-name {
    font-size:   0.85rem;
    font-weight: 600;
    color:       #ffffff;
}

.user-role {
    font-size: 0.75rem;
    color:     #74c69d;
}

.nav-links {
    list-style: none;
    padding:    0.5rem 0;
    flex:       1;
}

.nav-link {
    display:     flex;
    align-items: center;
    gap:         0.5rem;
    padding:     0.55rem 1.2rem;
    font-size:   0.85rem;
    color:       #b7e4c7;
    transition:  background 0.15s;
    border-radius: 0;
}

.nav-link:hover {
    background:      rgba(255,255,255,0.08);
    color:           #ffffff;
    text-decoration: none;
}

.nav-link.active {
    background: rgba(255,255,255,0.12);
    color:      #ffffff;
    font-weight: 600;
}

.nav-icon { width: 1.2rem; text-align: center; }

.nav-divider {
    height:     1px;
    background: rgba(255,255,255,0.1);
    margin:     0.5rem 1.2rem;
}

.badge {
    margin-left:      auto;
    background:       var(--accent);
    color:            #fff;
    font-size:        0.7rem;
    font-weight:      700;
    padding:          0.1rem 0.45rem;
    border-radius:    10px;
    min-width:        1.4rem;
    text-align:       center;
}

.sidebar-footer {
    padding:       1rem 1.2rem;
    border-top:    1px solid rgba(255,255,255,0.1);
}

.logout-link {
    font-size: 0.8rem;
    color:     #74c69d;
}

.logout-link:hover { color: #ffffff; }

/* ---------------------------------------------------------------------------
   Login page
--------------------------------------------------------------------------- */
.login-body {
    background:      var(--bg);
    display:         flex;
    align-items:     center;
    justify-content: center;
    min-height:      100vh;
}

.login-container {
    background:    var(--surface);
    border:        1px solid var(--border);
    border-radius: var(--radius);
    box-shadow:    var(--shadow-md);
    padding:       2.5rem 2rem;
    width:         100%;
    max-width:     400px;
}

.login-header { text-align: center; margin-bottom: 1.8rem; }

.login-icon  { font-size: 2.5rem; margin-bottom: 0.5rem; }

.login-title {
    font-size:   1.4rem;
    font-weight: 700;
    color:       var(--primary-dark);
}

.login-subtitle {
    font-size: 0.85rem;
    color:     var(--text-muted);
    margin-top: 0.25rem;
}

.login-footer {
    text-align: center;
    font-size:  0.75rem;
    color:      var(--text-faint);
    margin-top: 1.5rem;
}

/* ---------------------------------------------------------------------------
   Page header
--------------------------------------------------------------------------- */
.page-header {
    margin-bottom: 1.8rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.page-title {
    font-size:   1.6rem;
    font-weight: 700;
    color:       var(--primary-dark);
}

.page-subtitle {
    font-size:  0.85rem;
    color:      var(--text-muted);
    margin-top: 0.2rem;
}

/* ---------------------------------------------------------------------------
   Cards
--------------------------------------------------------------------------- */
.card {
    background:    var(--surface);
    border:        1px solid var(--border);
    border-radius: var(--radius);
    padding:       1.5rem;
    box-shadow:    var(--shadow);
    margin-bottom: 1.2rem;
}

.card-title {
    font-size:     1rem;
    font-weight:   600;
    margin-bottom: 1rem;
    color:         var(--primary-dark);
}

/* ---------------------------------------------------------------------------
   Metrics row
--------------------------------------------------------------------------- */
.metrics-row {
    display: grid;
    gap:     1rem;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    margin-bottom: 1.5rem;
}

.metric-card {
    background:    var(--surface);
    border:        1px solid var(--border);
    border-radius: var(--radius);
    padding:       1.2rem 1.4rem;
    box-shadow:    var(--shadow);
}

.metric-label {
    font-size:     0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color:         var(--text-muted);
    margin-bottom: 0.3rem;
}

.metric-value {
    font-size:   1.6rem;
    font-weight: 700;
    color:       var(--primary-dark);
    line-height: 1.2;
}

.metric-delta {
    font-size:  0.75rem;
    margin-top: 0.2rem;
}

.metric-delta.positive { color: var(--primary); }
.metric-delta.negative { color: var(--accent); }

/* ---------------------------------------------------------------------------
   Tables
--------------------------------------------------------------------------- */
.table-wrapper {
    overflow-x:    auto;
    border:        1px solid var(--border);
    border-radius: var(--radius);
    background:    var(--surface);
}

table {
    width:           100%;
    border-collapse: collapse;
    font-size:       0.85rem;
}

th {
    background:    var(--bg);
    padding:       0.6rem 1rem;
    text-align:    left;
    font-size:     0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color:         var(--text-muted);
    font-weight:   600;
    border-bottom: 1px solid var(--border);
    white-space:   nowrap;
}

td {
    padding:       0.6rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tr:last-child td { border-bottom: none; }

tr:hover td { background: var(--bg); }

.amount-positive { color: var(--primary);  font-weight: 600; }
.amount-negative { color: var(--accent);   font-weight: 600; }
.text-muted      { color: var(--text-muted); }
.text-mono       { font-family: var(--font-mono); font-size: 0.8rem; }

/* ---------------------------------------------------------------------------
   Forms
--------------------------------------------------------------------------- */
.form-group    { margin-bottom: 1.2rem; }

.form-label {
    display:       block;
    font-size:     0.8rem;
    font-weight:   600;
    margin-bottom: 0.35rem;
    color:         var(--text);
}

.form-input,
.form-select,
.form-textarea {
    width:         100%;
    padding:       0.55rem 0.75rem;
    border:        1px solid var(--border-dark);
    border-radius: var(--radius);
    font-size:     0.875rem;
    font-family:   var(--font-ui);
    background:    var(--surface);
    color:         var(--text);
    transition:    border-color 0.15s, box-shadow 0.15s;
    appearance:    none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline:      none;
    border-color: var(--primary);
    box-shadow:   0 0 0 3px rgba(45,106,79,0.12);
}

.form-hint {
    font-size:  0.75rem;
    color:      var(--text-muted);
    margin-top: 0.25rem;
    display:    block;
}

.form-row {
    display: grid;
    gap:     1rem;
    grid-template-columns: 1fr 1fr;
}

/* ---------------------------------------------------------------------------
   Buttons
--------------------------------------------------------------------------- */
.btn {
    display:       inline-flex;
    align-items:   center;
    gap:           0.4rem;
    padding:       0.55rem 1.2rem;
    font-size:     0.85rem;
    font-weight:   600;
    font-family:   var(--font-ui);
    border:        1px solid transparent;
    border-radius: var(--radius);
    cursor:        pointer;
    transition:    background 0.15s, border-color 0.15s, color 0.15s;
    text-decoration: none;
    white-space:   nowrap;
}

.btn-primary {
    background:   var(--primary);
    color:        #ffffff;
    border-color: var(--primary);
}

.btn-primary:hover {
    background:      var(--primary-dark);
    border-color:    var(--primary-dark);
    color:           #ffffff;
    text-decoration: none;
}

.btn-secondary {
    background:   var(--surface);
    color:        var(--text);
    border-color: var(--border-dark);
}

.btn-secondary:hover {
    background:      var(--bg);
    text-decoration: none;
}

.btn-danger {
    background:   #c0392b;
    color:        #ffffff;
    border-color: #c0392b;
}

.btn-danger:hover { background: #a93226; }

.btn-full { width: 100%; justify-content: center; }

.btn-row {
    display:    flex;
    gap:        0.75rem;
    flex-wrap:  wrap;
    margin-top: 1.2rem;
}

/* ---------------------------------------------------------------------------
   Alerts
--------------------------------------------------------------------------- */
.alert {
    padding:       0.75rem 1rem;
    border-radius: var(--radius);
    font-size:     0.85rem;
    margin-bottom: 1rem;
    border:        1px solid transparent;
}

.alert-error {
    background:   var(--error-bg);
    color:        var(--error-text);
    border-color: #f5c6cb;
}

.alert-warning {
    background:   var(--warning-bg);
    color:        var(--warning-text);
    border-color: #ffc107;
}

.alert-success {
    background:   var(--success-bg);
    color:        var(--success-text);
    border-color: #95d5b2;
}

.alert-info {
    background:   var(--info-bg);
    color:        var(--info-text);
    border-color: #bee3f8;
}

/* ---------------------------------------------------------------------------
   Progress bar
--------------------------------------------------------------------------- */
.progress {
    height:        6px;
    background:    var(--border);
    border-radius: 3px;
    overflow:      hidden;
    margin-bottom: 1rem;
}

.progress-bar {
    height:        100%;
    background:    var(--primary);
    border-radius: 3px;
    transition:    width 0.3s ease;
}

/* ---------------------------------------------------------------------------
   Utility
--------------------------------------------------------------------------- */
.text-right  { text-align: right; }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5rem 0;
}

/* ---------------------------------------------------------------------------
   HTMX loading indicator
--------------------------------------------------------------------------- */
.htmx-indicator {
    opacity:    0;
    transition: opacity 0.2s;
}
.htmx-request .htmx-indicator { opacity: 1; }
.htmx-request.htmx-indicator  { opacity: 1; }

/* ---------------------------------------------------------------------------
   Responsive
--------------------------------------------------------------------------- */
@media (max-width: 768px) {
    .sidebar       { width: 100%; height: auto; position: relative; }
    .main-content  { margin-left: 0; padding: 1rem; }
    .form-row      { grid-template-columns: 1fr; }
    .metrics-row   { grid-template-columns: 1fr 1fr; }
}
