/* Nexus Calendar - Self-hosted PHP Calendar Viewer */
/* Swiss Utility Design Theme */

:root {
    --background: #ffffff;
    --foreground: #0f172a;
    --card: #ffffff;
    --card-foreground: #0f172a;
    --primary: #0f172a;
    --primary-foreground: #f8fafc;
    --secondary: #f1f5f9;
    --secondary-foreground: #0f172a;
    --muted: #f8fafc;
    --muted-foreground: #64748b;
    --accent: #f1f5f9;
    --accent-foreground: #0f172a;
    --destructive: #ef4444;
    --border: #e2e8f0;
    --input: #e2e8f0;
    --ring: #0f172a;
    --radius: 0.25rem;
    --success: #16a34a;
    
    --sidebar-width: 280px;
    --toolbar-height: 60px;
}

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

body {
    font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--background);
    color: var(--foreground);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Chivo', sans-serif;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--muted);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    background: rgba(255,255,255,0.8);
    backdrop-filter: blur(12px);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 900;
    letter-spacing: -0.03em;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.sidebar-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted-foreground);
    margin-bottom: 0.75rem;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
}

/* Feed List */
.feed-list {
    list-style: none;
}

.feed-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: var(--radius);
    transition: background 0.15s ease;
}

.feed-item:hover {
    background: var(--accent);
}

.feed-item.disabled .feed-name {
    color: var(--muted-foreground);
    text-decoration: line-through;
}

.feed-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.feed-name {
    flex: 1;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Toggle Switch */
.toggle {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--border);
    border-radius: 10px;
    transition: 0.2s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background: white;
    border-radius: 50%;
    transition: 0.2s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.toggle input:checked + .toggle-slider {
    background: var(--primary);
}

.toggle input:checked + .toggle-slider:before {
    transform: translateX(16px);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: rgba(255,255,255,0.8);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toolbar-title {
    font-size: 1.25rem;
    font-weight: 700;
}

.btn-group {
    display: flex;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.btn-group .btn {
    border: none;
    border-radius: 0;
}

.btn-group .btn:first-child {
    border-radius: var(--radius) 0 0 var(--radius);
}

.btn-group .btn:last-child {
    border-radius: 0 var(--radius) var(--radius) 0;
}

/* Date Picker */
.date-picker-wrapper {
    position: relative;
}

.date-picker-wrapper input[type="date"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--background);
    color: var(--foreground);
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover {
    background: var(--secondary);
    border-color: var(--muted-foreground);
}

.btn-primary {
    background: var(--primary);
    color: var(--primary-foreground);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: #1e293b;
    border-color: #1e293b;
}

.btn-outline {
    background: transparent;
}

.btn-ghost {
    border-color: transparent;
    background: transparent;
}

.btn-ghost:hover {
    background: var(--accent);
    border-color: transparent;
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

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

.btn-danger:hover {
    background: #fef2f2;
}

.btn[disabled] {
    opacity: 0.5;
    pointer-events: none;
}

/* Calendar Grid */
.calendar-container {
    flex: 1;
    overflow: auto;
    padding: 1rem 1.5rem;
}

.calendar-grid {
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

.calendar-header {
    display: grid;
    grid-template-columns: 60px repeat(7, 1fr);
    border-bottom: 2px solid var(--primary);
    background: var(--muted);
    position: sticky;
    top: 0;
    z-index: 5;
}

.time-gutter-header {
    border-right: 1px solid var(--border);
}

.day-header {
    padding: 0.75rem 0.5rem;
    text-align: center;
    font-family: 'Chivo', sans-serif;
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-right: 1px solid var(--border);
}

.day-header:last-child {
    border-right: none;
}

.day-header.today {
    background: #dbeafe;
}

.day-header .day-name {
    display: block;
    color: var(--muted-foreground);
}

.day-header .day-num {
    display: block;
    font-size: 1.25rem;
    font-weight: 900;
    color: var(--foreground);
}

.day-header.today .day-num {
    color: #2563eb;
}

/* All Day Row */
.all-day-row {
    display: grid;
    grid-template-columns: 60px repeat(7, 1fr);
    min-height: 40px;
    border-bottom: 1px solid var(--border);
    background: var(--muted);
}

.all-day-label {
    font-size: 0.65rem;
    color: var(--muted-foreground);
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.all-day-cell {
    border-right: 1px solid var(--border);
    padding: 0.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.all-day-cell:last-child {
    border-right: none;
}

/* Time Grid */
.time-grid-wrapper {
    flex: 1;
    overflow-y: auto;
}

.time-grid {
    display: flex;
    flex-direction: column;
}

.time-row {
    display: grid;
    grid-template-columns: 60px repeat(7, 1fr);
    min-height: 60px;
    border-bottom: 1px solid var(--border);
}

.time-gutter {
    border-right: 1px solid var(--border);
    padding: 0.25rem 0.5rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    color: var(--muted-foreground);
    text-align: right;
}

.time-cell {
    border-right: 1px solid var(--border);
    position: relative;
    background: var(--background);
}

.time-cell:last-child {
    border-right: none;
}

.time-cell.today {
    background: #f0f9ff;
}

.time-cell::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    border-top: 1px dotted var(--border);
}

/* Events */
.event {
    padding: 0.25rem 0.5rem;
    border-radius: 2px;
    color: white;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.event:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 10;
}

.all-day-event {
    white-space: nowrap;
    text-overflow: ellipsis;
}

.timed-event {
    position: absolute;
    left: 2px;
    right: 2px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    z-index: 1;
}

.event-time {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.65rem;
    opacity: 0.9;
}

.event-title {
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal.open {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--card);
    border-radius: 0.5rem;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    width: 100%;
    max-width: 500px;
    margin: 1rem;
    max-height: calc(100vh - 2rem);
    overflow: auto;
}

.modal-header {
    padding: 1.5rem 1.5rem 1rem;
    border-top: 4px solid var(--primary);
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 900;
    letter-spacing: -0.02em;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    font-size: 1.5rem;
    color: var(--muted-foreground);
    cursor: pointer;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--accent);
    color: var(--foreground);
}

.modal-body {
    padding: 0 1.5rem 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* Event Detail */
.event-detail {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1rem;
    color: var(--muted-foreground);
}

.event-detail svg {
    flex-shrink: 0;
    margin-top: 0.125rem;
}

.event-calendar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.calendar-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

/* Search Modal */
.modal-search {
    max-width: 400px;
}

.search-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.search-header input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 1rem;
    font-family: inherit;
    background: transparent;
}

.search-results {
    max-height: 300px;
    overflow-y: auto;
}

.search-hint,
.search-no-results {
    padding: 2rem;
    text-align: center;
    color: var(--muted-foreground);
    font-size: 0.875rem;
}

.search-result {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    transition: background 0.15s;
}

.search-result:hover {
    background: var(--accent);
}

.search-result .calendar-dot {
    margin-top: 0.25rem;
}

.search-result-content {
    flex: 1;
    min-width: 0;
}

.search-result-title {
    display: block;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-meta {
    display: block;
    font-size: 0.75rem;
    color: var(--muted-foreground);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--muted-foreground);
}

.empty-state svg {
    opacity: 0.5;
    margin-bottom: 0.75rem;
}

.empty-state p {
    font-size: 0.875rem;
}

/* Admin Styles */
.admin-body {
    background: var(--muted);
}

.admin-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

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

.admin-header-left {
    display: flex;
    align-items: center;
}

.back-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--muted-foreground);
    text-decoration: none;
    font-size: 0.875rem;
}

.back-link:hover {
    color: var(--foreground);
}

.admin-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
}

.admin-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.admin-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1.5rem;
}

.admin-card h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.admin-card-full {
    grid-column: 1 / -1;
}

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

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.375rem;
}

