/* =====================================================
   Хронос-2124: Виртуальный ежедневник директора
   Основные стили. Светлая тема по умолчанию.
   ===================================================== */

/* =====================================================
   СВЕТЛАЯ ТЕМА (по умолчанию)
   ===================================================== */
:root,
[data-theme="light"] {
    --primary: #1a237e;
    --primary-light: #534bae;
    --primary-dark: #000051;
    --secondary: #00897b;
    --accent: #ff6f00;
    
    --success: #43a047;
    --warning: #fb8c00;
    --danger: #e53935;
    --info: #039be5;
    
    --bg-primary: #f5f7fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #eef1f5;
    --bg-dark: #1a1a2e;
    
    --text-primary: #1a1a2e;
    --text-secondary: #5a5a7a;
    --text-muted: #9a9ab0;
    --text-light: #ffffff;
    
    --border-color: #e0e4e8;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.16);
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    --header-height: 64px;
    --sidebar-width: 260px;
    
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;
    
    --today-bg: rgba(26, 35, 126, 0.10);
    --today-border: #1a237e;
    --today-number-bg: #1a237e;
    --today-number-color: #ffffff;
    
    --weekend-bg: rgba(0, 0, 0, 0.025);
    --holiday-bg: rgba(229, 57, 53, 0.07);
    --dayoff-bg: rgba(251, 140, 0, 0.07);
    --workday-bg: rgba(67, 160, 71, 0.06);
    --vacation-bg: rgba(3, 155, 229, 0.06);
    --shortday-bg: rgba(255, 193, 7, 0.08);
}

/* =====================================================
   ТЁМНАЯ ТЕМА
   ===================================================== */
[data-theme="dark"] {
    --primary: #6478ff;
    --primary-light: #8896ff;
    --primary-dark: #4a5cdb;
    --secondary: #00bcd4;
    --accent: #ff9800;
    
    --success: #66bb6a;
    --warning: #ffa726;
    --danger: #ef5350;
    --info: #42a5f5;
    
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #252540;
    --bg-dark: #000000;
    
    --text-primary: #ffffff;
    --text-secondary: #b0b0c0;
    --text-muted: #707080;
    --text-light: #ffffff;
    
    --border-color: #2a2a45;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.6);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.7);
    
    --today-bg: rgba(100, 120, 255, 0.18);
    --today-border: #6478ff;
    --today-number-bg: #6478ff;
    --today-number-color: #ffffff;
    
    --weekend-bg: rgba(255, 255, 255, 0.03);
    --holiday-bg: rgba(239, 83, 80, 0.12);
    --dayoff-bg: rgba(255, 167, 38, 0.12);
    --workday-bg: rgba(102, 187, 106, 0.10);
    --vacation-bg: rgba(66, 165, 245, 0.10);
    --shortday-bg: rgba(255, 213, 79, 0.12);
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-primary);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

body.not-authenticated {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
}

.hidden { display: none !important; }
.text-danger { color: var(--danger) !important; }
.text-muted { color: var(--text-muted); font-size: 12px; }

/* =====================================================
   КАЛЕНДАРЬ: подсветка сегодня, праздников, выходных
   ===================================================== */

/* Ячейка дня */
.fc .fc-daygrid-day {
    position: relative;
    cursor: pointer;
    touch-action: manipulation;
    overflow: hidden;
    min-height: 100px;
    transition: background-color 0.2s ease;
}

.fc .fc-daygrid-day-frame {
    min-height: 100%;
    overflow: hidden;
}

/* Сегодня */
.fc .fc-day-today,
.fc .fc-daygrid-day.chronos-today {
    background-color: var(--today-bg) !important;
}

.fc .fc-daygrid-day.chronos-today .fc-daygrid-day-frame {
    box-shadow: inset 0 0 0 2px var(--today-border);
    border-radius: 8px;
}

