@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --bg-gradient-start: #f8fafc;
    --bg-gradient-end: #e2e8f0;
    --card-bg: rgba(255, 255, 255, 0.7);
    --card-border: rgba(255, 255, 255, 0.4);
    --text-main: #1e293b;
    --text-muted: #64748b;
    --danger: #ef4444;
    --success: #22c55e;
    --warning: #eab308;
    --radius: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-gradient-start: #0f172a;
        --bg-gradient-end: #1e293b;
        --card-bg: rgba(30, 41, 59, 0.7);
        --card-border: rgba(255, 255, 255, 0.1);
        --text-main: #f8fafc;
        --text-muted: #94a3b8;
    }
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
    color: var(--text-main);
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

.container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

.app-layout {
    display: flex;
    width: 100%;
    min-height: 100vh;
    align-items: stretch;
}

.sidebar {
    width: 250px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid var(--card-border);
    padding: 2rem 1.5rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

@media (prefers-color-scheme: dark) {
    .sidebar {
        background: rgba(30, 41, 59, 0.4);
    }
}

.main-content {
    flex: 1;
    min-width: 0;
    padding: 2rem;
    display: flex;
    justify-content: center;
}

.sidebar-header {
    margin-bottom: 2rem;
    padding: 0 0.5rem;
}

.sidebar-header h2 {
    font-size: 1.25rem;
    margin-bottom: 0;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-main);
    transition: var(--transition);
    font-weight: 500;
}

.nav-item:hover {
    background: rgba(148, 163, 184, 0.15);
}

.nav-item.active {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
    font-weight: 600;
}

.nav-icon {
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-title {
    font-size: 1rem;
}

.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 2.5rem;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
    animation: fadeIn 0.5s ease-out;
}

h1, h2, h3 {
    font-weight: 700;
    margin-bottom: 1rem;
    letter-spacing: -0.025em;
}

h1 {
    font-size: 2.25rem;
    background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-align: center;
    margin-bottom: 2rem;
}

p {
    line-height: 1.6;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

input[type="text"],
textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.9);
    color: var(--text-main);
    font-family: inherit;
    font-size: 1rem;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
    transition: var(--transition);
}

@media (prefers-color-scheme: dark) {
    input[type="text"], textarea {
        background: rgba(0, 0, 0, 0.3);
        border: 2px solid rgba(255, 255, 255, 0.1);
        color: #f8fafc;
    }
}

input[type="text"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

button, .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-secondary {
    background: rgba(148, 163, 184, 0.2);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: rgba(148, 163, 184, 0.3);
}

.date-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.date-item {
    display: flex;
    gap: 0.5rem;
    animation: slideIn 0.3s ease-out;
}

.remove-date {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    padding: 0.75rem;
}

.remove-date:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* Table Styles */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-top: 2rem;
    border-radius: 12px;
    border: 1px solid var(--card-border);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

th, td {
    padding: 1rem;
    text-align: center;
    border-bottom: 1px solid var(--card-border);
    border-right: 1px solid var(--card-border);
}

th {
    background: rgba(0, 0, 0, 0.03);
    font-weight: 600;
}

@media (prefers-color-scheme: dark) {
    th { background: rgba(255, 255, 255, 0.03); }
}

th:last-child, td:last-child {
    border-right: none;
}

.sticky-col {
    position: sticky;
    left: 0;
    z-index: 10;
    background: #ffffff;
    box-shadow: 2px 0 5px -2px rgba(0,0,0,0.1);
}

@media (prefers-color-scheme: dark) {
    .sticky-col {
        background: #1e293b;
        box-shadow: 2px 0 5px -2px rgba(255,255,255,0.05);
    }
}

tr:last-child td {
    border-bottom: none;
}

.vote-0 { color: var(--danger); font-weight: bold; }
.vote-1 { color: var(--warning); font-weight: bold; }
.vote-2 { color: var(--success); font-weight: bold; }

/* Voting UI */
.vote-options {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

.vote-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid transparent;
    background: rgba(148, 163, 184, 0.1);
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    /* Ensure touch actions are handled well */
    touch-action: manipulation;
}

.vote-btn.selected[data-val="0"] { border-color: var(--danger); background: rgba(239, 68, 68, 0.1); }
.vote-btn.selected[data-val="1"] { border-color: var(--warning); background: rgba(234, 179, 8, 0.1); }
.vote-btn.selected[data-val="2"] { border-color: var(--success); background: rgba(34, 197, 94, 0.1); }

/* Copy Link Area */
.share-area {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.share-area input {
    flex: 1;
    background: rgba(0,0,0,0.05);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Calendar Styles */
.calendar-wrapper {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
}

@media (prefers-color-scheme: dark) {
    .calendar-wrapper {
        background: rgba(0, 0, 0, 0.2);
    }
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.calendar-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.btn-icon {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-main);
    padding: 0.5rem;
    border-radius: 50%;
    transition: var(--transition);
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

.btn-icon:hover {
    background: rgba(0, 0, 0, 0.05);
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.25rem;
    text-align: center;
}

.calendar-grid .day-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    padding-bottom: 0.5rem;
}

.calendar-grid .day-cell {
    padding: 0.5rem 0;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
    border: 2px solid transparent;
}

.calendar-grid .day-cell:not(.empty):not(.selected):hover {
    background: rgba(99, 102, 241, 0.1);
}

.calendar-grid .day-cell.selected {
    background: var(--primary-color);
    color: white;
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3);
}

.calendar-grid .day-cell.empty {
    cursor: default;
}

/* Selected Dates List */
.selected-dates-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.selected-date-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.5);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--card-border);
    animation: slideIn 0.2s ease-out;
}

