/* ProfitCore — стили главной (dashboard) по макету */

@import url('https://fonts.googleapis.com/css2?family=Crimson+Pro:wght@400;600;700&display=swap');

html, body {
    height: 100%;
}

/* Обёртка страницы: десктоп — 100% экрана; планшет/мобильный — прокрутка */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
    background-color: #f5f5f5;
}

@media (max-width: 992px) {
    .dashboard-layout {
        height: auto;
        max-height: none;
        min-height: 100vh;
        flex-direction: column;
    }
}

/* Левая колонка — синий сайдбар (на мобильном — верхняя полоса) */
.dashboard-sidebar {
    width: 90px;
    min-width: 90px;
    background-color: #1976d2;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 24px;
    padding-bottom: 20px;
    flex-shrink: 0;
}

@media (max-width: 992px) {
    .dashboard-sidebar {
        width: 100%;
        min-width: 100%;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 10px 16px;
        position: relative;
        z-index: 1002;
    }
    .dashboard-menu-toggle {
        display: flex !important;
        visibility: visible !important;
        order: 1;
        min-width: 44px;
        min-height: 44px;
    }
    .dashboard-menu-toggle-icon {
        display: block !important;
    }
    .dashboard-nav {
        display: none !important;
    }
    .dashboard-sidebar-logo {
        margin-top: 0;
        padding-top: 0;
        order: 2;
        display: flex;
        align-items: center;
    }
    .dashboard-sidebar-logo picture,
    .dashboard-sidebar-logo img {
        display: block;
        vertical-align: middle;
    }
    .dashboard-header-actions {
        display: none !important;
    }
    .dashboard-menu-overlay {
        display: block;
    }
    .dashboard-menu-drawer {
        display: flex;
    }
}
.dashboard-layout.menu-open .dashboard-menu-overlay {
    opacity: 1;
    pointer-events: auto;
}
.dashboard-layout.menu-open .dashboard-menu-drawer {
    transform: translateX(0);
}
.dashboard-layout.menu-open {
    overflow: hidden;
}

@media (max-width: 768px) {
    .dashboard-sidebar {
        padding: 8px 12px;
    }
    .dashboard-sidebar-logo img {
        height: 36px;
        max-width: 120px;
    }
    .dashboard-menu-drawer-logo {
        height: 38px;
        max-width: 140px;
    }
}

.dashboard-nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.dashboard-nav-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background-color: #fff;
    text-decoration: none;
    transition: background-color 0.2s, transform 0.2s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.dashboard-nav-item:hover {
    background-color: #e0e0e0;
    transform: scale(1.08);
}


.dashboard-nav-item.active {
    background-color: #2d6194;
}

.dashboard-nav-item img {
    width: 24px;
    height: 24px;
    display: block;
    object-fit: contain;
}

.dashboard-sidebar-logo {
    margin-top: auto;
    padding-top: 24px;
    text-align: center;
}

.dashboard-sidebar-logo img {
    width: 77px;
    height: 113px;
    display: block;
    object-fit: contain;
    border-radius: 10px;
}

.app-version {
    position: fixed;
    bottom: 8px;
    right: 12px;
    font-size: 11px;
    color: #888;
    z-index: 100;
    pointer-events: none;
}

/* Кнопка гамбургера — только на мобильном */
.dashboard-menu-toggle {
    display: none;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background-color: #fff;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
.dashboard-menu-toggle-icon {
    display: none;
    font-size: 24px;
    line-height: 1;
    color: #333;
    font-weight: bold;
}

/* Оверлей и боковое меню (мобильное) — поверх шапки */
.dashboard-menu-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1100;
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
}
.dashboard-menu-drawer {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    background: #1976d2;
    z-index: 1101;
    flex-direction: column;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    overflow-y: auto;
}
.dashboard-menu-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}
.dashboard-menu-drawer-logo {
    width: 60px;
    height: 88px;
    object-fit: contain;
    border-radius: 12px;
}

@media (max-width: 992px) {
    .dashboard-sidebar-logo img {
        height: 40px;
        width: auto;
        max-width: 140px;
        object-fit: contain;
    }
    .dashboard-menu-drawer-logo {
        height: 44px;
        width: auto;
        max-width: 160px;
        object-fit: contain;
    }
}
.dashboard-menu-close {
    width: 44px;
    height: 44px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.dashboard-menu-drawer-nav {
    display: flex;
    flex-direction: column;
    padding: 16px 0;
}
.dashboard-menu-drawer-actions {
    display: flex;
    flex-direction: column;
    padding: 16px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    margin-top: auto;
}
.dashboard-menu-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    color: #fff;
    text-decoration: none;
    font-family: Arial, sans-serif;
    font-size: 16px;
    background: none;
    border: none;
    cursor: pointer;
    width: 100%;
    text-align: left;
    transition: background 0.2s;
}
.dashboard-menu-item:hover {
    background: rgba(255, 255, 255, 0.15);
}
.dashboard-menu-item.active {
    background: rgba(255, 255, 255, 0.25);
}
.dashboard-menu-item img {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    object-fit: contain;
    filter: brightness(0) invert(1);
}
.dashboard-menu-item-btn.btn-primary img {
    filter: brightness(0) invert(1);
}
.dashboard-menu-item-btn.btn-primary {
    background: rgba(255, 255, 255, 0.3);
    font-weight: 600;
}