/* Номер дня "сегодня" — круглый бейдж */
.fc .fc-daygrid-day.chronos-today .fc-daygrid-day-number,
.fc .fc-day-today .fc-daygrid-day-number {
    background-color: var(--today-number-bg) !important;
    color: var(--today-number-color) !important;
    border-radius: 50% !important;
    width: 24px !important;
    height: 24px !important;
    min-width: 24px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-weight: 700 !important;
    font-size: 12px !important;
    margin: 2px !important;
    padding: 0 !important;
    line-height: 1 !important;
}

/* Подпись "Сегодня" — через псевдоэлемент (не перекрывает события) */
.fc .fc-daygrid-day.chronos-today .fc-daygrid-day-top::before {
    content: 'Сегодня';
    display: inline-block;
    margin: 2px 4px 2px 0;
    padding: 0 6px;
    font-size: 9px;
    font-weight: 700;
    color: #fff;
    background: var(--today-number-bg);
    border-radius: 8px;
    line-height: 14px;
    height: 14px;
    vertical-align: middle;
    letter-spacing: 0.3px;
}

.fc .fc-col-header-cell.chronos-today {
    background-color: var(--today-bg) !important;
    color: var(--today-border) !important;
    font-weight: 700 !important;
}

/* Индикатор "сейчас" */
.fc .fc-timegrid-now-indicator-line {
    border-color: var(--danger) !important;
    border-width: 2px !important;
    z-index: 5 !important;
}

.fc .fc-timegrid-now-indicator-arrow {
    border-top-color: var(--danger) !important;
    border-bottom-color: var(--danger) !important;
}

/* =====================================================
   ПРАЗДНИКИ И ВЫХОДНЫЕ
   ===================================================== */

.fc-daygrid-day.chronos-holiday,
.fc-timegrid-col.chronos-holiday {
    background-color: var(--holiday-bg) !important;
}

.fc-daygrid-day.chronos-holiday-day_off,
.fc-timegrid-col.chronos-holiday-day_off {
    background-color: var(--dayoff-bg) !important;
}

.fc-daygrid-day.chronos-holiday-workday,
.fc-timegrid-col.chronos-holiday-workday {
    background-color: var(--workday-bg) !important;
}

.fc-daygrid-day.chronos-holiday-vacation,
.fc-timegrid-col.chronos-holiday-vacation {
    background-color: var(--vacation-bg) !important;
}

.fc-daygrid-day.chronos-holiday-short_day,
.fc-timegrid-col.chronos-holiday-short_day {
    background-color: var(--shortday-bg) !important;
}

.fc-daygrid-day.chronos-weekend,
.fc-timegrid-col.chronos-weekend {
    background-color: var(--weekend-bg);
}

.fc-daygrid-day.chronos-today.chronos-holiday,
.fc-daygrid-day.chronos-today.chronos-weekend,
.fc-timegrid-col.chronos-today.chronos-holiday {
    background-color: var(--today-bg) !important;
}

/* Метка праздника на десктопе */
.chronos-holiday-label {
    display: block;
    margin-top: 1px;
    padding: 0 4px;
    font-size: 9px;
    font-weight: 600;
    border-radius: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    line-height: 12px;
    height: 14px;
}

/* Цветная точка праздника на мобильных */
.fc-daygrid-day.has-holiday-dot::after {
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--holiday-color, #e53935);
    z-index: 2;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.6);
}

[data-theme="dark"] .fc-daygrid-day.has-holiday-dot::after {
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
}

.fc .fc-col-header-cell.fc-day-sat .fc-col-header-cell-cushion,
.fc .fc-col-header-cell.fc-day-sun .fc-col-header-cell-cushion {
    color: var(--danger);
    font-weight: 600;
}

.fc-daygrid-day.chronos-other-month {
    opacity: 0.45;
}

/* =====================================================
   СОБЫТИЯ В ЯЧЕЙКАХ КАЛЕНДАРЯ
   Главное: события НЕ выходят за границы ячейки
   ===================================================== */

