:root {
    --bg-body: #0f172a;
    --bg-gradient: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
    --bg-gradient-size: 400% 400%;
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
    --text-primary: #ffffff;
    --text-secondary: #e2e8f0;
    --text-muted: #94a3b8;
    --primary: #3b82f6;
    --primary-glow: rgba(59, 130, 246, 0.5);
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --cell-bg: rgba(255, 255, 255, 0.05);
    --cell-hover: rgba(255, 255, 255, 0.1);
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-gradient);
    background-size: var(--bg-gradient-size);
    animation: gradientBG 15s ease infinite;
    color: var(--text-primary);
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.app-wrapper {
    display: flex;
    min-height: 100vh;
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
    gap: 20px;
}

.sidebar {
    width: 260px;
    padding: 25px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow);
}
.sidebar-header { 
    margin-bottom: 30px; 
}
.logo { 
    display: flex; 
    align-items: center; 
    gap: 12px; 
}
.logo-icon { 
    font-size: 2rem; 
}
.logo h1 { 
    font-size: 1.5rem; 
    font-weight: 700; 
}

.sidebar-nav { 
    display: flex; 
    flex-direction: column; 
    gap: 8px; 
    margin-bottom: 30px; 
}
.nav-item {
    display: flex; 
    align-items: center; 
    gap: 12px;
    padding: 12px 16px;
    background: transparent; 
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer; font-size: 1rem;
    transition: var(--transition);
}
.nav-item:hover { 
    background: rgba(255,255,255,0.1); 
    color: white; 
}
.nav-item.active { 
    background: var(--primary); 
    color: white; 
    font-weight: 600; 
}

.category-list { 
    display: flex; 
    flex-wrap: wrap; 
    gap: 8px; 
    margin-bottom: 20px; 
}
.category-btn {
    padding: 6px 12px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer; font-size: 0.85rem;
    transition: var(--transition);
}
.category-btn:hover { 
    background: rgba(255,255,255,0.15); 
    color: white; 
}
.category-btn.active { 
    background: var(--primary); 
    border-color: var(--primary); 
    color: white; 
}

.sidebar-stats {
    padding: 15px;
    background: rgba(0,0,0,0.2);
    border-radius: var(--radius-md);
    margin-bottom: auto;
}
.stat-row { 
    display: flex; 
    justify-content: space-between; 
    font-size: 0.9rem; 
    margin-bottom: 8px; 
}

.sidebar-footer {
    display: flex; 
    gap: 10px; 
    padding-top: 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}
.icon-btn {
    width: 36px; 
    height: 36px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 50%;
    cursor: pointer; 
    font-size: 1.1rem;
    display: flex; 
    align-items: center; 
    justify-content: center;
    transition: var(--transition); 
    color: white;
}
.icon-btn:hover { 
    background: rgba(255,255,255,0.2); 
    transform: scale(1.1); 
}

.main-content {
    flex: 1;
    display: flex; flex-direction: column;
    gap: 20px;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow);
    padding: 20px;
    overflow: hidden;
}

.main-header {
    display: flex; 
    align-items: center; 
    gap: 20px;
    flex-wrap: wrap; 
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.date-navigator { 
    display: flex; 
    align-items: center; 
    gap: 15px; 
}
.icon-btn-small {
    width: 32px; 
    height: 32px;
    background: rgba(255,255,255,0.1);
    border: none; 
    border-radius: 50%;
    color: white; 
    cursor: pointer; 
    font-size: 1rem;
}
.icon-btn-small:hover { 
    background: rgba(255,255,255,0.2); 
}
#current-period { 
    font-size: 1.4rem; 
    font-weight: 700; 
    margin: 0; 
}

.search-container { 
    flex: 1; 
    position: relative; 
    min-width: 200px; 
}
.search-container input {
    width: 100%; 
    padding: 10px 15px 10px 40px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 20px; 
    color: white;
}
.search-icon { 
    position: absolute; 
    left: 12px; 
    top: 50%; 
    transform: translateY(-50%); 
    opacity: 0.7; 
}