@media (prefers-color-scheme: dark) {
    .selected-date-item {
        background: rgba(0, 0, 0, 0.2);
    }
}

.selected-date-item span {
    font-weight: 500;
}

.selected-date-item select {
    padding: 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--card-border);
    background: var(--card-bg);
    color: var(--text-main);
    font-family: inherit;
    outline: none;
}

.empty-msg {
    color: var(--text-muted);
    font-style: italic;
}



/* Short Calendar Grid */
.short-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.short-day-cell {
    padding: 0.5rem;
    border-radius: 8px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.short-day-cell .day-of-week {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.short-day-cell .day-num {
    font-size: 1.1rem;
    font-weight: bold;
}

.short-day-cell:not(.selected):hover {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--primary-color);
}

.short-day-cell.selected {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.short-day-cell.selected .day-of-week {
    color: rgba(255, 255, 255, 0.8);
}

/* Time Pills */
.time-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.time-pill {
    padding: 0.5rem 0.75rem;
    border-radius: 20px;
    background: rgba(148, 163, 184, 0.1);
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition);
    user-select: none;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

.time-pill:not(.selected):hover {
    background: rgba(148, 163, 184, 0.2);
}

.time-pill.selected {
    background: var(--primary-color);
    color: white;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 2rem;
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-header h3 {
    margin: 0;
}

.close-modal {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

.time-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.time-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 8px;
    transition: background 0.2s;
}

.time-checkbox-label:hover {
    background: rgba(148, 163, 184, 0.1);
}

.time-checkbox-label input[type="checkbox"] {
    width: 1.5rem;
    height: 1.5rem;
    cursor: pointer;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    body {
        /* Remove padding since main-content handles it now */
        padding: 0;
    }
    
    .main-content {
        padding: 1rem 0.5rem;
    }
    
    .glass-card {
        padding: 1.25rem;
    }

    h1 {
        font-size: 1.5rem;
        margin-bottom: 1.5rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    .app-layout {
        flex-direction: column;
        gap: 0;
    }
    
    .sidebar {
        flex: none;
        width: 100%;
        height: auto;
        position: static;
        padding: 1rem;
        border-right: none;
        border-bottom: 1px solid var(--card-border);
    }
    
    .sidebar-header {
        margin-bottom: 1rem;
        padding: 0;
    }

    .sidebar-nav {
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 0.5rem;
    }
    
    .nav-item {
        flex: 0 0 auto;
        min-width: 0;
        white-space: nowrap;
    }

    .calendar-grid .day-cell, .short-day-cell {
        padding: 0.35rem;
        font-size: 0.85rem;
    }
    
    .short-day-cell .day-num {
        font-size: 1rem;
    }

    .short-day-cell .day-of-week {
        font-size: 0.65rem;
    }
    
    .calendar-header h3 {
        font-size: 1rem;
    }

    .btn {
        min-height: 48px;
    }

    th, td {
        padding: 0.75rem 0.5rem;
    }
}