.fc .fc-daygrid-day-events {
    margin: 0 !important;
    padding: 0 2px 2px !important;
    overflow: hidden !important;
    min-height: 0 !important;
}

.fc .fc-daygrid-event-harness {
    margin-top: 1px !important;
    overflow: hidden !important;
    max-width: 100% !important;
}

.fc .fc-daygrid-event {
    margin: 0 !important;
    padding: 0 4px !important;
    border-radius: 4px !important;
    border: none !important;
    cursor: pointer;
    overflow: hidden !important;
    white-space: nowrap !important;
    text-overflow: ellipsis !important;
    max-width: 100% !important;
    font-size: 11px !important;
    line-height: 16px !important;
    height: 16px !important;
    min-height: 16px !important;
    display: flex !important;
    align-items: center !important;
}

.fc .fc-daygrid-event .fc-event-main {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    width: 100% !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    gap: 3px !important;
}

.fc .fc-daygrid-event .fc-event-main-frame {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    gap: 3px !important;
}

.fc .fc-daygrid-event .fc-event-time {
    font-weight: 700 !important;
    font-size: 10px !important;
    opacity: 0.95;
    flex-shrink: 0;
}

.fc .fc-daygrid-event .fc-event-title {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    flex: 1 1 auto;
    min-width: 0;
    font-weight: 500;
}

.fc .fc-daygrid-event .fc-event-title-container {
    overflow: hidden !important;
    min-width: 0;
    flex: 1 1 auto;
}

.fc .fc-daygrid-event .fc-event-icon {
    flex-shrink: 0;
    font-size: 11px;
}

/* "Ещё N" — компактно */
.fc .fc-daygrid-more-link {
    font-size: 10px !important;
    font-weight: 700 !important;
    color: var(--primary) !important;
    padding: 0 4px !important;
    line-height: 14px !important;
    margin-top: 1px !important;
    text-decoration: none !important;
}

.fc .fc-daygrid-more-link:hover {
    text-decoration: underline !important;
}

/* Точки событий (когда включён dayMaxEvents) */
.fc .fc-daygrid-event-dot {
    border-width: 3px !important;
    margin: 0 2px !important;
}

/* Режим "Неделя" и "День" */
.fc .fc-timegrid-event {
    border-radius: 4px !important;
    border: none !important;
    padding: 2px 4px !important;
    font-size: 11px !important;
    overflow: hidden !important;
}

.fc .fc-timegrid-event .fc-event-main {
    overflow: hidden !important;
}

.fc .fc-timegrid-event .fc-event-title {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

/* =====================================================
   ОБЩИЕ СТИЛИ FULLCALENDAR
   ===================================================== */

.fc { font-family: inherit; }
.fc .fc-toolbar-title {
    font-size: 18px !important;
    font-weight: 600 !important;
    color: var(--text-primary) !important;
}

.fc .fc-button {
    padding: 8px 14px !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    background: var(--bg-tertiary) !important;
    border: none !important;
    color: var(--text-primary) !important;
    border-radius: var(--radius-md) !important;
}

.fc .fc-button:hover { background: var(--primary) !important; color: white !important; }
.fc .fc-button-primary:not(:disabled).fc-button-active { background: var(--primary) !important; color: white !important; }
.fc .fc-daygrid-day-number {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    padding: 2px 4px !important;
}
.fc .fc-col-header-cell-cushion {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 12px;
    padding: 4px 2px !important;
}

.fc .fc-scrollgrid {
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-md) !important;
    overflow: hidden;
}

.fc .fc-scrollgrid-section > td {
    border-color: var(--border-color) !important;
}

.fc .fc-daygrid-day-top {
    display: flex !important;
    flex-direction: row !important;
    justify-content: flex-end !important;
    align-items: center;
    flex-wrap: wrap;
    padding: 0 !important;
    min-height: 22px;
    gap: 2px;
}

/* =====================================================
   ИНДИКАТОР СИНХРОНИЗАЦИИ
   ===================================================== */

.sync-indicator {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin-right: 4px;
    cursor: help;
}

