/* --- 1. GLOBAL RESET & BASE --- */
html, body {
    height: 100%;
    margin: 0;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: #f4f7f6;
    overflow: hidden; /* Prevent the main window from scrolling */
}

.app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
}

/* --- 2. SIDEBAR NAVIGATION --- */
.sidebar {
    width: 240px;
    min-width: 240px;
    background: #2c3e50;
    color: white;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
    z-index: 10;
}

.sidebar .logo {
    padding: 20px;
    font-size: 1.5rem;
    font-weight: bold;
    border-bottom: 1px solid #34495e;
}

.sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar li {
    padding: 15px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.2s;
}

.sidebar li:hover { background: #34495e; }
.sidebar li.active {
    background: #3498db;
    border-right: 4px solid #fff;
}

/* --- 3. MAIN CONTENT ENGINE --- */
.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.top-bar {
    height: 60px;
    padding: 0 20px;
    background: white;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.admin-view {
    display: none; /* Toggled by JS */
    padding: 20px;
    height: calc(100vh - 60px); /* Fill remaining screen */
    box-sizing: border-box;
    overflow: hidden; /* Lock the view to the screen */
}

/* --- 4. THE EVENTS DASHBOARD GRID --- */
.events-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr; /* Left narrow, Right wide */
    gap: 20px;
    height: 100%;
    min-height: 0; /* Critical: allows children to scroll instead of pushing parent */
}

/* Vertical Stacks */
.left-column-stack, .right-column-stack {
    display: grid;
    gap: 20px;
    height: 100%;
    min-height: 0;
}

.left-column-stack { grid-template-rows: 1fr 1fr; } /* 50/50 split */
.right-column-stack { grid-template-rows: 3fr 2fr; } /* 60/40 split */

/* --- 5. CARDS & SCROLLING --- */
.grid-card {
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Rounds the corners of inner content */
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.card-header {
    background: #f8f9fa;
    padding: 10px 15px;
    font-weight: bold;
    border-bottom: 1px solid #ddd;
    color: #2c3e50;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.btn-admin {
    padding: 5px 12px;
    cursor: pointer;
    background-color: #7f8c8d;
    /* Muted slate to match your dusty theme */
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.8rem;
}

.btn-admin:hover {
    background-color: #95a5a6;
}

.table-container.scrollable {
    flex: 1;
    overflow-y: auto;
    background: white;
    min-height: 0;

    position: relative;
    scroll-padding-top: 45px;
}

/* --- 6. TABLE STYLES --- */
table {
    width: 100%;
    /* Changing collapse to separate fixes most 'bleeding' issues */
    border-collapse: separate;
    border-spacing: 0;
}

thead th {
    position: sticky;
    top: 0;
    /* Use a solid hex to ensure no transparency */
    background-color: #ffffff;
    /* Increased z-index to stay above the 'dusty' row colors */
    z-index: 10;
    padding: 12px 10px;
    text-align: left;
    font-size: 0.85rem;
    color: #7f8c8d;
    /* Since borders don't 'collapse', we apply the bottom border to the TH specifically */
    border-bottom: 2px solid #eee;
}

td {
    padding: 10px;
    border-bottom: 1px solid #eee;
    font-size: 0.9rem;
}

.event-row:hover { background-color: #f1f8ff; cursor: pointer; }
.selected-row { background-color: #e3f2fd !important; border-left: 4px solid #3498db; }

/* Table Columns */
.date-col { width: 75px; font-weight: 600; color: #666; }
.status-tag {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    text-transform: uppercase;
}
.status-tag.active { background: #e1f5fe; color: #0288d1; }

/* --- 7. CALENDAR STYLES --- */
#calendar-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #fff;
}

.year-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 20px;
    align-content: start;
}

.month-container { font-size: 0.75rem; }
.month-name { font-weight: bold; text-align: center; margin-bottom: 8px; border-bottom: 1px solid #eee; }
.days-grid { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; }

.day { padding: 3px; color: #ccc; }
.day.has-event {
    background: #3498db;
    color: white;
    border-radius: 50%;
    font-weight: bold;
    cursor: pointer;
}
.day.today { box-shadow: inset 0 0 0 1px #3498db; border-radius: 50%; }

/* Year Picker */
.year-picker { display: flex; align-items: center; gap: 5px; }
.year-picker input { width: 60px; text-align: center; border: 1px solid #ddd; border-radius: 4px; }
.year-picker button { border: 1px solid #ddd; background: white; cursor: pointer; border-radius: 4px; }

/* --- 8. MAP & FILTERS --- */
#map-container {
    flex: 1;
    width: 100%;
    height: 100%;
    position: relative;
}

#map { height: 100%; width: 100%; }

.filter-controls {
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.filter-row label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 4px; }
.range-group { display: flex; gap: 10px; }
.range-group input { flex: 1; }

/* --- 9. DETAIL PANEL --- */
#detail-panel {
    display: block; /* Always block, but hidden by position */
    position: fixed; /* Fixed is better for a bottom slide-up tray */
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 3px solid #3498db;
    padding: 15px;
    box-shadow: 0 -4px 10px rgba(0,0,0,0.1);
    z-index: 1000;

    /* THE SLIDE LOGIC */
    transform: translateY(100%);
    transition: transform 0.4s ease-out; /* Control the speed here (0.4s) */
}

#detail-panel.active {
    transform: translateY(0);
}

/* Container Isolation */
.ev-modal-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    /* High z-index to stay above OSM map */
}

.ev-modal-box {
    background: #ffffff;
    padding: 25px;
    border-radius: 12px;
    width: 95%;
    max-width: 550px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    color: #333;
}

/* Scoped Input Styles - Won't mess up your table or grid */
.ev-modal-wrapper .ev-input-field,
.ev-modal-wrapper .ev-input-area,
.ev-modal-wrapper .ev-input-select {
    width: 100%;
    padding: 10px;
    margin-top: 5px;
    border: 1px solid #ccd1d1;
    border-radius: 6px;
    box-sizing: border-box;
    font-family: inherit;
}

.ev-form-split {
    display: flex;
    gap: 15px;
    margin-bottom: 12px;
}

.ev-split-item {
    flex: 1;
}

.ev-label {
    display: block;
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: uppercase;
    color: #7f8c8d;
    margin-top: 10px;
}

/* Button Isolation */
.ev-btn {
    padding: 10px 20px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: opacity 0.2s;
}

.ev-btn-cancel {
    background: #ecf0f1;
    color: #2c3e50;
}

.ev-btn-save {
    background: #2ecc71;
    color: white;
}

.ev-btn-danger {
    background: #c08081;
    color: white;
}

/* Dusty Rose */

.ev-btn:hover {
    opacity: 0.8;
}

#open-email-modal-btn 
{
    margin-top: 25px; /* Gap from pagination */
    display: inline-block;
    padding: 10px 20px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.modal-overlay 
{
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7); /* Darkens the background */
    z-index: 3000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.email-modal-content 
{
    background-color: #ffffff; /* FIX: Prevents transparency */
    color: #333333;            /* FIX: Ensures text is visible */
    padding: 25px;
    border-radius: 8px;
    width: 700px;
    max-width: 95vw;
    max-height: 90vh;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;    /* FIX: Prevents horizontal overrun */
}

.email-modal-header 
{
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.email-fields .field-row 
{
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    border-bottom: 1px solid #f9f9f9;
}

.field-row label 
{
    width: 80px;
    font-weight: 600;
    color: #555;
}

.field-row input 
{
    flex-grow: 1;
    border: none;
    padding: 8px;
    outline: none;
    font-size: 14px;
    box-sizing: border-box;
}

.bcc-read-only 
{
    flex-grow: 1;
    font-size: 0.85em;
    color: #777;
    background: #fcfcfc;
    padding: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Quill Editor Container */
#editor-container 
{
    height: 300px; /* Fixed height for the editor */
    background: #fff;
    margin-top: 10px;
    box-sizing: border-box;
}

.email-modal-footer 
{
    margin-top: 20px;
    display: flex;
    justify-content: flex-end;
}

#send-email-btn 
{
    padding: 10px 30px;
    background-color: #27ae60;
    color: white;
    border: none;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
}

.close-modal 
{
    cursor: pointer;
    font-size: 28px;
    color: #999;
    line-height: 1;
}

.close-modal:hover 
{
    color: #333;
}

.event-details-mini 
{
    font-size: 0.75rem;
    line-height: 1.1;

    padding: 4px 6px;
    margin-top: 4px;

    max-height: 4.5em;   /* ~3–4 lines max */
    overflow: hidden;

    border-top: 1px solid #eee;
    color: #666;

    flex-shrink: 0;
}

#event-details .desc 
{
    margin-top: 4px;
    font-size: 0.75rem;
    color: #666;
    max-height: 3em;
    overflow: hidden;
}

.tag-container {
    position: relative;
    display: flex;
    align-items: center;
}

.custom-volunteer-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;

    max-height: 200px;   /* controls visible size */
    overflow-y: auto;

    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;

    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    z-index: 1000;       /* ensures it floats above everything */
}

.menu-item {
    padding: 6px 10px;
    cursor: pointer;
}

.menu-item:hover {
    background: #f0f0f0;
}

.form-group {
    display: grid;
    grid-template-columns: 90px 1fr; /* label | input */
    gap: 6px 10px;
    align-items: center;
}

.form-group label {
    text-align: right;
    font-size: 0.8rem;
    color: #666;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.85rem;
    height: 20px;
}

textarea {
    height: auto;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr; /* two columns */
    gap: 12px 20px;
}

.form-group.wide {
    grid-column: span 2;
}

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

.action-group {
    grid-column: span 2;
    display: flex;
    align-items: center;
    gap: 10px;
}

.action-group label {
    text-align: left;
}

#vol-type-container .dropdown-arrow {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: auto;
}

#vol-type-container {
    position: relative;
}

.multi-select {
    position: relative;
}

.multi-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 4px 28px 4px 6px;
    background: white;
}

.multi-input-wrapper input {
    border: none;
    outline: none;
    flex: 1;
    font-size: 0.9rem;
}

.multi-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;

    max-height: 200px;
    overflow-y: auto;

    background: white;
    border: 1px solid #ccc;
    z-index: 1000;
    display: none;
}

.multi-item {
    padding: 6px 10px;
    cursor: pointer;
}

.multi-item:hover {
    background: #f0f0f0;
}

.multi-item.selected {
    background-color: #d0ebff;
    font-weight: 500;
}

/* optional checkmark */
.multi-item.selected::before {
    content: "✔ ";
    color: green;
}

.import-panel
{
  display: flex;
  flex-direction: column;
  gap: 12px; /* vertical spacing between rows */
}

/* Only affects rows inside this panel */
.import-panel .row
{
  display: flex;
  align-items: center; /* vertical alignment */
  gap: 10px;           /* spacing between controls */
}

/* Optional: consistent label width for alignment */
.import-panel label
{
  min-width: 110px;
}

/* Optional: slightly nicer input sizing consistency */
.import-panel input[type="text"]
{
  min-width: 180px;
}

.import-panel select,
.import-panel input[type="file"]
{
  min-height: 28px;
}

.mapping-panel table
{
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed; /* key for predictable column widths */
}

.mapping-panel th,
.mapping-panel td
{
  padding: 8px 10px;
  text-align: left;
  vertical-align: middle;
}

/* Alternating row colors */
.mapping-panel tbody tr:nth-child(even)
{
  background-color: #f5f5f5;
}

/* Hover highlight for readability */
.mapping-panel tbody tr:hover
{
  background-color: #eaeaea;
}

#importBtn
{
    margin-top: 25px; /* Gap from pagination */
    display: inline-block;
    padding: 10px 20px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}
#exportBtn
{
    margin-top: 25px; /* Gap from pagination */
    display: inline-block;
    padding: 10px 20px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}