.form-group input[type="text"],
.form-group input[type="url"],
.form-group input[type="password"] {
    width: 100%;
    padding: 0.625rem 0.75rem;
    font-size: 0.875rem;
    font-family: inherit;
    border: 1px solid var(--input);
    border-radius: var(--radius);
    background: var(--background);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--ring);
    box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.1);
}

.form-hint {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    margin-top: 0.375rem;
}

.form-hint code {
    background: var(--muted);
    padding: 0.125rem 0.25rem;
    border-radius: 2px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

/* Color Picker */
.color-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.color-option {
    cursor: pointer;
}

.color-option input {
    display: none;
}

.color-swatch {
    display: block;
    width: 32px;
    height: 32px;
    border-radius: var(--radius);
    transition: transform 0.15s, box-shadow 0.15s;
}

.color-option:hover .color-swatch {
    transform: scale(1.1);
}

.color-option input:checked + .color-swatch {
    transform: scale(1.1);
    box-shadow: 0 0 0 3px var(--background), 0 0 0 5px var(--primary);
}

/* Table */
.feeds-table-wrapper {
    overflow-x: auto;
}

.feeds-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.feeds-table th,
.feeds-table td {
    padding: 0.75rem 0.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.feeds-table th {
    font-weight: 600;
    color: var(--muted-foreground);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.feed-color-dot {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 50%;
}

.url-truncate {
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
}

.table-actions {
    display: flex;
    gap: 0.25rem;
}

.inline {
    display: inline;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

.badge-muted {
    background: var(--muted);
    color: var(--muted-foreground);
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* Maintenance */
.maintenance-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Login */
.login-card {
    max-width: 400px;
    margin: 2rem auto;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 2rem;
}

.login-card h2 {
    text-align: center;
    margin-bottom: 1.5rem;
}

/* Install */
.install-body {
    background: var(--muted);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.install-container {
    width: 100%;
    max-width: 500px;
    padding: 1rem;
}

.install-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 2rem;
}

.install-header {
    text-align: center;
    margin-bottom: 2rem;
}

.install-header svg {
    color: var(--primary);
    margin-bottom: 1rem;
}

.install-header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.install-header p {
    color: var(--muted-foreground);
}

.install-requirements {
    margin-bottom: 2rem;
}

.install-requirements h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
}

.requirements-list {
    list-style: none;
}

.requirements-list li {
    padding: 0.5rem 0;
    padding-left: 1.5rem;
    position: relative;
}

.requirements-list li::before {
    position: absolute;
    left: 0;
    font-size: 1rem;
}

.requirements-list li.ok::before {
    content: '✓';
    color: var(--success);
}

.requirements-list li.error::before {
    content: '✗';
    color: var(--destructive);
}

.install-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin: 1.5rem 0;
}

.install-credentials {
    background: var(--muted);
    border-radius: var(--radius);
    padding: 1rem;
    margin-top: 1.5rem;
}

.install-credentials h3 {
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.install-credentials p {
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.install-info {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.install-info h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
}

.install-info ul {
    list-style: none;
    font-size: 0.875rem;
    color: var(--muted-foreground);
}

.install-info li {
    padding: 0.25rem 0;
}

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

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    
    .sidebar-content {
        display: none;
    }
    
    .toolbar {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .toolbar-title {
        order: -1;
        width: 100%;
        text-align: center;
    }
    
    .admin-grid {
        grid-template-columns: 1fr;
    }
    
    .calendar-header,
    .all-day-row,
    .time-row {
        grid-template-columns: 40px repeat(7, 1fr);
    }
    
    .day-header .day-name {
        font-size: 0.625rem;
    }
    
    .day-header .day-num {
        font-size: 1rem;
    }
}