.sync-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    transition: all 0.3s ease;
    box-shadow: 0 0 0 0 rgba(67, 160, 71, 0.7);
}

.sync-dot.active {
    background: var(--primary);
    animation: syncPulse 1s ease-out;
}

.sync-indicator.syncing .sync-dot {
    background: var(--warning);
    animation: syncPulse 1s infinite;
}

.sync-indicator.offline .sync-dot { background: var(--text-muted); }

@keyframes syncPulse {
    0% { box-shadow: 0 0 0 0 rgba(26, 35, 126, 0.7); }
    100% { box-shadow: 0 0 0 8px rgba(26, 35, 126, 0); }
}

.sync-badge {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 600;
    color: #fff;
    background: var(--success);
    border-radius: 10px;
    white-space: nowrap;
    animation: fadeInOut 2s ease;
    z-index: 100;
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translateY(-4px); }
    15% { opacity: 1; transform: translateY(0); }
    85% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-4px); }
}

/* =====================================================
   Переключатель темы
   ===================================================== */

.theme-toggle { position: relative; overflow: hidden; }
.theme-toggle .theme-icon { transition: transform var(--transition-normal), opacity var(--transition-normal); }
.theme-toggle:active { transform: scale(0.95); }
.theme-toggle .theme-icon-light { display: none; color: #ffc107; }
.theme-toggle .theme-icon-dark { display: block; color: var(--text-secondary); }
[data-theme="dark"] .theme-toggle .theme-icon-light { display: block; }
[data-theme="dark"] .theme-toggle .theme-icon-dark { display: none; }

/* =====================================================
   Splash Screen
   ===================================================== */

.splash-screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #000051 0%, #1a237e 100%);
    color: white;
    z-index: 9999;
    transition: opacity var(--transition-slow), visibility var(--transition-slow);
}

.splash-screen.fade-out { opacity: 0; visibility: hidden; }
.splash-logo svg { animation: pulse 1.5s ease-in-out infinite; }

.splash-screen h1 {
    font-size: 28px;
    font-weight: 700;
    margin-top: 20px;
    letter-spacing: 2px;
}

.splash-screen p { font-size: 14px; opacity: 0.8; margin-top: 8px; }

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.8; }
}

/* =====================================================
   Login Screen
   ===================================================== */

.login-screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 100;
}

.login-screen.hidden { display: none; }

.login-container {
    width: 100%;
    max-width: 400px;
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    padding: 40px;
    box-shadow: var(--shadow-xl);
    transition: background-color var(--transition-normal);
}

.login-header { text-align: center; margin-bottom: 32px; }
.login-header svg { color: var(--primary); }

.login-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
    margin-top: 16px;
}

.login-header p { font-size: 14px; color: var(--text-secondary); margin-top: 4px; }
.login-form { display: flex; flex-direction: column; gap: 20px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }

.form-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 12px 16px;
    font-size: 14px;
    font-family: inherit;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-normal);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 35, 126, 0.1);
}

.password-wrapper { position: relative; }
.password-wrapper input { width: 100%; padding-right: 48px; }

.toggle-password {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
}

.toggle-password:hover { color: var(--text-primary); }

.error-message {
    padding: 12px;
    background: rgba(229, 57, 53, 0.1);
    border: 1px solid rgba(229, 57, 53, 0.3);
    border-radius: var(--radius-md);
    color: var(--danger);
    font-size: 13px;
}

.login-footer { text-align: center; margin-top: 24px; color: var(--text-muted); font-size: 12px; }

/* Кнопки */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
}

.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }

.btn-primary:hover:not(:disabled) {
    background: var(--primary-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-primary);
}

