/* --- Global Reset & Base Styles (Copied from waitTimes.css) --- */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f0f2f5;
    color: #222;
}

/* --- Header & Navigation (Copied from waitTimes.css) --- */
header {
    background-color: #007bff;
    color: white;
    padding: 1rem 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 1010;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

header h1 {
    margin: 0;
    font-size: 1.5rem;
}

.desktop-user-nav .user-info {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-link {
    color: #fff;
    text-decoration: underline;
}

.header-btn {
    background-color: transparent;
    border: 1px solid white;
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    text-decoration: none;
}
.header-btn:hover {
    background-color: rgba(255,255,255,0.2);
}

/* Hamburger Menu */
.hamburger-menu {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    width: 30px;
    height: 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1100;
}
.hamburger-menu span {
    width: 30px;
    height: 3px;
    background: white;
    border-radius: 10px;
    transition: all 0.3s linear;
}

/* Mobile Nav */
.mobile-nav {
    display: flex;
    flex-direction: column;
    background: #0056b3;
    height: 100%;
    padding: 2rem;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1050;
    transition: transform 0.3s ease-in-out;
    transform: translateX(-100%);
    width: 80%;
    max-width: 300px;
    box-shadow: 2px 0 5px rgba(0,0,0,0.5);
}
.mobile-nav.open { transform: translateX(0); }

.mobile-user-info {
    padding-bottom: 1rem;
    text-align: center;
    color: white;
}
.mobile-user-info span {
    display: block;
    margin-bottom: 10px;
    font-weight: bold;
}

.mobile-nav-link {
    font-size: 1.2rem;
    padding: 1rem 0.5rem;
    font-weight: bold;
    color: #FFF;
    text-decoration: none;
    transition: color 0.3s linear;
    display: block;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.mobile-nav-link:hover { color: #00c040; }

.close-nav-btn {
    position: absolute;
    top: 15px;
    right: 25px;
    background: transparent;
    border: none;
    color: white;
    font-size: 2.5rem;
    cursor: pointer;
    line-height: 1;
}

/* --- Challenges Layout & Components --- */
.container { max-width: 1000px; margin: 20px auto; padding: 0 15px; }

/* Page Header */
.page-header { background: white; padding: 20px; border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.15); margin-bottom: 20px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.page-title h1 { margin: 0; font-size: 1.8rem; color: #111; font-weight: 800; }
.page-title p { margin: 5px 0 0; color: #444; font-weight: 500; }

/* Dashboard Tabs */
.dashboard-tabs { margin-bottom: 20px; display: flex; gap: 10px; }
.tab-btn { padding: 10px 20px; font-size: 0.95rem; background-color: #0056b3; color: white; border: none; border-radius: 30px; cursor: pointer; transition: background 0.2s; box-shadow: 0 4px 6px rgba(0,0,0,0.2); font-weight: bold; }
.tab-btn.inactive { background: #6c757d; }

/* Intro Section */
#active-section { text-align: center; }
#intro-message { padding: 40px 20px; background: white; border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.15); margin-bottom: 20px; }
#intro-message h2 { font-size: 2rem; color: #111; margin-bottom: 10px; }
#intro-message p { font-size: 1.1rem; color: #333; max-width: 600px; margin: 0 auto 30px; line-height: 1.5; }

/* Buttons */
.hero-btn { background-color: #0056b3; color: white; border: none; padding: 12px 30px; border-radius: 30px; font-size: 1.1rem; font-weight: bold; cursor: pointer; transition: background 0.2s; box-shadow: 0 4px 6px rgba(0,0,0,0.2); }
.hero-btn:hover { background-color: #003d80; transform: translateY(-2px); }

.btn-link { background: none; border: none; cursor: pointer; color: #0056b3; font-weight: 700; font-size: 1rem; padding: 5px; }
.btn-link:hover { text-decoration: underline; }
.btn-link-muted { color: #444; }

/* Selection Grid */
#selection-section { display: none; }
.challenges-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; margin-top: 20px; }
.challenge-option-card { background: white; border-radius: 12px; box-shadow: 0 4px 10px rgba(0,0,0,0.1); overflow: hidden; transition: transform 0.2s; cursor: pointer; border: 2px solid #ddd; display:flex; flex-direction: column; }
.challenge-option-card:hover { transform: translateY(-5px); border-color: #0056b3; box-shadow: 0 8px 15px rgba(0,0,0,0.15); }
.challenge-option-header { background: #f1f3f5; padding: 20px; text-align: center; border-bottom: 1px solid #ddd; }
.challenge-option-header h3 { margin: 0; font-size: 1.5rem; color: #0056b3; font-weight: 800; }
.challenge-option-body { padding: 20px; color: #333; text-align: center; flex-grow: 1; display:flex; flex-direction: column; justify-content: center; font-weight: 500; }

/* Setup Section */
.setup-card { background: white; border-radius: 12px; box-shadow: 0 4px 10px rgba(0,0,0,0.1); padding: 25px; margin-bottom: 20px; display: none; border: 1px solid #ddd; }
.setup-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; border-bottom: 2px solid #eee; padding-bottom: 15px; }
.setup-header h2 { color: #111; margin: 0; }
.setup-description { margin-bottom: 15px; font-weight: 600; color: #333; font-size: 1.1rem; }
.setup-form-group { margin-bottom: 20px; }
.setup-form-group label { display: block; font-weight: 700; margin-bottom: 8px; color: #222; }
.setup-form-group select, .setup-form-group input { width: 100%; padding: 12px; border: 2px solid #ccc; border-radius: 6px; font-size: 1rem; color: #111; }
.setup-form-group input:focus { border-color: #0056b3; outline: none; }

/* Challenge Card */
.challenge-card { background: white; border-radius: 12px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); overflow: hidden; margin-bottom: 25px; border-top: 6px solid #0056b3; }
.challenge-header { padding: 15px 20px; display: flex; justify-content: space-between; align-items: center; background: #f8f9fa; border-bottom: 1px solid #ddd; }
.challenge-header h2 { margin: 0; font-size: 1.3rem; color: #111; font-weight: 800; }
.challenge-controls { display: flex; gap: 10px; }
.header-control-btn { background: white; border: 2px solid #ccc; color: #444; padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 0.9rem; font-weight: 600; }
.header-control-btn:hover { background: #e9ecef; border-color: #bbb; color: #111; }

.challenge-body { padding: 20px; }
.goals-section { background: #eef2f7; border-radius: 8px; padding: 15px; margin-bottom: 20px; border: 1px solid #d1d9e6; }
.goals-title { font-weight: 800; margin-bottom: 10px; display: block; color: #111; font-size: 1.1rem; }
.goals-hint { font-size: 0.95rem; color: #444; margin: 5px 0 15px; }
.checkbox-group { display: flex; flex-direction: column; gap: 10px; }
.checkbox-label { display: flex; align-items: center; gap: 12px; cursor: pointer; color: #333; font-weight: 600; }
.checkbox-label input[type="checkbox"] { width: 20px; height: 20px; accent-color: #0056b3; }

.progress-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 15px; margin-top: 20px; }
.park-progress-card { background: white; border: 2px solid #ddd; border-radius: 8px; padding: 15px; text-align: center; transition: all 0.3s ease; display: flex; flex-direction: column; align-items: center; box-shadow: 0 2px 5px rgba(0,0,0,0.05); }
.park-progress-card.visited { background: #e3f9e5; border-color: #28a745; }
.park-icon { font-size: 2.5rem; margin-bottom: 10px; display: block; filter: drop-shadow(0 2px 2px rgba(0,0,0,0.1)); }
.park-name { font-weight: 800; color: #111; margin-bottom: 8px; font-size: 1.1rem; }

.status-badges { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 10px; margin-bottom: 15px; }
.status-badge { font-size: 0.8rem; padding: 4px 8px; border-radius: 6px; background: #e9ecef; color: #555; display: none; font-weight: 600; border: 1px solid #ccc; }
.status-badge.completed { background: #28a745; color: white; border-color: #218838; }

.card-actions { margin-top: auto; display: flex; width: 100%; justify-content: center; }
.log-action-btn { width: 100%; background-color: #0056b3; color: white; border: none; padding: 10px 12px; border-radius: 6px; font-size: 1rem; cursor: pointer; font-weight: 700; transition: background 0.2s; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }
.log-action-btn:hover { background-color: #003d80; }

.overall-progress { margin-top: 20px; padding-top: 20px; border-top: 2px solid #eee; }
.progress-bar-container { width: 100%; height: 24px; background: #ddd; border-radius: 12px; overflow: hidden; margin-top: 8px; box-shadow: inset 0 2px 4px rgba(0,0,0,0.1); }
.progress-bar { height: 100%; background: #28a745; width: 0%; transition: width 0.5s ease; box-shadow: inset 0 -2px 0 rgba(0,0,0,0.2); }

.start-btn-container { text-align: right; margin-top: 20px; }
.start-challenge-btn { background-color: #28a745; color: white; border: none; padding: 12px 25px; border-radius: 6px; cursor: pointer; font-weight: 800; font-size: 1.1rem; box-shadow: 0 4px 6px rgba(0,0,0,0.2); }
.start-challenge-btn:hover { background-color: #218838; }

/* Modal Layout */
.modal {
    position: fixed; 
    z-index: 10000; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    background-color: rgba(0,0,0,0.5); 
    display: none;
    overflow: hidden;
}

.modal-content {
    color: #111; 
    border: 1px solid #888; 
    background-color: #fefefe;
    position: absolute;
    top: 4rem;
    left: 50%;
    transform: translateX(-50%);
    width: 90%; 
    max-width: 500px;
    max-height: calc(100vh - 6rem); 
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    padding: 20px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-content h2 { 
    color: #111; 
    border-bottom: 2px solid #eee; 
    padding-bottom: 10px; 
    margin-bottom: 15px; 
    margin-top: 0; 
    flex-shrink: 0; 
}
.modal-content p.modal-intro { 
    color: #333; 
    font-size: 1.05rem; 
    flex-shrink: 0; 
    margin-bottom: 15px;
}
.close-btn {
    flex-shrink: 0;
    position: absolute; 
    right: 15px; 
    top: 10px; 
    cursor: pointer; 
    font-size: 2rem; 
    color: #111;
    z-index: 10;
}

.picker-search { 
    border: 2px solid #999; 
    padding: 12px; 
    font-size: 1rem; 
    color: #000; 
    width: 100%; 
    box-sizing: border-box;
    flex-shrink: 0;
    margin-bottom: 10px;
}

#picker-list,
.item-list-container,
#selection-options,
#selection-custom-form,
#log-visit-form,
.scrollable-content {
    flex-grow: 1;
    overflow-y: auto;
    min-height: 0;
    padding-right: 5px;
    border-top: 1px solid transparent;
}

.item-list-container {
    border: 1px solid #ddd;
    border-radius: 4px;
}

.modal-buttons { 
    margin-top: 15px; 
    display: flex; 
    gap: 10px; 
    justify-content: flex-end; 
    flex-shrink: 0; 
    padding-top: 10px;
    border-top: 1px solid #eee;
}
.modal-buttons button { flex: 1; }

.form-grid {
    display: grid;
    gap: 15px;
}
.form-grid label { color: #222; font-weight: 700; margin-bottom: 5px; display: block; }

.form-grid input, 
.form-grid select, 
.form-grid textarea,
#log-visit-form textarea,
input[type="datetime-local"],
input[type="number"],
input[type="text"],
.picker-search { 
    border: 2px solid #ccc !important;
    color: #222 !important; 
    background-color: #f9f9f9 !important;
    padding: 12px 15px;
    width: 100%;
    box-sizing: border-box;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#log-visit-form textarea, 
.form-grid textarea {
    min-height: 80px;
    resize: vertical;
}

.form-grid input:focus, 
.form-grid select:focus, 
.form-grid textarea:focus,
#log-visit-form textarea:focus,
.picker-search:focus { 
    border-color: #0056b3 !important; 
    background-color: #fff !important;
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 86, 179, 0.1);
}

.selection-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px; padding: 10px 0; }

.selection-btn { background: #f8f9fa; border: 2px solid #ccc; border-radius: 8px; padding: 15px; cursor: pointer; transition: all 0.2s; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #111 !important; font-weight: 800 !important; font-size: 1rem; }
.selection-btn:hover { background: #e9ecef; border-color: #0056b3; color: #0056b3 !important; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.selection-btn .btn-icon { font-size: 2.2rem; margin-bottom: 8px; color: #111 !important; }
.selection-btn:hover .btn-icon { color: #0056b3 !important; }
.selection-btn.full-width { grid-column: span 2; background-color: #e3f2fd; border-color: #90caf9; }

.picker-option { padding: 12px; border-bottom: 1px solid #ddd; cursor: pointer; color: #222; font-weight: 500; }
.picker-option:hover { background-color: #f0f8ff; color: #0056b3; }
.picker-option.selected { background-color: #cce5ff; border-left: 6px solid #0056b3; font-weight: bold; }

.modal-action-btn { background-color: #0056b3; color: white; font-weight: 800; padding: 12px 24px; border: none; border-radius: 6px; font-size: 1rem; cursor: pointer; width: 100%; }
.modal-action-btn:hover { background-color: #004494; }
.modal-secondary-btn { background-color: #6c757d; color: white; font-weight: 700; padding: 10px 20px; border: none; border-radius: 6px; cursor: pointer; }
.modal-secondary-btn:hover { background-color: #5a6268; }

.text-center { text-align: center; }
.text-primary { color: #0056b3; }
.text-muted { color: #444; }
.text-small { font-size: 0.9rem; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 5px; }
.mt-3 { margin-top: 15px; }
.mt-4 { margin-top: 20px; }
.p-large { padding: 40px; }

#history-section { display: none; }
.history-list { margin-top: 20px; }
.history-item { background: white; border-radius: 8px; padding: 15px; margin-bottom: 12px; border: 1px solid #ddd; border-left: 6px solid #aaa; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
.history-item.completed { border-left-color: #ffc107; background: #fffdf5; }

/* --- Visit History Panel (Synchronized with waitTimes.css) --- */
.log-history-panel {
    position: fixed;
    top: 0;
    right: -100%;
    width: 100%;
    max-width: 480px;
    height: 100%;
    background-color: #f0f2f5;
    box-shadow: -4px 0 15px rgba(0,0,0,0.2);
    z-index: 2000;
    transition: right 0.4s ease-in-out;
    display: flex;
    flex-direction: column;
}
.log-history-panel.open {
    right: 0;
}

.log-panel-header {
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid #dee2e6;
    background-color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0; /* Prevent header from shrinking */
}
.log-panel-header h3 { margin: 0; font-size: 1.25rem; color: #111; }
.log-panel-header button {
    background: none;
    border: none;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    color: #444;
}

/* === MODIFIED: Log Filters with consistent sizing === */
.log-filters {
    display: flex;
    overflow-x: auto;
    padding: 10px 15px;
    background-color: #e2e8f0;
    gap: 8px;
    scrollbar-width: none;
    flex-shrink: 0; /* Critical: prevents filters from being crushed */
    align-items: center;
    -webkit-overflow-scrolling: touch;
}
.log-filters::-webkit-scrollbar { display: none; }

.log-filters button {
    flex: 0 0 auto; /* Prevent growing/shrinking */
    white-space: nowrap;
    padding: 8px 15px;
    font-size: 0.85rem;
    font-weight: 600; /* Consistent weight */
    border-radius: 20px;
    border: 1px solid #ccc;
    background-color: white;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}
.log-filters button.active {
    background-color: #0056b3;
    color: white;
    border-color: #0056b3;
    font-weight: 600; /* Keep weight consistent */
}

/* === ADDED: Date Filter Styles === */
.log-date-filters {
    padding: 10px 15px;
    background-color: #fff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    font-size: 0.9rem;
    flex-shrink: 0; /* Prevent date filters from shrinking */
}

.log-date-filters input[type="date"] {
    padding: 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.85rem;
    background: #f9f9f9;
    color: #333;
    max-width: 130px;
}

.log-date-filters button {
    padding: 6px 10px;
    font-size: 0.8rem;
    background-color: #e9ecef;
    border: 1px solid #ced4da;
    border-radius: 4px;
    cursor: pointer;
    color: #555;
    font-weight: 600;
}
.log-date-filters button:hover {
    background-color: #dde2e6;
}

.log-list {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem;
    min-height: 0; /* Important for flex scrolling */
}

.log-date-group h4 {
    margin: 20px 0 10px;
    font-size: 0.9rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #ddd;
    padding-bottom: 5px;
}

.log-entry-item {
    background-color: #ffffff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    display: flex;
    gap: 15px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    flex-wrap: wrap;
}

.log-icon {
    font-size: 2rem;
    width: 45px;
    height: 45px;
    background: #f8f9fa;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.log-details { flex: 1; min-width: 200px; }
.log-title { font-weight: 800; font-size: 1.1rem; color: #111; margin-bottom: 2px; }
.log-meta { font-size: 0.9rem; color: #555; margin-bottom: 8px; }

.log-notes { 
    margin-top: 10px; 
    font-size: 0.9rem; 
    color: #444; 
    background: #f1f3f5;
    padding: 10px;
    border-radius: 6px;
    border-left: 4px solid #adb5bd;
    font-style: italic;
}

.log-actions { display: flex; flex-direction: column; gap: 10px; }
.log-actions button { background: none; border: none; cursor: pointer; font-size: 1.3rem; opacity: 0.6; }
.log-actions button:hover { opacity: 1; }

.edit-form-container { width: 100%; margin-top: 15px; }

.inline-edit-form {
    background: #fff;
    padding: 1.5rem;
    border: 2px solid #007bff;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.inline-edit-form label { font-weight: 700; font-size: 0.85rem; color: #555; }
.inline-edit-form input, .inline-edit-form textarea, .inline-edit-form select {
    width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 6px;
}
.inline-actions { display: flex; justify-content: flex-end; gap: 10px; }
.inline-actions button { padding: 10px 20px; border-radius: 6px; font-weight: bold; cursor: pointer; border: none; }
.inline-actions .save-btn { background: #28a745; color: white; }
.inline-actions button[type="button"] { background: #6c757d; color: white; }

@media (max-width: 600px) {
    .log-history-panel { max-width: 100%; }
    .page-title h1 { font-size: 1.5rem; }
    .header-right { display: none; }
    .park-progress-card { padding: 12px; }
    .log-action-btn { padding: 12px; font-size: 1.1rem; }
    .hamburger-menu { display: flex; }
    .desktop-user-nav { display: none; }
    .modal-content {
        width: 100% !important;
        height: 100% !important;
        max-width: none !important;
        max-height: none !important;
        top: 0 !important;
        left: 0 !important;
        transform: none !important;
        border-radius: 0 !important;
        margin: 0 !important;
        border: none !important;
    }
}