/* 4-H Goat Club — base styles
   Layout: fixed sidebar (240px) + scrolling main content. Sidebar collapses on mobile. */

:root {
    --green: #2f6b3a;
    --green-dark: #234f2c;
    --green-soft: #e8f1ea;
    --accent: #d49a17;
    --bg: #f7f7f4;
    --surface: #ffffff;
    --text: #1f2a24;
    --muted: #6b7a72;
    --border: #d8dcd6;
    --danger: #b3261e;
    --success: #1f7a3d;
    --shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.04);
    --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
}

a { color: var(--green-dark); }

/* ---------- Sidebar ---------- */

.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 240px;
    background: var(--green);
    color: white;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    padding: 4px;
    margin: -4px;
    transition: background .12s;
}
.brand:hover { background: rgba(255,255,255,.06); }
.brand-mark {
    width: 44px; height: 44px;
    background: var(--accent);
    color: var(--green-dark);
    border-radius: 50%;
    display: grid; place-items: center;
    font-weight: 800;
    font-size: 14px;
}
.brand-title { font-weight: 700; font-size: 16px; }
.brand-sub { font-size: 12px; opacity: .8; }

.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a {
    color: white;
    text-decoration: none;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 14px;
    transition: background .12s;
}
.sidebar nav a:hover { background: rgba(255,255,255,.08); }
.sidebar nav a.active { background: rgba(255,255,255,.16); font-weight: 600; }

.sidebar-footer {
    margin-top: auto;
    color: rgba(255,255,255,.7);
    font-size: 12px;
}

.nav-toggle {
    display: none;
    position: fixed;
    top: 12px; left: 12px;
    z-index: 20;
    background: var(--green);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 18px;
    cursor: pointer;
}

@media (max-width: 720px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s; }
    .sidebar.open { transform: translateX(0); }
    .nav-toggle { display: block; }
    .content { margin-left: 0 !important; padding-top: 60px !important; }
}

/* ---------- Main content ---------- */

.content {
    margin-left: 240px;
    padding: 32px 40px;
    max-width: 1100px;
}

.page-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 24px;
}
.page-header h1 { margin: 0 0 4px; font-size: 24px; }
.muted { color: var(--muted); font-size: 14px; }

/* ---------- Calendar ---------- */

#calendar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
}

.fc .fc-toolbar-title { font-size: 18px; }
.fc .fc-button-primary {
    background: var(--green);
    border-color: var(--green);
}
.fc .fc-button-primary:hover { background: var(--green-dark); border-color: var(--green-dark); }
.fc .fc-button-primary:not(:disabled).fc-button-active {
    background: var(--green-dark); border-color: var(--green-dark);
}

.fc-event {
    border: none;
    padding: 2px 4px;
    cursor: pointer;
    font-size: 12px;
}