.btn-outline:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover:not(:disabled) { background: #c62828; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-icon:hover { background: var(--bg-tertiary); color: var(--primary); }
.btn-loader { display: inline-flex; align-items: center; }
.spinner { animation: spin 1s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* App Layout */
.app {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-rows: var(--header-height) 1fr;
    grid-template-areas:
        "header header"
        "sidebar main";
    min-height: 100vh;
}

.app-header {
    grid-area: header;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 50;
    transition: background-color var(--transition-normal);
}

.menu-toggle {
    display: none;
    padding: 8px;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
}

.header-title { flex: 1; display: flex; align-items: baseline; gap: 12px; }
.header-title h1 { font-size: 18px; font-weight: 700; color: var(--primary); }
.header-date { font-size: 13px; color: var(--text-muted); }
.header-actions { display: flex; align-items: center; gap: 8px; }
.notification-btn { position: relative; }

.notification-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 11px;
    font-weight: 600;
    line-height: 18px;
    text-align: center;
    background: var(--danger);
    color: white;
    border-radius: 9px;
}

.user-menu { position: relative; }

.user-avatar {
    width: 40px;
    height: 40px;
    padding: 0;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    overflow: hidden;
    background: var(--bg-tertiary);
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

.user-avatar:hover { border-color: var(--primary); }
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }

.avatar-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 16px;
    font-weight: 600;
    color: var(--primary);
    background: var(--bg-tertiary);
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 220px;
    padding: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 100;
}

.user-info { padding: 12px; }
.user-info strong { display: block; font-size: 14px; }
.user-info span { font-size: 12px; color: var(--text-muted); }
.user-dropdown hr { margin: 8px 0; border: none; border-top: 1px solid var(--border-color); }

.user-dropdown a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    font-size: 14px;
    color: var(--text-primary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.user-dropdown a:hover { background: var(--bg-tertiary); }

/* Sidebar */
.sidebar {
    grid-area: sidebar;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    transition: background-color var(--transition-normal);
}

.sidebar-nav { flex: 1; padding: 16px 12px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    position: relative;
}

.nav-item:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.nav-item.active { background: rgba(26, 35, 126, 0.08); color: var(--primary); }
[data-theme="dark"] .nav-item.active { background: rgba(100, 120, 255, 0.15); }

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
}

.nav-badge {
    margin-left: auto;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    font-size: 11px;
    font-weight: 600;
    line-height: 20px;
    text-align: center;
    background: var(--danger);
    color: white;
    border-radius: 10px;
}

.nav-divider { margin: 12px 16px; border: none; border-top: 1px solid var(--border-color); }
.sidebar-footer { padding: 16px; border-top: 1px solid var(--border-color); }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 40;
}

/* Main Content */
.main-content {
    grid-area: main;
    padding: 24px;
    overflow-y: auto;
}