/* Правая часть: шапка + контент */
.dashboard-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

@media (max-width: 992px) {
    .dashboard-main {
        flex: 1;
        min-height: 0;
        overflow: auto;
    }
}

/* Верхняя шапка — без поиска, кнопки выровнены по правому краю дашбордов */
.dashboard-header {
    background-color: #ffffffc7;
    padding: 18px 24px;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

@media (max-width: 992px) {
    .dashboard-header {
        padding: 10px 16px;
        display: none;
    }
    .dashboard-header-inner {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .dashboard-header {
        padding: 8px 12px;
    }
    .dashboard-header-btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
    }
    .dashboard-header-btn img {
        width: 22px;
        height: 22px;
    }
}

.dashboard-header-inner {
    max-width: 1500px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.dashboard-header-title {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
    color: #2c3e50;
    letter-spacing: -0.02em;
}

.dashboard-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dashboard-header-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background-color: #e0e0e0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    transition: background-color 0.2s, box-shadow 0.2s;
}

.dashboard-header-btn:hover {
    background-color: #bdbdbd;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
}

.dashboard-header-btn img {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.dashboard-header-btn.btn-primary img {
    filter: brightness(0) saturate(100%) invert(42%) sepia(93%) saturate(1000%) hue-rotate(190deg);
}

/* Скролл-контейнер: один актуальный блок для десктопа; padding-bottom даёт воздух в конце прокрутки */
.dashboard-content-wrap {
    box-sizing: border-box;
    flex: 1;
    min-height: 0;
    padding: 60px 24px 56px 24px;
    padding-bottom: 56px;
    display: flex;
    justify-content: center;
    align-items: stretch;
    overflow: auto;
}

@media (max-width: 992px) {
    .dashboard-content-wrap {
        padding: 24px 16px 56px 16px;
        overflow: auto;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 768px) {
    .dashboard-content-wrap {
        padding: 16px 12px 56px 12px;
    }
}

@media (max-width: 480px) {
    .dashboard-content-wrap {
        padding: 12px 10px 56px 10px;
    }
}

.dashboard-content-inner {
    width: 100%;
    max-width: 1500px;
    font-family: Arial, sans-serif;
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
    padding-bottom: 32px;
}

/* Контент на всех страницах — та же ширина, что и на главной (1500px), центрирован */
.dashboard-layout .container,
.dashboard-content-inner .container {
    max-width: 1500px;
    width: 100%;
    margin: 0 auto;
}

/* Внутри дашборда .container не задаёт фон и min-height (из common.css), чтобы фон страницы не обрывался */
.dashboard-layout .dashboard-content-inner > .container,
.dashboard-layout .dashboard-content-inner .container {
    background: transparent;
    min-height: 0;
}

/* Нижний отступ после последней карточки (воздух 48–64px до низа); только когда карточки внутри .container (Личный кабинет, др.) */
.dashboard-layout .dashboard-content-inner .container .dashboard-card:last-of-type {
    margin-bottom: 56px;
}

/* Сетка из 6 карточек — компактно */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
    margin-bottom: 24px;
    flex-shrink: 0;
}

.dashboard-card {
    border-radius: 8px;
    padding: 10px 8px;
    min-height: 150px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    background: linear-gradient(135deg, #B4D4DF 0%, #108FBA 100%);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.dashboard-card-value {
    font-family: 'Crimson Pro', serif;
    font-size: 70px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.95);
    line-height: 1;
    margin-bottom: 2px;
}

.dashboard-card-title {
    font-family: Arial, sans-serif;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    margin-bottom: 2px;
}

.dashboard-card-sub {
    font-family: Arial, sans-serif;
    font-size: 18px;
    color: #fff;
    opacity: 0.95;
}

/* Блок «Сделки по статусам» — занимает оставшуюся высоту, ~15% выше */
.dashboard-charts {
    flex: 1.27;
    min-height: 0;
    display: flex;
}

.dashboard-pie-block {
    flex: 1;
    min-height: 42vh;
    max-width: 1500px;
    width: 100%;
    background: linear-gradient(90deg, #1993BC 0%, #B4D4DF 100%);
    border-radius: 10px;
    padding: 18px 22px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.dashboard-pie-block h3 {
    position: absolute;
    top: 12px;
    left: 20px;
    font-family: Arial, sans-serif;
    font-size: 24px;
    font-weight: 700;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin: 0;
}

.dashboard-pie-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 0;
    padding-top: 8px;
    width: 100%;
    overflow: visible;
}

.dashboard-pie {
    width: min(352px, 44vh);
    height: min(352px, 44vh);
    flex-shrink: 0;
    max-width: 100%;
    max-height: 100%;
    margin: 0 auto;
    overflow: visible;
}

.dashboard-pie .pie-svg {
    width: 100%;
    height: 100%;
    display: block;
    overflow: visible;
}

.dashboard-pie .pie-segment {
    cursor: pointer;
    transition: transform 0.25s ease;
    transform-origin: 50% 50%;
}

.dashboard-pie .pie-segment:hover {
    transform: scale(1.04);
}

.dashboard-pie-legend {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: center;
    gap: 16px 20px;
    margin-top: 10px;
    font-family: Arial, sans-serif;
    font-size: 13px;
    color: #fff;
}

.dashboard-pie-legend .pie-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.dashboard-pie-legend .pie-legend-item i {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
}

/* Состояние загрузки и ошибки */
.dashboard-content-inner .loading,
.dashboard-content-inner .error {
    font-family: Arial, sans-serif;
}

/* Планшеты */
@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .dashboard-card-value { font-size: 58px; }
    .dashboard-card { min-height: 135px; }
}

@media (max-width: 992px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        margin-bottom: 20px;
    }
    .dashboard-card {
        min-height: 120px;
        padding: 12px 10px;
    }
    .dashboard-card-value {
        font-size: 52px;
    }
    .dashboard-card-title,
    .dashboard-card-sub {
        font-size: 11px;
    }
    .dashboard-pie-block {
        min-height: 352px;
        padding: 16px 18px;
    }
    .dashboard-pie-block h3 {
        font-size: 20px;
        top: 10px;
        left: 16px;
    }
    .dashboard-pie {
        width: min(308px, 55vw);
        height: min(308px, 55vw);
    }
    .dashboard-pie-legend {
        font-size: 12px;
        gap: 12px 16px;
        flex-wrap: wrap;
    }
}

/* Планшеты портрет и крупные телефоны */
@media (max-width: 768px) {
    .dashboard-nav-item {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
    }

    .dashboard-nav-item img {
        width: 22px;
        height: 22px;
    }

    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        margin-bottom: 20px;
    }

    .dashboard-card {
        padding: 10px 8px;
        min-height: 115px;
    }

    .dashboard-card-value {
        font-size: 44px;
    }

    .dashboard-card-title,
    .dashboard-card-sub {
        font-size: 10px;
    }

    .dashboard-pie-block {
        min-height: 308px;
        padding: 14px 16px;
    }

    .dashboard-pie-block h3 {
        font-size: 16px;
        top: 10px;
        left: 14px;
    }

    .dashboard-pie {
        width: min(220px, 50vw);
        height: min(220px, 50vw);
    }

    .dashboard-pie-legend {
        font-size: 11px;
        gap: 10px 12px;
        flex-wrap: wrap;
    }

    .dashboard-pie-legend .pie-legend-item i {
        width: 12px;
        height: 12px;
    }
}

