/*
 * Custom CSS для Tax Reporting System
 */

/* ===== ОБЩИЕ СТИЛИ ===== */
:root {
    --primary-color: #5b21b6;
    --primary-dark: #4c1d95;
    --secondary-color: #7c3aed;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f5f7fa;
}

/* Скруглённые поля ввода и выбора (форма, компании, отчёты) */
.form-control,
.form-select {
    border-radius: 12px;
}
.form-control:focus,
.form-select:focus {
    border-radius: 12px;
}

/* Мягкие скруглённые полосы прокрутки (как у Apple), не съедают место контента */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.25) transparent;
}
*::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
*::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 8px;
}
*::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.22);
    border-radius: 8px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.35);
    border-radius: 8px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:active {
    background: rgba(0, 0, 0, 0.4);
}
*::-webkit-scrollbar-corner {
    background: transparent;
    border-radius: 8px;
}

/* ===== ЛЕВЫЙ ЛЕЙАУТ И НАВИГАЦИЯ ===== */
.app-layout {
    min-height: 100vh;
    padding-top: 0.75rem;
    align-items: stretch;
}
.main-content {
    flex-grow: 0;
    min-height: calc(100vh - 0.75rem);
}

.app-layout.no-sidebar .main-content {
    flex: 1;
    max-width: 100%;
}

/* Левое меню — скругление как у баннера (24px), верх и низ в уровень с контентом справа */
.sidebar {
    width: 260px;
    min-width: 260px;
    max-width: 260px;
    flex-shrink: 0;
    background: linear-gradient(180deg, #5b21b6 0%, #7c3aed 100%);
    color: #fff;
    padding: 1.5rem 1rem;
    margin: 1.5rem 0 0.75rem 0.75rem;
    border-radius: 24px;
}

.sidebar-header {
    width: 100%;
    min-width: 0;
}
.sidebar .navbar-brand.sidebar-brand-link,
.sidebar .sidebar-brand-link {
    display: block;
    width: 100%;
    max-width: 100%;
    font-weight: 700;
    color: #fff;
    line-height: 1.25;
}
.sidebar-brand-text {
    display: block;
    font-size: 1.4rem;
    line-height: 1.35;
    word-wrap: break-word;
    overflow-wrap: break-word;
    -webkit-text-fill-color: #fff;
    max-width: 100%;
    margin-bottom: 0.25rem;
}
.sidebar-brand-subtitle {
    display: block;
    font-size: 1.1rem;
    opacity: 0.9;
    line-height: 1.3;
    margin-bottom: 0;
}
.sidebar-header .sidebar-brand-link {
    text-align: center;
}
.sidebar-user-cabinet {
    font-size: 0.8rem;
    margin-top: 1.25rem;
    padding: 0.5rem 0.6rem;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border-radius: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.35);
}
.sidebar-user-cabinet .text-break {
    word-break: break-all;
}

.sidebar-link {
    color: rgba(255,255,255,0.8);
    padding: 0.6rem 0.8rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.sidebar-link:hover {
    background: rgba(0,0,0,0.1);
    color: #fff;
    text-decoration: none;
}

.sidebar-link.active {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

.sidebar-footer {
    font-size: 0.875rem;
}

.main-content {
    max-width: 1200px;
    margin: 0 auto;
}

/* ===== ФОРМАТ СТРАНИЦ КАК «КОМПАНИИ» (главная, тарифы, настройки) ===== */
.page-landing-style {
    --lp: #5b21b6;
    --lp-light: #7c3aed;
    --lt: #0d9488;
    --ls: #1e293b;
    --ls-muted: #475569;
}
.page-landing-style .page-hero {
    background: linear-gradient(180deg, #ccfbf1 0%, #f0fdfa 100%);
    color: #0f766e;
    padding: 2rem 1.5rem 3rem;
    margin: 0 0 1.5rem 0;
    border-radius: 24px;
    position: relative;
    overflow: hidden;
    border: 2px solid #0d9488;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.2);
}
.page-landing-style .page-hero::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 60%;
    height: 200%;
    background: radial-gradient(ellipse, rgba(13, 148, 136, 0.08) 0%, transparent 70%);
    pointer-events: none;
}
.page-landing-style .page-hero-inner { position: relative; z-index: 1; }
.page-landing-style .page-hero-title {
    font-size: clamp(1.85rem, 4vw, 2.5rem);
    font-weight: 800;
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}
.page-landing-style .page-hero-lead {
    font-size: 1.1rem;
    opacity: 0.98;
    margin: 0;
    line-height: 1.5;
}
.page-landing-style .page-content { padding-bottom: 1rem; }
.page-landing-style .page-section { margin-bottom: 1.5rem; }
.page-landing-style .page-section-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--lp);
    margin-bottom: 0.75rem;
}
@media (max-width: 768px) {
    .page-landing-style .page-hero {
        margin: 0 0 1rem 0;
        border-radius: 20px;
        padding: 1.5rem 1rem 2rem;
    }
}

