/* Стли v9.4.0 */

:root {
    --dashd-blue: #1e87f0;
    --dashd-border: #cbd5e1;
    --dashd-bg-light: #f8fafc;
    --dashd-text: #334155;
}

/* Общие кнопки */
.dashd-ui-btn { 
    border-radius: 50vh; padding: 5px 15px; border: 1px solid #e2e2e2; 
    font-size: 12px; background: #fff; cursor: pointer; transition: 0.3s; 
    color: var(--dashd-text); display: inline-flex; align-items: center; 
}
.dashd-ui-btn.active-btn { 
    background: var(--dashd-blue) !important; 
    color: #fff !important; 
    border-color: var(--dashd-blue) !important;
    font-weight: 700;
}

/* Таблицы v7.0.0 */
.dashd-table-container { 
    border: 1px solid var(--dashd-border); border-radius: 12px; 
    overflow: hidden; background: #fff; box-shadow: 0 4px 12px rgba(0,0,0,0.05); margin-top: 20px; 
}
.dashd-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.dashd-table th { background: #f1f5f9; font-weight: 700; padding: 12px; border-bottom: 2px solid var(--dashd-border); text-transform: uppercase; text-align: center; }
.dashd-table td { padding: 10px 15px; text-align: center; border-bottom: 1px solid #e2e8f0; border-right: 1px solid #e2e8f0; }
.dashd-table td:first-child { text-align: left; }
.dashd-table td:last-child { text-align: right; padding-right: 2%; }
.dashd-table tr:nth-child(even) { background: var(--dashd-bg-light); }
.dashd-table tr:hover td { background: #e0f2fe !important; color: #0369a1; }
.dashd-total-col { font-weight: 800; background: #f1f5f9 !important; border-left: 2px solid #94a3b8 !important; color: #1e293b; }

/* Конструктор */
.con-sidebar { background: #fff; padding: 20px; border: 1px solid #ccd0d4; border-radius: 8px; }
.prev-area { min-height: 450px; border: 1px dashed #ccc; background: #fafafa; border-radius: 8px; padding: 15px; position: relative; }

/* Новые переключатели v7.2.0 */
.dashd-view-selector {
    display: flex;
    background: #f2f2f2;
    border-radius: 20px;
    padding: 2px;
    cursor: pointer;
    position: relative;
    border: 1px solid #e2e2e2;
}

.dashd-selector-label {
    padding: 3px 12px;
    font-size: 11px;
    font-weight: 600;
    color: #666;
    z-index: 2;
    transition: 0.3s;
    border-radius: 15px;
}

.dashd-selector-label:hover {
    color: var(--dashd-blue);
    background: rgba(30, 135, 240, 0.1);
}

/* Эмуляция активного состояния без сложной логики слайдера */
.dashd-selector-label.active {
    background: #fff;
    color: var(--dashd-blue);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Компактные кнопки для периодов v7.3.0 */
.dashd-year-btns .dashd-ui-btn, 
.dashd-q-btns .dashd-ui-btn {
    padding: 2px 10px;
    font-size: 10px;
    height: 26px;
    background: #f1f5f9;
}

.dashd-country-btns .dashd-ui-btn {
    margin-bottom: 5px;
}

.dashd-mobile-controls {
    display: none;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.dashd-mobile-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dashd-mobile-field span {
    font-size: 10px;
    font-weight: 600;
    color: #64748b;
    line-height: 1.1;
}

.dashd-mobile-select {
    width: 100%;
    height: 34px;
    border: 1px solid #d8dee8;
    border-radius: 10px;
    background: #fff;
    color: #334155;
    font-size: 12px;
    padding: 0 10px;
    box-sizing: border-box;
}

.dashd-mobile-select:focus {
    outline: none;
    border-color: var(--dashd-blue);
    box-shadow: 0 0 0 2px rgba(30, 135, 240, 0.12);
}

.active-btn {
    background: var(--dashd-blue) !important;
    color: #fff !important;
    border-color: var(--dashd-blue) !important;
}

.badge-v { 
    background: #1e87f0; 
    color: #fff; 
    padding: 4px 8px; 
    border-radius: 50vh; 
    font-size: 11px; 
    vertical-align: middle; 
    margin-left: 10px; 
}

/* ==========================================================================
   DashD Widget: Hamburger Toggle & Responsive Table
   ========================================================================== */

/* Анимированный гамбургер */
.dashd-hamburger { 
    width: 18px; 
    height: 12px; 
    position: relative; 
    display: flex; 
    flex-direction: column; 
    justify-content: space-between; 
}
.dashd-hamburger span { 
    display: block; 
    height: 2px; 
    width: 100%; 
    background: #1e87f0; 
    transition: 0.3s ease-in-out; 
    border-radius: 2px; 
}
.dashd-hamburger.open span:nth-child(1) { transform: translateY(5px) rotate(45deg); }
.dashd-hamburger.open span:nth-child(2) { opacity: 0; }
.dashd-hamburger.open span:nth-child(3) { transform: translateY(-5px) rotate(-45deg); }

/* Адаптивная таблица с горизонтальным скроллом и залипающей колонкой */
.dashd-table-wrapper {
    width: 100%;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    overflow: hidden;
}
.dashd-table-scroll-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.dashd-table {
    width: 100%;
    min-width: max-content;
    border-collapse: collapse;
    margin: 0;
    background: #fff;
}
.dashd-table th, .dashd-table td {
    white-space: nowrap;
    padding: 12px 15px;
    border-bottom: 1px solid #e5e5e5;
    text-align: center;
}
.dashd-table th { 
    background: #f8f9fa; 
    font-weight: 600; 
    color: #333; 
}
.dashd-table th:first-child,
.dashd-table td:first-child {
    position: sticky;
    left: 0;
    text-align: left;
    z-index: 2;
    border-right: 1px solid #e5e5e5;
}
.dashd-table th:first-child { background: #f8f9fa; z-index: 3; }
.dashd-table td:first-child { background: #fff; }

/* Внутренние отступы для всего виджета */
.dashd-widget-container {
    padding: 0px 25px 25px 25px;
    box-sizing: border-box;
    /* Если хотите добавить виджету легкий фон и скругление на сайте, раскомментируйте строки ниже: */
    background: #ffffff; 
    border-radius: 8px; 
    box-shadow: 0 2px 15px rgba(0,0,0,0.03); 
}

@media (max-width: 640px) and (orientation: portrait) {
    .dashd-widget-container {
        padding: 0 12px 16px 12px;
    }

    .dashd-widget-topbar {
        flex-direction: column;
        align-items: stretch !important;
        gap: 10px;
    }

    .dashd-controls-stack {
        width: 100%;
        align-items: stretch !important;
    }

    .dashd-controls-desktop {
        display: none !important;
    }

    .dashd-mobile-controls {
        display: grid;
    }

    .dashd-period-controls {
        width: 100%;
        gap: 8px !important;
    }

    .dashd-period-controls .dashd-period-buttons {
        display: none !important;
    }
}

/* ==========================================================================
   DashD Backend Admin Styles (Modern SaaS Aesthetic)
   ========================================================================== */

/* Заголовки и бейджи */
.dashd-admin-header { display: flex; align-items: center; gap: 15px; margin-bottom: 25px; margin-top: 15px; }
.dashd-admin-header h1 { margin: 0; font-weight: 600; font-size: 24px; color: #1d2327; line-height: 1.2; }
.dashd-badge { background: #e0f0fa; color: #2271b1; padding: 4px 10px; border-radius: 20px; font-size: 13px; font-weight: 600; vertical-align: middle; }

/* Сетка (Grid) для карточек */
.dashd-grid { display: grid; gap: 20px; margin: 20px 0; }
.dashd-grid-4 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.dashd-grid-2 { grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); }

/* Карточки (Cards) */
.dashd-card { background: #fff; border: 1px solid #c3c4c7; border-radius: 8px; padding: 24px; box-shadow: 0 1px 3px rgba(0,0,0,0.04); transition: box-shadow 0.2s, transform 0.2s; }
.dashd-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); transform: translateY(-1px); }
.dashd-card.danger-zone { border-color: #f8acac; background: #fff5f5; }
.dashd-card.danger-zone:hover { box-shadow: 0 4px 12px rgba(214,54,56,0.15); }
.dashd-action-card { display: flex; flex-direction: column; min-height: 170px; }
.dashd-action-card .dashd-action-card-form { margin-top: auto; padding-top: 12px; }

/* Элементы статистики */
.dashd-stat-title { font-size: 13px; color: #646970; text-transform: uppercase; letter-spacing: 0.5px; margin: 0 0 10px 0; font-weight: 600; }
.dashd-stat-value { font-size: 36px; font-weight: 700; color: #1d2327; margin: 0; line-height: 1; }
.dashd-stat-value.highlight { color: #2271b1; }

/* Панели инструментов (Toolbars) */
.dashd-toolbar { background: #f6f7f7; border: 1px solid #c3c4c7; border-radius: 8px; padding: 16px 24px; display: flex; flex-wrap: wrap; gap: 20px; align-items: center; justify-content: space-between; margin: 25px 0; }
.dashd-toolbar-group { display: flex; align-items: center; gap: 15px; flex-wrap: wrap; }
.dashd-toolbar-title { font-weight: 600; font-size: 14px; color: #1d2327; margin: 0; min-width: 140px; }
.dashd-toolbar-divider { width: 1px; height: 30px; background: #dcdde1; }

/* Стилизация инлайнового редактирования */
.dashd-inline-edit { position: relative; transition: opacity 0.2s; }
.dashd-edit-trigger { cursor: pointer; color: #b4b9be; font-size: 16px; transition: color 0.2s; }
.dashd-edit-trigger:hover { color: #2271b1; }
.dashd-val-input { border-radius: 4px; border: 1px solid #8c8f94; box-shadow: none; }
.dashd-val-input:focus { border-color: #2271b1; box-shadow: 0 0 0 1px #2271b1; outline: none; }

/* Обновленная таблица для бекенда */
.dashd-table-container { background: #fff; border: 1px solid #c3c4c7; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.04); margin-top: 15px; }
.dashd-table thead th { background: #f6f7f7; border-bottom: 2px solid #c3c4c7; color: #1d2327; text-transform: uppercase; font-size: 12px; letter-spacing: 0.5px; padding: 12px 15px; }
.dashd-table tbody td { border-bottom: 1px solid #f0f0f1; padding: 12px 15px; vertical-align: middle; color: #3c434a; }
.dashd-table tbody tr:last-child td { border-bottom: none; }
.dashd-table tbody tr:hover { background: #f9f9f9; }

/* ==========================================================================
   v9.0.0 Frontend: Gated Content Modal
   ========================================================================== */
.dashd-modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 99999; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: 0.3s; backdrop-filter: blur(3px); }
.dashd-modal-overlay.active { opacity: 1; pointer-events: auto; }
.dashd-modal-box { background: #fff; padding: 30px; border-radius: 12px; width: 100%; max-width: 400px; box-shadow: 0 10px 25px rgba(0,0,0,0.2); transform: translateY(20px); transition: 0.3s; position: relative; }
.dashd-modal-overlay.active .dashd-modal-box { transform: translateY(0); }
.dashd-modal-close { position: absolute; top: 15px; right: 20px; cursor: pointer; font-size: 24px; color: #999; line-height: 1; transition: 0.2s; }
.dashd-modal-close:hover { color: #333; }

/* ==========================================================================
   v9.4.0 Frontend: WP Dark Mode Plugin Integration
   ========================================================================== */
html.wp-dark-mode-active .dashd-widget-container,
body.wp-dark-mode-active .dashd-widget-container,
.wp-dark-mode-active .dashd-widget-container { 
    background: #1e293b !important; 
    border: 1px solid #334155; 
}
.wp-dark-mode-active .dashd-widget-container h3, 
.wp-dark-mode-active .dashd-widget-container .dashd-selector-label { color: #f8fafc !important; }
.wp-dark-mode-active .dashd-view-selector { background: #0f172a !important; border-color: #334155 !important; }
.wp-dark-mode-active .dashd-selector-label.active { background: #334155 !important; color: #38bdf8 !important; box-shadow: none; }
.wp-dark-mode-active .dashd-table { background: #1e293b !important; }
.wp-dark-mode-active .dashd-table th { background: #0f172a !important; color: #cbd5e1 !important; border-bottom-color: #334155 !important; }
.wp-dark-mode-active .dashd-table td { background: #1e293b !important; color: #cbd5e1 !important; border-color: #334155 !important; }
.wp-dark-mode-active .dashd-table tr:hover td { background: #334155 !important; color: #f8fafc !important; }
.wp-dark-mode-active .dashd-total-col { background: #0f172a !important; border-left-color: #475569 !important; color: #f8fafc !important; }
.wp-dark-mode-active .dashd-chart-box { background: #1e293b !important; border-color: #334155 !important; }

/* Базовый стиль для всех кнопок в темном режиме */
.wp-dark-mode-active .dashd-ui-btn { 
    background: #0f172a !important; 
    border-color: #334155 !important; 
    color: #cbd5e1 !important; 
    transition: all 0.3s ease; /* Добавляем плавность */
}

/* 1. ПРИТУШАЕМ НЕАКТИВНЫЕ КНОПКИ */
.wp-dark-mode-active .dashd-ui-btn:not(.active-btn) {
    opacity: 0.4; /* Делаем кнопку полупрозрачной (приглушенной) */
}

/* Эффект при наведении на неактивную кнопку */
.wp-dark-mode-active .dashd-ui-btn:not(.active-btn):hover {
    opacity: 0.8; /* Делаем чуть ярче при наведении курсора */
    background: #1e293b !important; /* Слегка осветляем фон */
}

/* 2. АКТИВНАЯ КНОПКА (Остается яркой) */
.wp-dark-mode-active .dashd-ui-btn.active-btn { 
    background: var(--dashd-blue) !important; 
    color: #fff !important; 
    border-color: var(--dashd-blue) !important;
    opacity: 1 !important; /* Убеждаемся, что прозрачности нет */
    box-shadow: 0 0 10px rgba(30, 135, 240, 0.3); /* Легкое свечение для выделения */
}

.wp-dark-mode-active .dashd-modal-box { background: #1e293b; color: #f8fafc; }
.wp-dark-mode-active .dashd-modal-box input { background: #0f172a; border: 1px solid #334155; color: #f8fafc; }
.wp-dark-mode-active .dashd-mobile-select { background: #0f172a; border-color: #334155; color: #cbd5e1; }
.wp-dark-mode-active .dashd-mobile-field span { color: #94a3b8; }
.wp-dark-mode-active .dashd-last-sync-time { color: #64748b !important; }
.wp-dark-mode-active .dashd-loader-overlay { background: rgba(30, 41, 59, 0.7) !important; }
