/* ======================
   ГЛОБАЛЬНЫЕ СТИЛИ
   ====================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #667eea;
    --primary-dark: #5568d3;
    --secondary-color: #764ba2;
    --success-color: #48bb78;
    --danger-color: #f56565;
    --warning-color: #ed8936;
    --info-color: #4299e1;
    --dark-color: #2d3748;
    --light-color: #f7fafc;
    --gray-color: #718096;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
    --shadow-xl: 0 20px 25px rgba(0,0,0,0.15);
    --border-radius-sm: 4px;
    --border-radius-md: 8px;
    --border-radius-lg: 12px;
    --border-radius-xl: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--light-color);
    color: var(--dark-color);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ======================
   СТРАНИЦА АВТОРИЗАЦИИ
   ====================== */

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
    position: relative;
    overflow: auto; /* ← ИЗМЕНЕНО: разрешить прокрутку страницы */
}

.auth-background {
    position: fixed; /* ← ИЗМЕНЕНО: фон фиксированный, не мешает прокрутке */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.1;
    z-index: 1;
}

.bg-shapes {
    position: relative;
    width: 100%;
    height: 100%;
}

.shape {
    position: absolute;
    background: white;
    border-radius: 50%;
}

.shape-1 {
    width: 400px;
    height: 400px;
    top: -200px;
    right: -100px;
}

.shape-2 {
    width: 300px;
    height: 300px;
    bottom: -100px;
    left: 10%;
}

.shape-3 {
    width: 200px;
    height: 200px;
    bottom: 10%;
    right: 15%;
}

.auth-container {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 420px;
    max-height: 90vh; /* ← ДОБАВЛЕНО: ограничение высоты */
    overflow-y: auto; /* ← ДОБАВЛЕНО: прокрутка внутри контейнера */
    padding: 20px 0; /* ← ДОБАВЛЕНО: отступы для прокрутки */
}

.auth-card {
    background: white;
    border-radius: var(--border-radius-xl);
    padding: 40px 30px;
    box-shadow: var(--shadow-xl);
    animation: fadeInUp 0.5s ease-out;
    position: relative;
    z-index: 20;
    margin: 0 auto; /* ← ДОБАВЛЕНО: центрирование */
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-logo {
    font-size: 64px;
    margin-bottom: 15px;
    display: block;
}

.auth-header h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--dark-color);
    margin-bottom: 8px;
}

.auth-subtitle {
    color: var(--gray-color);
    font-size: 14px;
}

.auth-form {
    margin-bottom: 25px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--dark-color);
    font-size: 14px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-md);
    font-size: 15px;
    transition: var(--transition);
    background: white;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.form-control::placeholder {
    color: var(--gray-color);
    opacity: 0.6;
}

.password-wrapper {
    position: relative;
}

.toggle-password {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: var(--gray-color);
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.toggle-password:hover {
    color: var(--primary-color);
}

.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
    color: var(--gray-color);
}

.checkbox-label input[type="checkbox"] {
    margin-right: 8px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.forgot-link {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 14px;
    transition: var(--transition);
}

.forgot-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    background: var(--primary-color);
    color: white;
    min-width: 120px;
}

.btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-block {
    width: 100%;
}

.btn-primary {
    background: var(--primary-color);
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: #6c757d;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-danger {
    background: var(--danger-color);
}

.btn-danger:hover {
    background: #e53e3e;
}

.btn-success {
    background: var(--success-color);
}

.btn-success:hover {
    background: #38a169;
}

.btn-warning {
    background: var(--warning-color);
}

.btn-warning:hover {
    background: #dd6b20;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 14px;
    min-width: auto;
}

.auth-footer {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.auth-footer p {
    margin-bottom: 8px;
    color: var(--gray-color);
    font-size: 14px;
}

.link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
}

.link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.text-warning {
    color: var(--warning-color);
    font-size: 14px;
    margin-top: 10px;
}

/* Чекбокс личной записи */
#is_personal {
    margin-right: 8px;
    cursor: pointer;
}

#is_personal:checked + span {
    font-weight: 600;
    color: var(--primary-color);
}

/* Личные события (фиолетовые с звёздочкой) */
.fc-event-personal {
    border-left: 4px solid #7c3aed !important;
}

.fc-event-personal .fc-event-title::before {
    content: "⭐ ";
    font-size: 1.1em;
}