.primary-btn {
    padding: 10px 24px;
    background: var(--primary); 
    color: white;
    border: none; 
    border-radius: 20px;
    font-weight: 700; 
    cursor: pointer;
    display: flex; 
    align-items: center; 
    gap: 8px;
    transition: var(--transition);
}
.primary-btn:hover { 
    transform: translateY(-2px); 
    box-shadow: 0 5px 15px var(--primary-glow); 
}

.secondary-btn {
    padding: 10px 20px;
    background: rgba(255,255,255,0.1); 
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 20px; 
    cursor: pointer; 
    font-weight: 600;
}
.secondary-btn:hover { 
    background: rgba(255,255,255,0.2); 
}

.calendar-view { 
    display: none; 
    height: 100%; 
    overflow-y: auto; 
}
.calendar-view.active { 
    display: block; 
    animation: fadeIn 0.4s ease; 
}

.calendar-grid {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 500px; 
    flex-grow: 1; 
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.weekday-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: rgba(0,0,0,0.2);
    padding: 10px 0;
    text-align: center;
    font-weight: 600;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.days-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-auto-rows: 1fr;
    gap: 1px;
    background: rgba(255,255,255,0.1);
    flex-grow: 1;
    min-height: 0;
}

.day-cell {
    background: var(--cell-bg);
    padding: 8px;
    position: relative;
    transition: var(--transition);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 80px;
    border: 1px solid rgba(255,255,255,0.05);
}

.day-cell:hover { 
    background: var(--cell-hover); 
}
.day-cell.other-month { 
    opacity: 0.4; 
    background: rgba(0,0,0,0.1); 
}
.day-cell.today { 
    background: rgba(59, 130, 246, 0.2); 
    border: 1px solid var(--primary); 
}

.day-number {
    font-weight: 600; 
    font-size: 0.9rem;
    margin-bottom: 5px; 
    display: inline-block;
    width: 24px; 
    height: 24px;
    text-align: center; 
    line-height: 24px;
    border-radius: 50%;
    flex-shrink: 0;
}

.day-cell.today .day-number { 
    background: var(--primary); 
    color: white; 
}

.event-chip {
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 4px;
    margin-bottom: 2px;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    flex-shrink: 0;
}

.week-grid, .day-grid {
    display: flex;
    height: calc(100% - 20px);
    overflow-y: auto;
    position: relative;
}

.time-sidebar {
    width: 60px;
    flex-shrink: 0;
    border-right: 1px solid rgba(255,255,255,0.1);
    background: rgba(0,0,0,0.1);
    position: sticky;
    left: 0;
    z-index: 10;
}
.time-slot {
    height: 60px;
    display: flex; 
    align-items: flex-start; 
    justify-content: center;
    font-size: 0.75rem; color: var(--text-muted);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding-top: 2px;
}

.week-columns {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: rgba(255,255,255,0.1);
    position: relative;
}
.week-col {
    background: var(--cell-bg);
    border-right: 1px solid rgba(255,255,255,0.1);
    position: relative;
    min-height: 1440px;
}
.week-col-header {
    height: 40px;
    background: rgba(0,0,0,0.2);
    display: flex; 
    align-items: center; 
    justify-content: center;
    font-weight: 600;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    position: sticky;
    top: 0;
    z-index: 5;
}

.day-column {
    flex: 1;
    background: var(--cell-bg);
    position: relative;
    min-height: 1440px;
}

.grid-event {
    position: absolute;
    left: 4px; right: 4px;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.8rem;
    color: white;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    z-index: 5;
    transition: transform 0.2s;
}
.grid-event:hover { 
    transform: scale(1.02); 
    z-index: 10; 
}

.year-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    padding: 10px;
}
.year-month {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-md);
    padding: 15px;
}
.year-month h3 { 
    text-align: center; 
    margin: 0 0 10px 0; 
    color: var(--primary); 
}
.year-month-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    font-size: 0.75rem;
    text-align: center;
}
.year-day { 
    padding: 4px; 
    border-radius: 4px; 
}
.year-day.has-event { 
    background: var(--primary); 
    color: white; 
}

.modal {
    border: none; 
    border-radius: var(--radius-lg);
    padding: 0; 
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px); 
    color: white;
    max-width: 500px; 
    width: 90%; 
    margin: auto;
    animation: modalPop 0.3s ease;
}
@keyframes modalPop {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}
.modal::backdrop { 
    background: rgba(0,0,0,0.6); 
}