/* List view (default on the calendar page) — give big touch targets on mobile */
.fc .fc-list-event { cursor: pointer; }
.fc .fc-list-event-title { font-weight: 500; }
.fc .fc-list-event:hover td { background: var(--green-soft); }
.fc .fc-list-day-cushion { background: #f0f3ee; padding: 8px 12px; font-weight: 600; }
.fc .fc-list-event-time { white-space: nowrap; }

@media (max-width: 600px) {
    .fc .fc-toolbar { flex-wrap: wrap; gap: 8px; }
    .fc .fc-toolbar-title { font-size: 16px; }
    .fc .fc-list-event-time,
    .fc .fc-list-event-title { padding: 12px 8px; font-size: 14px; }
}
/* Color semantics: red = needs help, yellow = partial, green = covered */
.slot-event-open    { background: #f3e8e7; color: #5a1a16; border-left: 3px solid var(--danger); }
.slot-event-partial { background: #fff5d9; color: #6b4f00; border-left: 3px solid var(--accent); }
.slot-event-full    { background: var(--green-soft); color: var(--green-dark); border-left: 3px solid var(--green); }

/* Color the whole row in list view so phones show fill-state at a glance */
.fc-list-event.slot-event-open    td { background: #f9eceb; }
.fc-list-event.slot-event-partial td { background: #fff8e5; }
.fc-list-event.slot-event-full    td { background: #ecf5ee; }
.fc-list-event.slot-event-open:hover    td { background: #f0dad7; }
.fc-list-event.slot-event-partial:hover td { background: #ffefc2; }
.fc-list-event.slot-event-full:hover    td { background: #d8ebde; }
.fc-list-event .fc-list-event-dot { display: none; } /* row color carries the signal */

/* ---------- Modal ---------- */

.modal {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    display: none;
    align-items: center; justify-content: center;
    z-index: 100;
}
.modal.open { display: flex; }
.modal-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    width: min(440px, 92vw);
    box-shadow: 0 12px 48px rgba(0,0,0,.2);
    position: relative;
}
.modal-card h2 { margin: 0 0 4px; }
.modal-close {
    position: absolute; top: 8px; right: 12px;
    background: none; border: none;
    font-size: 24px; cursor: pointer;
    color: var(--muted);
}

.signup-list {
    list-style: none;
    padding: 0;
    margin: 12px 0 16px;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}
.signup-list:empty { display: none; }
.signup-list li {
    padding: 8px 0;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
    display: grid;
    grid-template-columns: 1fr auto;
    column-gap: 8px;
    align-items: center;
}
.signup-list li:last-child { border-bottom: none; }
.signup-main { min-width: 0; word-break: break-word; }
.signup-comment { grid-column: 1 / -1; font-size: 13px; font-style: italic; }
.inline-delete {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
    padding: 0 8px;
    line-height: 22px;
    font-size: 16px;
    font-weight: 700;
    border-radius: 6px;
    cursor: pointer;
    grid-row: 1;
    grid-column: 2;
}
.inline-delete:hover { background: #fbeae8; }

/* ---------- Forms ---------- */

.signup-form, .login-form, .stack-form, .grid-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
    font-weight: 500;
}

input[type="text"], input[type="password"], input[type="number"], input[type="date"], input[type="time"], textarea {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 14px;
    font-family: inherit;
    background: var(--surface);
}
input:focus, textarea:focus {
    outline: 2px solid var(--green);
    outline-offset: -1px;
}

button, .btn {
    background: var(--green);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background .12s;
}
button:hover { background: var(--green-dark); }
button:disabled { opacity: .6; cursor: not-allowed; }

.btn-secondary {
    background: transparent;
    color: var(--green-dark);
    border: 1px solid var(--green-dark);
}
.btn-secondary:hover { background: var(--green-soft); }

.btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
    padding: 4px 10px;
    font-size: 12px;
}
.btn-danger:hover { background: #fbeae8; }

.inline-form { display: inline; }

.form-msg { font-size: 13px; min-height: 18px; }
.form-msg.error { color: var(--danger); }
.form-msg.success { color: var(--success); }

/* ---------- Posts ---------- */

.post-list { display: flex; flex-direction: column; gap: 16px; }
.post {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    box-shadow: var(--shadow);
}
.post h2 { margin: 0 0 4px; font-size: 18px; }
.post-meta { margin-bottom: 8px; }
.post p { margin: 0; white-space: pre-wrap; }

/* ---------- Admin ---------- */

.admin-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}
.admin-section h2 { margin-top: 0; font-size: 16px; }

.inline-edit-form {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.inline-edit-form input[type="text"] {
    flex: 1;
    min-width: 200px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.inline-edit-form .form-msg { width: 100%; }

.grid-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    align-items: end;
}
.grid-form-wide { grid-column: 1 / -1; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.data-table th, .data-table td {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
}
.data-table th { font-weight: 600; color: var(--muted); }

/* ---------- Expandable slot rows (admin) ---------- */

.expandable-table .slot-row { cursor: pointer; transition: background .12s; }
.expandable-table .slot-row:hover { background: var(--green-soft); }
.expandable-table .toggle-cell { width: 24px; padding-right: 0; }
.row-toggle {
    display: inline-block;
    transition: transform .15s;
    color: var(--muted);
    font-size: 12px;
}
.row-toggle.expanded { transform: rotate(90deg); color: var(--green-dark); }

.slot-detail-row > td {
    background: #fafaf7;
    padding: 12px 24px 16px 48px !important;
}

.admin-signup-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.admin-signup-list li {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.admin-signup-list li:last-child { border-bottom: none; }
.admin-signup-info { flex: 1; min-width: 0; word-break: break-word; }
.admin-signup-comment { font-size: 13px; font-style: italic; margin-top: 2px; }

.post-admin-list { list-style: none; padding: 0; margin: 0; }
.post-admin-list li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

/* ---------- Auth ---------- */

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert {
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 14px;
}
.alert-error {
    background: #fbeae8;
    border: 1px solid #f5c6c4;
    color: var(--danger);
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 32px;
    box-shadow: var(--shadow);
    max-width: 440px;
}
.login-card p { margin: 0 0 16px; }

.btn-google {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    background: #fff;
    color: #3c4043;
    border: 1px solid #dadce0;
    border-radius: 6px;
    font-weight: 500;
    font-size: 14px;
    text-decoration: none;
    transition: box-shadow .12s, background .12s;
}
.btn-google:hover { box-shadow: 0 1px 3px rgba(0,0,0,.1); background: #f8f9fa; }
.btn-google.disabled {
    opacity: .5;
    pointer-events: none;
}
.btn-google svg { flex-shrink: 0; }

.alert-success {
    background: #e8f5ec;
    border: 1px solid #b9dec5;
    color: var(--success);
}

/* ---------- Home page ---------- */

.hero { margin-bottom: 32px; }
.hero h1 { font-size: 28px; }

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.action-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-decoration: none;
    color: var(--text);
    box-shadow: var(--shadow);
    transition: transform .12s, box-shadow .12s;
    display: block;
}
.action-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,.08);
}
.action-card-icon { font-size: 28px; margin-bottom: 8px; }
.action-card h2 { margin: 0 0 6px; font-size: 18px; color: var(--green-dark); }
.action-card p { margin: 0; color: var(--muted); font-size: 14px; }

.home-section { margin-top: 32px; }
.home-section h2 { font-size: 18px; margin: 0 0 12px; }

/* ---------- Events panel ---------- */

.events-section { margin-bottom: 32px; }
.events-section h2 { font-size: 18px; margin: 0 0 12px; }

.event-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }

.event-item {
    display: flex;
    gap: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius);
    padding: 14px 18px;
    box-shadow: var(--shadow);
}

.event-date {
    flex-shrink: 0;
    width: 56px;
    text-align: center;
    background: var(--green-soft);
    border-radius: 6px;
    padding: 6px 4px;
}
.event-date-month {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--green-dark);
    letter-spacing: .05em;
}
.event-date-day {
    font-size: 24px;
    font-weight: 700;
    color: var(--green-dark);
    line-height: 1.1;
}

.event-body { flex: 1; min-width: 0; }
.event-title { font-weight: 600; font-size: 15px; margin-bottom: 2px; }
.event-body p { margin: 6px 0 0; font-size: 14px; }

/* ---------- Handbook ---------- */

.handbook-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}
.handbook-icon { font-size: 32px; }
.handbook-info { flex: 1; min-width: 0; }
.handbook-name { font-weight: 600; word-break: break-all; }

.handbook-viewer {
    width: 100%;
    height: calc(100vh - 200px);
    min-height: 500px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #f1f1ed;
    box-shadow: var(--shadow);
}

/* ---------- Show Day ---------- */

.show-day-list {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.show-day-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.show-day-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.show-day-item-header h2 { margin: 0 0 4px; font-size: 17px; }

.show-day-image {
    display: block;
    width: 100%;
    max-height: 80vh;
    object-fit: contain;
    background: #1f1f1d;
}

.show-day-pdf {
    display: block;
    width: 100%;
    height: 70vh;
    min-height: 480px;
    border: none;
    background: #f1f1ed;
}

.empty-state {
    text-align: center;
    padding: 64px 24px;
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}
.empty-state-icon { font-size: 56px; margin-bottom: 12px; }
.empty-state h2 { margin: 0 0 8px; color: var(--green-dark); }
.empty-state p { margin: 0; }

.upload-form {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    background: #fafaf7;
}
.upload-form .muted { width: 100%; margin: 0; }
.upload-label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 240px;
    font-size: 13px;
    font-weight: 500;
}
.upload-label input[type="file"] {
    padding: 4px 0;
    font-size: 13px;
}

.btn {
    display: inline-block;
    background: var(--green);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}
.btn:hover { background: var(--green-dark); }
