/* ============================================
   functions/css/base.css
   ============================================ */

/* ============================================
   ПЕРЕМЕННЫЕ
   ============================================ */
:root {
    --color-text:         #2c3e50;
    --color-text-muted:   #7f8c8d;
    --color-text-light:   #555;
    --color-primary:      #4a90d9;
    --color-primary-dark: #357abd;
    --color-success:      #27ae60;
    --color-success-dark: #219a52;
    --color-danger:       #e74c3c;
    --color-danger-dark:  #c0392b;
    --color-warning:      #e67e22;
    --color-warning-dark: #d35400;
    --color-neutral:      #bdc3c7;
    --color-neutral-dark: #95a5a6;
    --color-bg:           #f0f2f5;
    --color-bg-light:     #f8f9fa;
    --color-border:       #e0e0e0;
    --color-border-light: #f0f0f0;

    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;

    --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.2);

    --modal-z: 2000;
    --modal-z-high: 2500;
}

/* ============================================
   RESET
   ============================================ */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: Arial, sans-serif;
}
body {
    background: var(--color-bg);
    min-height: 100vh;
    color: var(--color-text);
    font-size: 14px;
    line-height: 1.4;
}
a { color: var(--color-primary); }
a:hover { text-decoration: underline; }

h1 { color: var(--color-text); font-size: 22px; }
h2 { color: var(--color-text); font-size: 18px; }
h3 { color: var(--color-text); font-size: 16px; }

/* ============================================
   КНОПКИ
   ============================================ */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: background 0.2s, opacity 0.2s;
    line-height: 1.4;
}
.btn:hover { text-decoration: none; }
.btn:disabled,
.btn.is-disabled { opacity: 0.5; cursor: not-allowed; }

.btn--primary { background: var(--color-primary); color: #fff; }
.btn--primary:hover { background: var(--color-primary-dark); }

.btn--success { background: var(--color-success); color: #fff; }
.btn--success:hover { background: var(--color-success-dark); }

.btn--danger { background: var(--color-danger); color: #fff; }
.btn--danger:hover { background: var(--color-danger-dark); }

.btn--warning { background: var(--color-warning); color: #fff; }
.btn--warning:hover { background: var(--color-warning-dark); }

.btn--neutral { background: var(--color-neutral); color: var(--color-text); }
.btn--neutral:hover { background: var(--color-neutral-dark); }
.btn--purple { background: #8e44ad; color: #fff; }
.btn--purple:hover { background: #7d3c98; }

.btn--sm { padding: 4px 10px; font-size: 11px; }
.btn--lg { padding: 12px 30px; font-size: 15px; }
.btn--block { display: block; width: 100%; }

/* ============================================
   ФОРМЫ
   ============================================ */
input[type="text"],
input[type="number"],
input[type="password"],
input[type="date"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: var(--color-text);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(74,144,217,0.15);
}
input:disabled, select:disabled, textarea:disabled {
    background: #e9ecef;
    color: #999;
    cursor: not-allowed;
}

.form-group { margin-bottom: 15px; }
.form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
    font-weight: bold;
    color: var(--color-text-light);
}

/* ============================================
   МОДАЛКИ
   ============================================ */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: var(--modal-z);
    justify-content: center;
    align-items: center;
    padding: 20px;
}
.modal.active { display: flex; }

.modal__box {
    background: #fff;
    border-radius: var(--radius-xl);
    padding: 25px;
    max-width: 500px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    max-height: 92vh;
    overflow-y: auto;
    position: relative;
}
.modal__box--sm { max-width: 420px; text-align: center; }
.modal__box--md { max-width: 500px; text-align: center; }
.modal__box--lg { max-width: 800px; }
.modal__box--xl { max-width: 1200px; }

.modal__title { margin-bottom: 12px; color: var(--color-text); font-size: 18px; }
.modal__text  { color: var(--color-text-muted); margin-bottom: 20px; font-size: 14px; }
.modal__close {
    position: absolute; top: 12px; right: 18px;
    font-size: 24px; cursor: pointer; color: #999;
    background: none; border: none; line-height: 1;
}
.modal__close:hover { color: #333; }

.modal__buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 15px;
}
.modal__buttons--right { justify-content: flex-end; }

/* ============================================
   ТАБЛИЦЫ (базовая)
   ============================================ */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
    background: var(--color-primary);
    color: #fff;
    padding: 8px;
    text-align: left;
    font-weight: bold;
}
.table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--color-border);
}

/* ============================================
   УТИЛИТЫ
   ============================================ */
.mt-8  { margin-top: 8px; }
.mt-15 { margin-top: 15px; }
.mb-8  { margin-bottom: 8px; }
.hidden { display: none !important; }

/* ============================================
   ИНФО-ИКОНКА (подсказка)
   ============================================ */
.info-icon {
    display: inline-block;
    width: 15px;
    height: 15px;
    background: #fff;
    color: var(--color-primary);
    border-radius: 50%;
    font-size: 10px;
    line-height: 15px;
    text-align: center;
    cursor: help;
    font-weight: bold;
    margin-left: 4px;
    position: relative;
    vertical-align: middle;
}
.info-icon:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 11px;
    white-space: normal;
    width: 300px;
    max-width: 90vw;
    z-index: 100;
    pointer-events: none;
    font-weight: normal;
    text-align: left;
    line-height: 1.4;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* ============================================
   ШАПКА СТРАНИЦЫ С КНОПКОЙ НАЗАД
   Общая для всех страниц: Org_info, Payment, SalaryFacts,
   Admin, Settings, Curator и т.д.
   ============================================ */
/* ============================================
   ШАПКА СТРАНИЦЫ С КНОПКОЙ НАЗАД (кнопка слева)
   ============================================ */
.settings-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.settings-header h1 {
    margin: 0;
    text-align: left;
    flex: 1 1 auto;
    min-width: 0;
}
.back-btn {
    display: inline-block;
    padding: 8px 16px;
    background: var(--color-primary);
    color: #fff;
    border-radius: var(--radius-md);
    text-decoration: none;
    font-size: 13px;
    font-weight: bold;
    white-space: nowrap;
    transition: background 0.2s;
    flex: 0 0 auto;
}
.back-btn:hover {
    background: var(--color-primary-dark);
    color: #fff;
    text-decoration: none;
}

/* Компактный фильтр-бар (одна строка) */
.filter-bar--compact {
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-end;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    margin-bottom: 15px;
}
.filter-bar--compact .filter-field {
    display: flex;
    flex-direction: column;
    flex: 0 0 auto;
    min-width: 0;
}
.filter-bar--compact .filter-field label {
    font-size: 11px;
    color: var(--color-text-muted);
    margin-bottom: 3px;
    white-space: nowrap;
}
.filter-bar--compact .filter-field select,
.filter-bar--compact .filter-field input {
    font-size: 12px;
    padding: 5px 8px;
    height: 30px;
}
.filter-bar--compact .filter-field select { min-width: 90px; }
.filter-bar--compact .filter-field input[type="text"] { min-width: 140px; }
.filter-bar--compact .btn {
    padding: 5px 14px;
    font-size: 12px;
    height: 30px;
    flex: 0 0 auto;
    white-space: nowrap;
}
.filter-bar--compact .ml-auto { margin-left: auto; }

/* ============================================
   ЛОАДЕР (спиннер по центру экрана)
   ============================================ */
.loader {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.7);
    z-index: 3000;
    justify-content: center;
    align-items: center;
}
.loader.active {
    display: flex;
}