/* ===== КАРТОЧКИ — мягкие скругления ===== */
.card {
    border: none;
    border-radius: 14px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.card-header {
    background-color: #fff;
    border-bottom: 2px solid var(--light-color);
    font-weight: 600;
}

/* ===== СТАТИСТИЧЕСКИЕ КАРТОЧКИ ===== */
.stat-card {
    border-left: 4px solid var(--primary-color);
    transition: all 0.3s ease;
}

.stat-card:hover {
    border-left-width: 6px;
}

.stat-card.success {
    border-left-color: var(--success-color);
}

.stat-card.warning {
    border-left-color: var(--warning-color);
}

.stat-card.danger {
    border-left-color: var(--danger-color);
}

.stat-icon {
    font-size: 2.5rem;
    opacity: 0.3;
}

/* ===== КНОПКИ — мягкие скругления ===== */
.btn {
    border-radius: 12px;
    font-weight: 500;
    padding: 0.5rem 1.5rem;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border: none;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--secondary-color) 100%);
    box-shadow: 0 4px 12px rgba(91, 33, 182, 0.4);
}

/* Кнопка «Скачать отчёт»: фирменный бирюзовый, при наведении — ярче */
.btn-download-report {
    background: linear-gradient(180deg, #ccfbf1 0%, #f0fdfa 100%) !important;
    border: 2px solid #0d9488 !important;
    color: #0f766e !important;
}
.btn-download-report:hover {
    background: linear-gradient(180deg, #99f6e4 0%, #ccfbf1 100%) !important;
    border-color: #0d9488 !important;
    color: #0f766e !important;
    box-shadow: 0 4px 14px rgba(13, 148, 136, 0.25);
}

/* ===== ФОРМЫ — мягкий дизайн (скругления, как у Apple) ===== */
.form-control,
.form-select {
    border-radius: 12px !important;
    border: 1px solid rgba(0, 0, 0, 0.1);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
select {
    border-radius: 12px !important;
}
.form-control:hover,
.form-select:hover {
    border-color: rgba(0, 0, 0, 0.18);
}
.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.18);
    outline: none;
}

.form-label {
    font-weight: 600;
    color: var(--dark-color);
    margin-bottom: 0.5rem;
}

/* ===== Кастомный выпадающий список (скруглённая панель + стилизованный скролл) ===== */
.custom-select-wrap {
    position: relative;
    display: block;
    min-width: 7rem;
    width: 100%;
}
/* В строках периода не даём обёртке раздувать flex — колонка уже задана по ширине */
.reports-period-in-section .custom-select-wrap,
.added-period-row .custom-select-wrap {
    min-width: 0;
    max-width: 100%;
}

/* Раскладка блоков периода: 1-я строка — поля; 2-я строка — «Добавить период» и «Оплатить» (дублируем с шаблоном, чтобы работало при кэше) */
.reports-period-in-section .reports-form-row:has(.col-buttons.first-row-buttons-below) {
    flex-wrap: wrap !important;
}
.reports-period-in-section .reports-form-row .col-buttons.first-row-buttons-below {
    flex-basis: 100% !important;
    width: 100% !important;
    max-width: 100% !important;
}
.added-period-row .col-buttons.added-row-col-buttons {
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    align-items: flex-end;
    gap: 0.5rem;
}
.added-period-row .col-buttons .added-row-buttons-line1 { flex-shrink: 0; }
.added-period-row .col-buttons .period-actions-row.added-row-buttons-line2 { width: 100%; flex-shrink: 0; }

.custom-select-wrap select.form-select {
    cursor: pointer;
}
.custom-select-trigger {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-width: 0;
    padding: 0.375rem 2.25rem 0.375rem 0.75rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: #212529;
    background-color: #fff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    min-height: 38px;
    box-sizing: border-box;
}
.custom-select-trigger::after {
    content: '';
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid currentColor;
    opacity: 0.6;
}
.custom-select-trigger:hover {
    border-color: rgba(0, 0, 0, 0.18);
}
.custom-select-trigger.focused,
.custom-select-wrap.open .custom-select-trigger {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.18);
    outline: none;
}
.custom-select-dropdown {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    min-width: 100%;
    width: max-content;
    max-width: 320px;
    top: 100%;
    margin-top: 4px;
    max-height: 260px;
    overflow-y: auto;
    overflow-x: hidden;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 1050;
    padding: 6px;
}
.custom-select-wrap.open .custom-select-dropdown {
    display: block;
}
.custom-select-option {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.15s ease;
    white-space: nowrap;
}
.custom-select-option:hover {
    background: rgba(102, 126, 234, 0.08);
}
.custom-select-option.selected {
    background: rgba(102, 126, 234, 0.12);
    color: var(--primary-color);
    font-weight: 500;
}
.custom-select-option.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.custom-select-wrap-sm .custom-select-trigger {
    min-height: 32px;
    padding: 0.25rem 2rem 0.25rem 0.5rem;
    font-size: 0.875rem;
}

