* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 900px;
    margin: 0 auto;
}

header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 5px;
}

header .subtitle {
    opacity: 0.9;
    font-size: 1.1rem;
}

.card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

.card h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.4rem;
}

.card h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.view.hidden {
    display: none;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #444;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* Buttons */
.btn-primary,
.btn-secondary {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #f0f0f0;
    color: #444;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

.btn-small {
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    font-size: 0.85rem;
}

.btn-small:hover {
    background: #f5f5f5;
}

.btn-link {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1rem;
    opacity: 0.9;
}

.btn-link:hover {
    opacity: 1;
    text-decoration: underline;
}

/* Date Mode Switcher */
.date-mode-switcher {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
    padding: 10px;
    background: #f5f5f5;
    border-radius: 8px;
}

.mode-option {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.mode-option input[type="radio"] {
    width: auto;
    margin: 0;
    cursor: pointer;
}

.mode-label {
    font-weight: 500;
    color: #444;
}

.date-picker-panel.hidden {
    display: none;
}

.picker-description {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 15px;
}

/* Weekly Picker */
.weekly-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    margin-bottom: 15px;
}

.weekday-btn {
    padding: 15px 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: white;
    font-size: 0.9rem;
    font-weight: 500;
    color: #444;
    cursor: pointer;
    transition: all 0.2s;
}

.weekday-btn:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.weekday-btn.selected {
    background: #667eea;
    border-color: #667eea;
    color: white;
}

/* Calendar Picker */
.calendar-picker {
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
}

.calendar-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.calendar-nav button {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px 10px;
    color: #667eea;
}

.calendar-nav span {
    font-weight: 600;
    color: #333;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
}

.calendar-grid .day-header {
    text-align: center;
    font-size: 0.8rem;
    color: #888;
    padding: 5px;
}

.calendar-grid .day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.calendar-grid .day:hover {
    background: #f0f0f0;
}

.calendar-grid .day.selected {
    background: #667eea;
    color: white;
}

.calendar-grid .day.other-month {
    color: #ccc;
}

.calendar-grid .day.past {
    color: #ccc;
    cursor: not-allowed;
}

.selected-dates {
    margin-top: 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.selected-dates .date-tag {
    background: #667eea;
    color: white;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.selected-dates .date-tag button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}

/* Event View */
.event-header {
    border-bottom: 1px solid #eee;
    padding-bottom: 20px;
    margin-bottom: 20px;
}

.event-header h2 {
    margin-bottom: 10px;
}

.event-description {
    color: #666;
    margin-bottom: 15px;
}

/* Name Selection Section */
.name-section {
    padding-top: 10px;
}

.name-input-group {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.name-input-group input,
.name-input-group select {
    flex: 1;
    min-width: 150px;
}

.name-or {
    color: #888;
    font-size: 0.9rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.section-header h3 {
    margin-bottom: 0;
}

.section-header .btn-link {
    color: #667eea;
    font-size: 0.9rem;
}

#current-user-name {
    color: #667eea;
}

#availability-section.hidden {
    display: none;
}

.grid-instructions {
    margin-bottom: 15px;
    color: #666;
    font-size: 0.9rem;
}

/* Availability Grid */
.availability-grid-container {
    overflow-x: auto;
    margin-bottom: 20px;
}

.availability-grid {
    display: grid;
    gap: 2px;
    min-width: fit-content;
    user-select: none;
}

.availability-grid .grid-header {
    background: #f5f5f5;
    padding: 10px;
    text-align: center;
    font-weight: 500;
    font-size: 0.85rem;
    border-radius: 4px;
}

.availability-grid .grid-corner {
    background: #f5f5f5;
    position: sticky;
    left: 0;
    z-index: 2;
}

.availability-grid .grid-time {
    background: #f5f5f5;
    padding: 4px 8px;
    text-align: right;
    font-size: 0.7rem;
    color: #666;
    border-radius: 4px;
    white-space: nowrap;
    position: sticky;
    left: 0;
    z-index: 1;
}

.availability-grid .grid-cell {
    background: #f9f9f9;
    min-height: 20px;
    border-radius: 3px;
    cursor: pointer;
    transition: background 0.15s;
    position: relative;
}

.availability-grid .grid-cell:hover {
    background: #e8f5e9;
}

.availability-grid .grid-cell.selected {
    background: #4caf50;
    box-shadow: inset 0 0 0 3px #2e7d32;
}

.availability-grid .grid-cell.group-1 { background: #c8e6c9; }
.availability-grid .grid-cell.group-2 { background: #a5d6a7; }
.availability-grid .grid-cell.group-3 { background: #81c784; }
.availability-grid .grid-cell.group-4 { background: #66bb6a; }
.availability-grid .grid-cell.group-5 { background: #4caf50; }
.availability-grid .grid-cell.group-all { background: #2e7d32; }

.grid-actions {
    display: flex;
    gap: 15px;
}

/* View Toggle */
.view-toggle {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.toggle-btn {
    padding: 8px 16px;
    border: 2px solid #667eea;
    border-radius: 6px;
    background: white;
    color: #667eea;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-btn:hover {
    background: #f0f0ff;
}

.toggle-btn.active {
    background: #667eea;
    color: white;
}

.group-view.hidden {
    display: none;
}

/* Heatmap Legend */
.heatmap-legend {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    font-size: 0.85rem;
    color: #666;
}

.legend-gradient {
    width: 100px;
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(90deg, #f9f9f9, #c8e6c9, #81c784, #4caf50, #2e7d32);
}

/* Heatmap cells */
.availability-grid .grid-cell.heatmap {
    position: relative;
    cursor: default;
}

.availability-grid .grid-cell.heatmap:hover .tooltip {
    display: block;
}

.tooltip {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    white-space: nowrap;
    z-index: 100;
    margin-bottom: 5px;
}

.tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #333;
}

/* Best Times */
.best-times {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.best-time-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px;
    background: #f9f9f9;
    border-radius: 8px;
}

.best-time-item .time-info {
    flex: 1;
}

.best-time-item .time-date {
    font-weight: 500;
    color: #333;
}

.best-time-item .time-slot {
    color: #666;
    font-size: 0.9rem;
}

.best-time-item .time-bar {
    width: 100px;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.best-time-item .time-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 4px;
}

.best-time-item .time-count {
    font-weight: 600;
    color: #667eea;
    min-width: 60px;
    text-align: right;
}

/* Responses List */
.responses-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.response-tag {
    background: #f0f0f0;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.9rem;
    color: #444;
}

/* Responsive */
@media (max-width: 600px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    .grid-actions {
        flex-direction: column;
    }

    header h1 {
        font-size: 2rem;
    }
}