/* Телефоны */
@media (max-width: 480px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 10px;
        margin-bottom: 16px;
    }
    .dashboard-card {
        min-height: 100px;
        padding: 12px 10px;
    }
    .dashboard-card-value {
        font-size: 40px;
    }
    .dashboard-card-title,
    .dashboard-card-sub {
        font-size: 11px;
    }
    .dashboard-pie-block {
        min-height: 286px;
        padding: 11px 14px;
    }
    .dashboard-pie-block h3 {
        font-size: 14px;
        top: 8px;
        left: 12px;
    }
    .dashboard-pie {
        width: min(198px, 82vw);
        height: min(198px, 82vw);
    }
    .dashboard-pie-legend {
        font-size: 10px;
        gap: 8px 10px;
    }
    .dashboard-pie-legend .pie-legend-item i {
        width: 10px;
        height: 10px;
    }
}

/* Узкие экраны */
@media (max-width: 360px) {
    .dashboard-sidebar {
        padding: 6px 8px;
    }
    .dashboard-nav-item {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
    }
    .dashboard-sidebar-logo img {
        height: 32px;
        max-width: 100px;
    }
    .dashboard-content-wrap {
        padding: 10px 8px 56px 8px;
    }
    .dashboard-card-value {
        font-size: 36px;
    }
    .dashboard-pie-block h3 {
        font-size: 12px;
    }
}
