/* Reset and base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #32373c;
    --primary-dark: #23272b;
    --primary-light: #4a5058;
    --accent: #0693e3;
    --success: #16a34a;
    --warning: #f59e0b;
    --danger: #dc2626;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
}

html {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--gray-900);
    background: var(--gray-100);
}

body {
    min-height: 100vh;
    padding-bottom: 2rem;
}

/* Header */
header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #e2edfd;
    color: var(--gray-900);
    box-shadow: var(--shadow);
}

nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

nav h1 {
    flex: 1;
    font-size: clamp(0.9rem, 4vw, 1.25rem);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-logo-wrapper {
    position: relative;
    margin-right: 0.5rem;
    cursor: pointer;
}

.nav-logo-wrapper::before {
    content: "";
    position: absolute;
    width: 38px;
    height: 38px;
    background: #ffdb5a;
    transform: rotate(8deg);
    top: -3px;
    left: -5px;
    z-index: 0;
}

.nav-logo {
    position: relative;
    height: 32px;
    width: auto;
    z-index: 1;
}

.nav-btn {
    background: none;
    border: none;
    color: var(--gray-700);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius);
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.sync-status {
    font-size: 0.75rem;
    opacity: 0.8;
}

.sync-status.online { color: var(--success); }
.sync-status.syncing { color: var(--warning); animation: pulse 1s infinite; }
.sync-status.offline { color: var(--danger); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Main content */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
}

/* Cards */
.card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem;
    margin-bottom: 1rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    min-height: 44px;
    transition: background 0.15s;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: #0574b8;
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-sm {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    min-height: 36px;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.25rem;
    color: var(--gray-700);
}

.form-input {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    min-height: 44px;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(6, 147, 227, 0.1);
}

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

.form-row {
    display: flex;
    gap: 0.5rem;
}

.form-row .form-input {
    flex: 1;
}

/* Lists */
.list {
    list-style: none;
}

.list-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: background-color 0.15s;
}

.list-item:hover {
    background-color: var(--gray-100);
}

.list-item:active {
    background-color: var(--gray-200);
}

.list-item-content {
    flex: 1;
}

.list-item-title {
    font-weight: 500;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.list-item-meta {
    font-size: 0.875rem;
    color: var(--gray-500);
}

.list-item-arrow {
    color: var(--gray-300);
    font-size: 1.25rem;
}

/* Schedule scroll container */
.schedule-scroll-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -1rem;
    padding: 0 1rem;
}

.schedule-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.schedule-table th,
.schedule-table td {
    padding: 0.5rem;
    text-align: left;
    border: 1px solid var(--gray-200);
    vertical-align: top;
}

.schedule-table th {
    background: var(--gray-100);
    font-weight: 600;
    font-size: 0.875rem;
    position: sticky;
    top: 0;
}

/* Date header cells */
.date-header-cell {
    text-align: center;
    min-width: 140px;
}

.date-header-day {
    font-weight: 600;
    white-space: nowrap;
}

.slot-input {
    width: 100%;
    padding: 0.5rem;
    font-size: 0.875rem;
    border: 1px solid var(--gray-200);
    border-radius: 4px;
    margin-bottom: 0.25rem;
    min-height: 36px;
}

.slot-input:last-child {
    margin-bottom: 0;
}

.slot-input:focus {
    outline: none;
    border-color: var(--accent);
}

.slot-input.filled {
    background: #ecfdf5;
    border-color: #86efac;
}

/* Admin sections */
.admin-section {
    margin-bottom: 2rem;
}

.admin-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--gray-200);
}

.admin-section-header .admin-section-title {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.admin-section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--gray-200);
}

/* Event header */
.event-header {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.event-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--gray-900);
    margin: 0;
}

.event-title:not(:last-child) {
    margin-bottom: 0.5rem;
}

.event-header .event-description {
    color: var(--gray-500);
    font-size: 0.95rem;
    margin: 0;
    line-height: 1.6;
}

/* Page footer */
.page-footer,
.schedule-footer {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--gray-200);
    text-align: center;
}

.page-footer .card {
    text-align: left;
    margin-bottom: 1rem;
}

/* Activities list */
.activity-header {
    margin-bottom: 0.25rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--gray-200);
}

.activity-header-label {
    flex: 1;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
}

.activities-list {
    margin-bottom: 0.5rem;
}

.activity-row {
    align-items: center;
}

.activity-row .activity-name {
    min-width: 100px;
}

/* Drag handle */
.drag-handle {
    width: 24px;
    cursor: grab;
    color: var(--gray-400);
    user-select: none;
    text-align: center;
    flex-shrink: 0;
}

.drag-handle:active {
    cursor: grabbing;
}

/* Drag and drop states */
.activity-row.dragging {
    opacity: 0.5;
    background: var(--gray-100);
}

.activity-row.drag-over {
    border-top: 2px solid var(--primary);
    margin-top: -2px;
}

/* Activity blocks in schedule */
.date-activities-cell {
    padding: 0.5rem;
    vertical-align: top;
    min-width: 200px;
}

.activity-block {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 0.75rem;
    margin-bottom: 0.75rem;
}

.activity-block:last-child {
    margin-bottom: 0;
}

.activity-block-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.5rem;
    gap: 0.5rem;
}

.activity-block-header strong {
    font-size: 0.9rem;
}

.activity-block .activity-time {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.activity-slots {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.no-activities-placeholder {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--gray-500);
    font-style: italic;
}

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--gray-900);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    z-index: 1000;
    animation: slideUp 0.3s ease;
}

.toast.hidden {
    display: none;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(1rem);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Utility classes */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.text-muted {
    color: var(--gray-500);
}

.text-danger {
    color: var(--danger);
}

/* Toggle switch */
.toggle-label {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.toggle-label input {
    display: none;
}

.toggle-switch {
    width: 44px;
    height: 24px;
    background: var(--gray-300);
    border-radius: 12px;
    position: relative;
    transition: background 0.2s;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-label input:checked + .toggle-switch {
    background: var(--accent);
}

.toggle-label input:checked + .toggle-switch::after {
    transform: translateX(20px);
}

.toggle-label input:disabled + .toggle-switch {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Badge */
.badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--gray-200);
    color: var(--gray-700);
    border-radius: 999px;
    margin-left: 0.5rem;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }

/* Empty states */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--gray-500);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.empty-state-text {
    margin-bottom: 1rem;
}

/* Responsive */
@media (min-width: 768px) {
    .schedule-table th,
    .schedule-table td {
        padding: 0.75rem;
    }
}

@media (max-width: 480px) {
    .page-footer .form-row {
        flex-direction: column;
    }
    .page-footer .form-row .btn {
        width: 100%;
    }
}