/* Подсказка для личных событий */
.fc-event-tooltip-personal {
    border-left: 4px solid #7c3aed;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0e7ff 100%);
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--border-radius-md);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
}

.alert-icon {
    font-size: 20px;
}

.alert-danger {
    background: #fff5f5;
    border: 1px solid #fed7d7;
    color: #c53030;
}

.alert-success {
    background: #f0fff4;
    border: 1px solid #9ae6b4;
    color: #276749;
}

.alert-warning {
    background: #fffaf0;
    border: 1px solid #feebc8;
    color: #9c4221;
}

.alert-info {
    background: #ebf8ff;
    border: 1px solid #bee3f8;
    color: #2c5282;
}


/* Ошибки в модальном окне */
#modal-error-container {
    animation: fadeIn 0.3s ease-out;
    border-radius: var(--border-radius-md);
    padding: 15px;
    margin: 15px 0;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ======================
   ОСНОВНОЕ ПРИЛОЖЕНИЕ
   ====================== */

.app-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border-radius: var(--border-radius-lg);
    margin-bottom: 20px;
    box-shadow: var(--shadow-lg);
    flex-wrap: wrap;
    gap: 15px;
}

.header-left h1 {
    font-size: 26px;
    font-weight: 700;
    margin: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.user-info {
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-info small {
    opacity: 0.95;
    font-weight: 400;
}

/* ======================
   ПАНЕЛЬ ФИЛЬТРОВ (ПОЛНОСТЬЮ ОБНОВЛЕНА)
   ====================== */

.filters-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: white;
    border-radius: var(--border-radius-md);
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
    gap: 15px;
}

.filters-left {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.filters-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    min-width: 160px;
}

.filter-group label {
    font-size: 12px;
    color: var(--gray-color);
    margin-bottom: 6px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}

.filter-select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    background: white;
    transition: var(--transition);
    min-width: 150px;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Визуальная индикация активного фильтра */
.filter-select option:checked {
    font-weight: bold;
    color: #667eea;
}

/* Поиск */
.search-wrapper {
    position: relative;
    min-width: 280px;
    max-width: 400px;
}

.search-input {
    width: 100%;
    padding: 10px 40px 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    transition: var(--transition);
    background: white;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.search-input::placeholder {
    color: var(--gray-color);
    opacity: 0.7;
}

.btn-search-clear {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 20px;
    color: var(--gray-color);
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}

.btn-search-clear:hover {
    color: var(--danger-color);
    background: rgba(245, 101, 101, 0.1);
}

/* Кнопка обновления */
.btn-icon {
    position: relative;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: var(--border-radius-sm);
    background: var(--primary-color);
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
    overflow: hidden;
}

.btn-icon:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-icon:active {
    transform: translateY(0);
}

.btn-icon-text {
    position: relative;
    z-index: 2;
}

.btn-icon-active {
    animation: pulse 0.3s ease-in-out;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.btn-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: #1a202c;
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
    z-index: 100;
}

.btn-icon:hover .btn-tooltip {
    opacity: 1;
    transform: translateX(-50%) translateY(5px);
}

/* Адаптивность */
@media (max-width: 1024px) {
    .filters-panel {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filters-left,
    .filters-right {
        width: 100%;
        justify-content: center;
    }
    
    .search-wrapper {
        min-width: 100%;
        max-width: 100%;
    }
    
    .filter-group {
        min-width: 140px;
    }
}

@media (max-width: 768px) {
    .filters-panel {
        padding: 14px;
    }
    
    .filter-group {
        min-width: 100%;
    }
    
    .filter-group label {
        font-size: 13px;
    }
    
    .filter-select {
        min-width: 100%;
        font-size: 15px;
        padding: 10px 14px;
    }
    
    .search-input {
        font-size: 15px;
        padding: 12px 40px 12px 16px;
    }
    
    .btn-icon {
        width: 46px;
        height: 46px;
        font-size: 20px;
    }
    
    .btn-tooltip {
        display: none; /* Скрыть подсказку на мобильных */
    }
}

@media (max-width: 480px) {
    .filter-group {
        min-width: 100%;
    }
    
    .search-wrapper {
        order: 3;
    }
    
    .filters-right {
        width: 100%;
        justify-content: space-between;
    }
    
    .btn-icon {
        width: 48px;
        height: 48px;
    }
}

/* Calendar */
#calendar {
    background: white;
    border-radius: var(--border-radius-md);
    padding: 10px;
    box-shadow: var(--shadow-sm);
    min-height: 600px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    overflow: auto;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: white;
    margin: 30px auto;
    padding: 30px;
    border-radius: var(--border-radius-lg);
    width: 95%;
    max-width: 650px;
    box-shadow: var(--shadow-xl);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.close {
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 28px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
    transition: var(--transition);
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.close:hover {
    color: var(--danger-color);
    background: rgba(245, 101, 101, 0.1);
}

.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.form-row .form-group {
    margin-bottom: 0;
}

.form-row .half {
    flex: 1;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 25px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.form-actions .btn {
    min-width: 100px;
}

.close-modal {
    background: #e2e8f0;
    color: var(--dark-color);
}

.close-modal:hover {
    background: #cbd5e0;
}

/* Loading */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(102, 126, 234, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ======================
   АДАПТИВНОСТЬ
   ====================== */

@media (max-width: 1200px) {
    .app-container {
        padding: 15px;
    }
    
    .header {
        padding: 14px 20px;
    }
    
    .header-left h1 {
        font-size: 24px;
    }
}

@media (max-width: 992px) {
    .filters-panel {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-group {
        min-width: 100%;
    }
    
    .search-group {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-group .btn {
        width: 100%;
        margin-left: 0;
        margin-top: 10px;
    }
    
    .refresh-group {
        align-self: flex-end;
    }
    
    .modal-content {
        margin: 20px auto;
        padding: 25px;
    }
}

@media (max-width: 768px) {
    .auth-card {
        padding: 30px 20px;
        margin: 10px;
    }
    
    .auth-logo {
        font-size: 50px;
    }
    
    .auth-header h1 {
        font-size: 24px;
    }
    
    .header {
        flex-direction: column;
        text-align: center;
        gap: 15px;
        padding: 16px;
    }
    
    .header-right {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .user-info {
        font-size: 14px;
    }
    
    .filters-panel {
        padding: 12px;
    }
    
    .filter-group label {
        font-size: 12px;
    }
    
    .form-control {
        padding: 10px 14px;
        font-size: 14px;
    }
    
    .btn {
        padding: 10px 18px;
        font-size: 15px;
    }
    
    .btn-sm {
        padding: 6px 12px;
        font-size: 13px;
    }
    
    .modal-content {
        width: 95%;
        padding: 20px;
        margin: 15px auto;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .auth-container {
        max-width: 100%;
        padding: 10px;
    }
    
    .auth-card {
        padding: 25px 15px;
        border-radius: var(--border-radius-lg);
    }
    
    .auth-logo {
        font-size: 42px;
    }
    
    .auth-header h1 {
        font-size: 22px;
    }
    
    .auth-subtitle {
        font-size: 13px;
    }
    
    .form-options {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .forgot-link {
        margin-left: auto;
    }
    
    .btn-block {
        font-size: 16px;
        padding: 14px;
    }
    
    .header-left h1 {
        font-size: 20px;
    }
    
    .user-info {
        font-size: 13px;
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .user-info small {
        display: block;
    }
    
    .modal-content {
        padding: 18px;
    }
    
    .close {
        right: 12px;
        top: 10px;
        font-size: 24px;
    }
}

/* Прокрутка формы регистрации на мобильных */
@media (max-height: 700px) {
    .auth-container {
        max-height: 85vh;
    }
    
    .auth-card {
        padding: 30px 20px;
    }
}

@media (max-height: 600px) {
    .auth-container {
        max-height: 80vh;
    }
    
    .auth-card {
        padding: 25px 15px;
    }
    
    .auth-logo {
        font-size: 42px;
    }
    
    .auth-header h1 {
        font-size: 22px;
    }
}

@media (max-height: 500px) {
    .auth-container {
        max-height: 75vh;
    }
    
    .auth-card {
        padding: 20px 10px;
        border-radius: var(--border-radius-lg);
    }
    
    .form-group {
        margin-bottom: 15px;
    }
    
    .btn {
        padding: 10px 16px;
        font-size: 15px;
    }
}

/* ======================
   ПЕЧАТЬ
   ====================== */

@media print {
    .header,
    .filters-panel,
    .btn,
    .close,
    .form-actions {
        display: none !important;
    }
    
    #calendar {
        padding: 0;
        box-shadow: none;
        border-radius: 0;
    }
    
    body {
        background: white;
        padding: 0;
    }
    
    .app-container {
        padding: 0;
        max-width: 100%;
    }
}