/* Поле ФИО директора: при пустом поле — светлый фон подсказки */
.director-fio-input:placeholder-shown {
    background-color: #f0f4f8;
}
.director-fio-input::placeholder {
    color: #6c757d;
}

/* ===== ТАБЛИЦЫ ===== */
.table {
    background-color: #fff;
}

.table thead th {
    border-bottom: 2px solid var(--primary-color);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

.table-hover tbody tr:hover {
    background-color: rgba(102, 126, 234, 0.05);
    cursor: pointer;
}

/* ===== БЕЙДЖИ ===== */
.badge {
    padding: 0.5em 0.8em;
    font-weight: 500;
    border-radius: 6px;
}

/* ===== АЛЕРТЫ ===== */
.alert {
    border: none;
    border-radius: 8px;
    border-left: 4px solid;
}

.alert-success {
    background-color: #d4edda;
    border-left-color: var(--success-color);
    color: #155724;
}

.alert-danger {
    background-color: #f8d7da;
    border-left-color: var(--danger-color);
    color: #721c24;
}

.alert-warning {
    background-color: #fff3cd;
    border-left-color: var(--warning-color);
    color: #856404;
}

.alert-info {
    background-color: #d1ecf1;
    border-left-color: var(--info-color);
    color: #0c5460;
}

/* ===== ПАГИНАЦИЯ ===== */
.pagination {
    margin-top: 2rem;
}

.page-link {
    color: var(--primary-color);
    border-radius: 6px;
    margin: 0 2px;
    border: 1px solid #dee2e6;
}

.page-link:hover {
    background-color: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

.page-item.active .page-link {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* ===== BREADCRUMB ===== */
.breadcrumb {
    background-color: transparent;
    padding: 0;
    margin-bottom: 1rem;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: "›";
    font-size: 1.2rem;
}

/* ===== МОДАЛЬНЫЕ ОКНА ===== */
.modal-content {
    border: none;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.modal-header {
    border-bottom: 2px solid var(--light-color);
    border-radius: 10px 10px 0 0;
}

.modal-footer {
    border-top: 2px solid var(--light-color);
}

/* ===== СПИННЕРЫ ===== */
.spinner-border {
    width: 3rem;
    height: 3rem;
    border-width: 0.3rem;
}

/* ===== ПРОГРЕСС БАРЫ ===== */
.progress {
    height: 25px;
    border-radius: 10px;
    background-color: #e9ecef;
}

.progress-bar {
    border-radius: 10px;
    font-weight: 600;
}

/* ===== СПИСОК ГРУПП ===== */
.list-group-item {
    border: none;
    border-left: 3px solid transparent;
    transition: all 0.3s ease;
}

.list-group-item:hover {
    border-left-color: var(--primary-color);
    background-color: rgba(102, 126, 234, 0.05);
}

.list-group-item-action:active {
    background-color: rgba(102, 126, 234, 0.1);
}

/* ===== ГЛАВНАЯ СТРАНИЦА ===== */
.hero-section {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 4rem 0;
    border-radius: 15px;
    margin-bottom: 3rem;
}

.feature-icon {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

/* ===== СТРАНИЦЫ ОШИБОК ===== */
.error-page {
    padding: 3rem 0;
}

.error-page h1 {
    font-size: 8rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

/* ===== АНИМАЦИИ ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes slideIn {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

.slide-in {
    animation: slideIn 0.5s ease-in-out;
}

/* ===== УТИЛИТЫ ===== */
.text-gradient {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.shadow-sm-hover:hover {
    box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,0.075) !important;
}

.cursor-pointer {
    cursor: pointer;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }
    .main-content {
        max-width: 100%;
    }
    .hero-section {
        padding: 2rem 0;
    }
    
    .error-page h1 {
        font-size: 5rem;
    }
    
    .stat-card {
        margin-bottom: 1rem;
    }
}

/* ===== DARK MODE (опционально) ===== */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #1a1a1a;
        color: #e0e0e0;
    }
    
    .card {
        background-color: #2d2d2d;
        color: #e0e0e0;
    }
    
    .table {
        background-color: #2d2d2d;
        color: #e0e0e0;
    }
    
    .form-control,
    .form-select {
        background-color: #2d2d2d;
        color: #e0e0e0;
        border-color: #444;
    }
}

/* ===== ФОРМА ДИРЕКТОРА: ПОЛЯ ОДИНАКОВОГО РАЗМЕРА ===== */
.director-id-field,
.passport-field {
    max-width: 100%;
    box-sizing: border-box;
}
.row .col-md-4 .director-id-field,
.row .col-md-3 .passport-field {
    width: 100%;
}

/* ===== ПЕЧАТЬ ===== */
@media print {
    .navbar,
    .btn,
    .breadcrumb,
    .sidebar {
        display: none !important;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}