.loader__spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: loader-spin 0.8s linear infinite;
}

@keyframes loader-spin {
    to { transform: rotate(360deg); }
}

/* ============================================ */
/* ОТОБРАЖЕНИЕ ВЕРСИИ                             */
/* ============================================ */
.app-version {
    font-size: 11px;
    color: #95a5a6;
    font-family: 'Consolas', 'Monaco', monospace;
    padding: 2px 6px;
    background: #f4f4f4;
    border-radius: 3px;
    user-select: all;   /* легко копировать мышью */
    cursor: default;
}

/* ============================================ */
/* ПРАВАЯ ЧАСТЬ ШАПКИ (МЕНЮ + ПРОФИЛЬ + ВЫЙТИ) */
/* ============================================ */

.header-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;            /* Задает одинаковый отступ между кнопками */
    flex-wrap: wrap;     /* Позволяет кнопкам переноситься на новую строку при сужении экрана */
}

/* ============================================ */
/* АВАТАР ПОЛЬЗОВАТЕЛЯ (шапка) */
/* ============================================ */

.header-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 0.5px;
    cursor: pointer;
    user-select: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    background-color: #3498db;
    text-transform: uppercase;
}

.header-avatar:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.header-avatar:active {
    transform: scale(0.98);
}

/* Обёртка «кружок + имя» — кликабельная, при наведении подсветка */
.header-user {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 4px;
    border-radius: 24px;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s ease;
    max-width: 240px;
    vertical-align: middle;
}

.header-user:hover {
    background-color: rgba(0, 0, 0, 0.06);
}

.header-user:active {
    background-color: rgba(0, 0, 0, 0.1);
}

.header-user:hover .header-avatar {
    transform: scale(1.05);
}

.header-user-name {
    font-size: 13px;
    color: inherit;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px; /* Уменьшили с 180px, чтобы дать место кнопке "Выйти" */
    line-height: 1.2;
}

/* ============================================ */
/* АВАТАР ПОЛЬЗОВАТЕЛЯ (модалка «Мой профиль») */
/* ============================================ */

.profile-avatar-big {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    color: #fff;
    font-weight: 700;
    font-size: 26px;
    letter-spacing: 1px;
    margin: 0 auto 20px auto;
    background-color: #3498db;
    text-transform: uppercase;
    user-select: none;
}

.profile-readonly {
    margin-top: 16px;
    padding: 12px 14px;
    background: #f5f6f7;
    border-radius: 6px;
    font-size: 13px;
    color: #555;
    line-height: 1.7;
}

.profile-readonly strong {
    color: #333;
    font-weight: 600;
    display: inline-block;
    min-width: 110px;
}

.profile-readonly > div {
    display: flex;
    align-items: baseline;
}

.profile-readonly > div + div {
    margin-top: 4px;
}

/* Мобильная адаптация */
@media (max-width: 720px) {
    .header-user-name {
        display: none;
    }
    .header-user {
        padding: 2px;
        gap: 0;
    }
}

@media (max-width: 480px) {
    .header-avatar {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }
    .profile-avatar-big {
        width: 60px;
        height: 60px;
        font-size: 22px;
    }
    .profile-readonly > div {
        flex-direction: column;
        align-items: flex-start;
    }
    .profile-readonly strong {
        min-width: 0;
    }
}