.modal-content { 
    padding: 25px; 
}
.modal-header {
    display: flex; 
    justify-content: space-between;
    margin-bottom: 20px; 
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 10px;
}
.close-btn { 
    background: none; 
    border: none; 
    font-size: 1.5rem; 
    color: white; 
    cursor: pointer; 
}

.form-group { 
    margin-bottom: 15px; 
}
.form-group label { 
    display: block; 
    font-size: 0.9rem; 
    margin-bottom: 5px; 
    color: var(--text-secondary); 
}
.form-row { 
    display: flex; 
    gap: 15px; 
}
.half { 
    flex: 1; 
}

input, select, textarea {
    width: 100%; 
    padding: 10px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-sm);
    color: white;
    box-sizing: border-box;
}
input:focus, select:focus, textarea:focus {
    outline: none; 
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}


.modal-actions {
    display: flex; 
    justify-content: flex-end; 
    gap: 10px; 
    margin-top: 20px;
}
.danger-btn {
    background: var(--danger); 
    color: white; 
    border: none;
    padding: 10px 20px; 
    border-radius: 20px; 
    cursor: pointer;
}
.danger-btn:hover { 
    background: #dc2626; 
}

.secondary-btn { 
    background: rgba(255,255,255,0.1); 
    color: white; 
    border: none; 
    padding: 10px 20px; 
    border-radius: 20px; 
    cursor: pointer; 
}
.secondary-btn:hover { 
    background: rgba(255,255,255,0.2); 
}
.spacer { 
    flex: 1; 
}

.theme-menu {
    position: fixed; 
    top: 70px; 
    right: 20px;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-lg);
    padding: 10px; 
    display: flex; 
    flex-direction: column; 
    gap: 5px;
    z-index: 1000;
    opacity: 0; 
    visibility: hidden; 
    transform: translateY(-10px);
    transition: all 0.3s;
}
.theme-menu:not(.hidden) { 
    opacity: 1; 
    visibility: visible; 
    transform: translateY(0); 
}
.theme-menu button {
    width: 100%; 
    text-align: left; 
    padding: 10px;
    background: transparent; 
    border: none; 
    color: var(--text-secondary);
    cursor: pointer; 
    border-radius: var(--radius-sm);
}
.theme-menu button:hover { 
    background: rgba(255,255,255,0.1); 
    color: white; 
}

.toast-container { 
    position: fixed; 
    bottom: 30px; 
    right: 30px; 
    z-index: 2000; 
    display: flex; 
    flex-direction: column; 
    gap: 10px; 
}
.toast {
    padding: 15px 20px; 
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(10px); 
    color: white;
    border-radius: var(--radius-md); 
    border-left: 4px solid var(--primary);
    animation: slideInRight 0.3s ease;
}
@keyframes slideInRight { from { transform: translateX(100%); } to { transform: translateX(0); } }

.hidden { 
    display: none !important; 
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 1024px) {
    .app-wrapper { flex-direction: column; }
    .sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; padding: 15px; }
    .sidebar-nav { flex-direction: row; margin-bottom: 0; }
    .sidebar-stats { display: none; }
    .calendar-grid { height: 60vh; }
}
@media (max-width: 768px) {
    .week-columns { grid-template-columns: 1fr; }
    .week-col { min-height: 200px; }
    .time-sidebar { display: none; }
    .day-grid { flex-direction: column; }
}
.app-wrapper { max-width: none; padding: 12px; gap: 12px; }
.sidebar { width: 240px; padding: 18px; }
.main-content { gap: 12px; padding: 14px; }
.main-header { padding: 10px 14px; min-height: 42px; }
.sidebar-toggle { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; flex: 0 0 36px; padding: 0; border: 1px solid rgba(255,255,255,0.2); border-radius: 8px; background: rgba(255,255,255,0.1); color: white; cursor: pointer; font-size: 1.1rem; }
.sidebar-toggle:hover { background: rgba(255,255,255,0.2); }
.sidebar-collapsed .sidebar { display: none; }
.sidebar-collapsed .main-content { width: 100%; }
@media (max-width: 1024px) {
    .app-wrapper { flex-direction: row; }
    .sidebar { width: 240px; }
}