.view { animation: fadeIn var(--transition-normal); }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.view-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.view-title h2 { font-size: 24px; font-weight: 700; color: var(--text-primary); }
.view-subtitle { font-size: 14px; color: var(--text-muted); margin-top: 4px; }
.view-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.view-switcher {
    display: flex;
    padding: 4px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.view-btn {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.view-btn:hover { color: var(--text-primary); }

.view-btn.active {
    background: var(--bg-secondary);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

/* Calendar Container */
.calendar-container {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    min-height: 600px;
    transition: background-color var(--transition-normal);
    overflow: hidden;
}

#calendar { height: 100%; }

/* Events List */
.events-list { display: flex; flex-direction: column; gap: 12px; }

.event-card {
    display: flex;
    gap: 16px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
    cursor: pointer;
}

.event-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.event-card-time {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 70px;
    padding: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.event-card-date { font-size: 12px; color: var(--text-muted); }
.event-card-hour { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.event-card-content { flex: 1; }
.event-card-title { font-size: 15px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }

.event-card-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: var(--text-muted);
}

.event-card-type {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 500;
    border-radius: 10px;
}

/* Tasks */
.tasks-board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }

.kanban-column {
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    padding: 16px;
    min-height: 400px;
}

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

.kanban-header h3 { font-size: 14px; font-weight: 600; color: var(--text-primary); }

.kanban-count {
    min-width: 24px;
    height: 24px;
    padding: 0 8px;
    font-size: 12px;
    font-weight: 600;
    line-height: 24px;
    text-align: center;
    background: var(--bg-secondary);
    border-radius: 12px;
}

.kanban-cards { display: flex; flex-direction: column; gap: 10px; }

.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.notifications-list { display: flex; flex-direction: column; gap: 8px; }

.notification-item {
    display: flex;
    gap: 12px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.notification-item:hover { box-shadow: var(--shadow-md); }

.notification-item.unread {
    border-left: 3px solid var(--primary);
    background: rgba(26, 35, 126, 0.02);
}

[data-theme="dark"] .notification-item.unread { background: rgba(100, 120, 255, 0.05); }

/* Help */
.help-content { max-width: 900px; }
.help-section { margin-bottom: 40px; }
.help-section h3 { font-size: 20px; font-weight: 600; margin-bottom: 16px; color: var(--text-primary); }

.help-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}

.help-card h4 { font-size: 16px; font-weight: 600; margin-bottom: 12px; color: var(--primary); }
.help-card ol, .help-card ul { margin-left: 20px; }
.help-card li { margin-bottom: 8px; color: var(--text-secondary); }

.help-card kbd {
    display: inline-block;
    padding: 2px 8px;
    font-family: monospace;
    font-size: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.help-card code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    color: var(--primary);
}

.shortcuts-table { width: 100%; border-collapse: collapse; }
.shortcuts-table td { padding: 8px 12px; border-bottom: 1px solid var(--border-color); }
.shortcuts-table td:first-child { width: 120px; }

.help-note {
    margin-top: 12px;
    padding: 12px;
    background: rgba(251, 140, 0, 0.1);
    border-radius: var(--radius-md);
    font-size: 13px;
    color: var(--warning);
}

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

.modal.active { display: flex; }

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    animation: modalSlideIn var(--transition-normal);
}

.modal-lg { max-width: 700px; }

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(-20px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 { font-size: 18px; font-weight: 600; }

.modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.modal-close:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.modal-body { flex: 1; padding: 24px; overflow-y: auto; }

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
}

.form-section {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.form-section h4 { font-size: 14px; font-weight: 600; color: var(--text-secondary); margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group-lg { grid-column: span 2; }
.checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.checkbox-label input { width: 18px; height: 18px; accent-color: var(--primary); }
.weekdays-selector { display: flex; flex-wrap: wrap; gap: 8px; }

.weekdays-selector label {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    font-size: 13px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.weekdays-selector label:hover { background: var(--border-color); }
.weekdays-selector input { accent-color: var(--primary); }

.attachments-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 32px;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.attachments-dropzone:hover,
.attachments-dropzone.dragover {
    border-color: var(--primary);
    background: rgba(26, 35, 126, 0.02);
    color: var(--primary);
}

.attachments-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }

/* Toast */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 2000;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: var(--bg-dark);
    color: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: toastSlideIn var(--transition-normal);
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }

@keyframes toastSlideIn {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}

/* Notification Panel */
.notification-panel {
    position: fixed;
    top: var(--header-height);
    right: 0;
    width: 380px;
    max-width: 100%;
    height: calc(100vh - var(--header-height));
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    box-shadow: var(--shadow-xl);
    transform: translateX(100%);
    transition: transform var(--transition-normal);
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.notification-panel.open { transform: translateX(0); }

.notification-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.notification-panel-header h3 { font-size: 16px; font-weight: 600; }
.notification-panel-body { flex: 1; overflow-y: auto; padding: 12px; }
.notification-panel-footer { padding: 12px 20px; border-top: 1px solid var(--border-color); text-align: center; }
.notification-panel-footer a { color: var(--primary); text-decoration: none; font-size: 14px; font-weight: 500; }

/* Search Box */
.search-box { position: relative; display: flex; align-items: center; }
.search-box svg { position: absolute; left: 12px; color: var(--text-muted); }

.search-box input {
    padding: 10px 16px 10px 40px;
    font-size: 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    min-width: 250px;
    transition: all var(--transition-fast);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 35, 126, 0.1);
}

/* Filter Dropdown */
.filter-dropdown { position: relative; }

.filter-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 280px;
    padding: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 100;
}

.filter-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.filter-item:hover { background: var(--bg-tertiary); }
.filter-item input { accent-color: var(--primary); }
.filter-menu hr { margin: 8px 0; border: none; border-top: 1px solid var(--border-color); }

/* Offline */
.offline-indicator {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px;
    background: var(--warning);
    color: white;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    z-index: 9999;
    transform: translateY(100%);
    transition: transform var(--transition-normal);
}

.offline-indicator.show { transform: translateY(0); }

/* =====================================================
   МОБИЛЬНАЯ АДАПТАЦИЯ
   ===================================================== */

@media (max-width: 1024px) {
    .app {
        grid-template-columns: 1fr;
        grid-template-areas: "header" "main";
    }
    
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: var(--sidebar-width);
        height: 100vh;
        transform: translateX(-100%);
        transition: transform var(--transition-normal);
        z-index: 50;
    }
    
    .sidebar.open { transform: translateX(0); }
    
    .sidebar-overlay {
        display: block;
        opacity: 0;
        visibility: hidden;
        transition: all var(--transition-normal);
    }
    
    .sidebar-overlay.active { opacity: 1; visibility: visible; }
    .menu-toggle { display: flex; }
    .tasks-board { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    :root {
        --header-height: 56px;
        --sidebar-width: 280px;
    }
    
    .main-content { padding: 12px 8px; }
    .view-header { flex-direction: column; align-items: stretch; gap: 12px; margin-bottom: 16px; }
    .view-controls { flex-direction: column; }
    .view-switcher { width: 100%; }
    .view-btn { flex: 1; padding: 8px 10px; font-size: 12px; }
    .search-box input { min-width: auto; width: 100%; }
    .form-row { grid-template-columns: 1fr; }
    .form-group-lg { grid-column: span 1; }
    .modal-content { max-height: 100vh; border-radius: 0; }
    .modal { padding: 0; align-items: flex-end; }
    .modal-lg { max-width: none; }
    .notification-panel { width: 100%; }
    .toast-container { left: 16px; right: 16px; bottom: 16px; }
    .toast { width: 100%; }
    .header-title h1 { font-size: 15px; }
    .header-date { display: none; }
    .header-actions { gap: 2px; }
    .btn-icon { width: 36px; height: 36px; }
    .user-avatar { width: 36px; height: 36px; }
    
    /* Компактный контейнер календаря */
    .calendar-container {
        padding: 8px;
        border-radius: var(--radius-md);
        min-height: auto;
    }
    
    /* Toolbar календаря — компактный */
    .fc .fc-toolbar {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
        margin-bottom: 8px !important;
    }
    
    .fc .fc-toolbar-chunk {
        display: flex;
        align-items: center;
        gap: 4px;
    }
    
    .fc .fc-toolbar-title {
        font-size: 15px !important;
        font-weight: 700 !important;
    }
    
    .fc .fc-button {
        padding: 6px 10px !important;
        font-size: 12px !important;
    }
    
    .fc .fc-button .fc-icon {
        font-size: 12px !important;
    }
    
    /* Заголовки дней */
    .fc .fc-col-header-cell-cushion {
        font-size: 11px !important;
        font-weight: 600 !important;
        padding: 4px 0 !important;
        color: var(--text-secondary);
    }
    
    /* Ячейки дней */
    .fc .fc-daygrid-day {
        min-height: 62px;
    }
    
    .fc .fc-daygrid-day-frame {
        min-height: 60px !important;
    }
    
    .fc .fc-daygrid-day-top {
        min-height: 20px;
    }
    
    /* Номер дня */
    .fc .fc-daygrid-day-number {
        font-size: 11px !important;
        padding: 2px 4px !important;
        font-weight: 600;
    }
    
    .fc .fc-daygrid-day.chronos-today .fc-daygrid-day-number,
    .fc .fc-day-today .fc-daygrid-day-number {
        width: 20px !important;
        height: 20px !important;
        min-width: 20px !important;
        font-size: 11px !important;
        margin: 1px !important;
    }
    
    /* Подпись "Сегодня" на мобильном */
    .fc .fc-daygrid-day.chronos-today .fc-daygrid-day-top::before {
        content: '';
        display: none;
    }
    
    /* Вместо текста — маленькая точка */
    .fc .fc-daygrid-day.chronos-today .fc-daygrid-day-frame::after {
        content: '';
        position: absolute;
        bottom: 2px;
        left: 50%;
        transform: translateX(-50%);
        width: 4px;
        height: 4px;
        border-radius: 50%;
        background: var(--today-number-bg);
        z-index: 1;
    }
    
    /* События на мобильных — компактные */
    .fc .fc-daygrid-day-events {
        padding: 0 1px 1px !important;
    }
    
    .fc .fc-daygrid-event-harness {
        margin-top: 1px !important;
    }
    
    .fc .fc-daygrid-event {
        font-size: 9.5px !important;
        line-height: 13px !important;
        height: 13px !important;
        min-height: 13px !important;
        padding: 0 3px !important;
        border-radius: 3px !important;
    }
    
    .fc .fc-daygrid-event .fc-event-time {
        font-size: 9px !important;
        display: none; /* на мобильных убираем время из месячной сетки */
    }
    
    .fc .fc-daygrid-event .fc-event-title {
        font-size: 9.5px !important;
        line-height: 13px !important;
    }
    
    .fc .fc-daygrid-event .fc-event-icon {
        display: none;
    }
    
    /* "Ещё N" */
    .fc .fc-daygrid-more-link {
        font-size: 9px !important;
        padding: 0 3px !important;
        line-height: 12px !important;
    }
    
    /* Точка праздника на мобильных */
    .fc-daygrid-day.has-holiday-dot::after {
        width: 5px;
        height: 5px;
        top: 3px;
        right: 3px;
    }
}

@media (max-width: 480px) {
    .login-container { padding: 24px; }
    .view-title h2 { font-size: 18px; }
    .event-card { flex-direction: column; gap: 12px; }
    
    .event-card-time {
        flex-direction: row;
        justify-content: flex-start;
        gap: 8px;
        min-width: auto;
    }
    
    .templates-grid { grid-template-columns: 1fr; }
    
    /* Календарь ещё компактнее */
    .calendar-container { padding: 6px; }
    
    .fc .fc-toolbar-title { font-size: 14px !important; }
    .fc .fc-button { padding: 5px 8px !important; font-size: 11px !important; }
    
    .fc .fc-daygrid-day { min-height: 52px; }
    .fc .fc-daygrid-day-frame { min-height: 50px !important; }
    .fc .fc-daygrid-day-number { font-size: 10px !important; }
    
    .fc .fc-daygrid-day.chronos-today .fc-daygrid-day-number,
    .fc .fc-day-today .fc-daygrid-day-number {
        width: 18px !important;
        height: 18px !important;
        min-width: 18px !important;
        font-size: 10px !important;
    }
    
    .fc .fc-daygrid-event {
        font-size: 9px !important;
        line-height: 12px !important;
        height: 12px !important;
        min-height: 12px !important;
    }
    
    .fc .fc-daygrid-event .fc-event-title {
        font-size: 9px !important;
        line-height: 12px !important;
    }
}

/* =====================================================
   Печать
   ===================================================== */
@media print {
    .app-header,
    .sidebar,
    .sidebar-overlay,
    .view-controls,
    .notification-panel,
    .toast-container,
    .modal,
    .sync-indicator,
    .theme-toggle {
        display: none !important;
    }
    
    .app { display: block; }
    .main-content { padding: 0; }
    .calendar-container { box-shadow: none; border: 1px solid #ddd; }
}