/* styles.css — FINAL FIX (TEXT-INDENT RESET) */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* --- DARK MODE VARIABLES --- */
    --bg-body: #0f172a;           
    --bg-card: #1e293b;           
    --text-primary: #f1f5f9;      
    --text-secondary: #94a3b8;    
    --accent-color: #6366f1;      
    --accent-hover: #818cf8;
    --border-color: #334155;      
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    --input-bg: #0f172a;
    --icon-bg: rgba(99, 102, 241, 0.15); 
    --table-head-bg: #0f172a;
    --table-hover: #334155;
}

/* --- LIGHT MODE OVERRIDES --- */
[data-bs-theme="light"] {
    --bg-body: #f3f4f6;
    --bg-card: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --accent-color: #4f46e5;
    --accent-hover: #4338ca;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 2px 4px -1px rgba(0, 0, 0, 0.1);
    --input-bg: #f9fafb;
    --icon-bg: #e5e7eb;
    --table-head-bg: #f3f4f6;
    --table-hover: #f9fafb;
}

/* --- GLOBAL SCROLLBAR & BODY --- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-body); }
::-webkit-scrollbar-thumb { background-color: var(--border-color); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background-color: var(--text-secondary); }

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    font-size: 0.85rem; 
    line-height: 1.4;
    padding-bottom: 2rem;
    transition: background-color 0.3s, color 0.3s;
}

/* =========================================
   CRITICAL FIXES
   ========================================= */

/* 1. AUTOFILL FIX */
input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus, input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px var(--input-bg) inset !important;
    -webkit-text-fill-color: var(--text-primary) !important;
    transition: background-color 5000s ease-in-out 0s;
}

/* 2. DATE INPUT FIX */
input[type="date"] { position: relative; }
input[type="date"]::-webkit-calendar-picker-indicator {
    background: transparent; bottom: 0; color: transparent; cursor: pointer;
    height: auto; left: 0; position: absolute; right: 0; top: 0; width: auto; z-index: 10;
}

/* =========================================
   SELECT2 BOOTSTRAP-5 THEME OVERRIDES
   ========================================= */

/* 1. КОНТЕЙНЕР (Сам инпут) */
.select2-container--bootstrap-5 .select2-selection--multiple {
    background-color: var(--input-bg) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
    min-height: 38px !important;
    border-radius: 0.4rem !important;
    padding: 0 4px !important;
    background-image: none !important;
    display: flex !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    overflow: hidden !important;
}

/* Фокус */
.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open .select2-selection {
    border-color: var(--accent-color) !important;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15) !important;
}

/* 2. СПИСОК ВЫБРАННЫХ ЭЛЕМЕНТОВ */
.select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__rendered {
    display: flex !important;
    flex-wrap: nowrap !important; 
    align-items: center !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    overflow-x: auto !important; 
    scrollbar-width: none !important;
}
.select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__rendered::-webkit-scrollbar {
    display: none;
}

/* 3. ЧИПСЫ (СИНИЕ ПЛАШКИ) */
.select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__choice {
    background-color: var(--accent-color) !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 4px !important;
    margin: 3px 4px 3px 0 !important;
    padding: 2px 8px 2px 4px !important;
    font-size: 0.85rem !important;
    display: flex !important;
    align-items: center !important;
    flex-direction: row-reverse !important;
    height: 26px !important;
    line-height: 1.2 !important;
    flex-shrink: 0 !important;
}
.select2-container--bootstrap-5 .select2-selection__choice span,
.select2-container--bootstrap-5 .select2-selection__choice__display {
    color: #ffffff !important;
    margin-left: 5px !important;
    white-space: nowrap !important;
}

/* 4. КРЕСТИК (БЕЛЫЙ) — FIX */
.select2-container--bootstrap-5 .select2-selection__choice .select2-selection__choice__remove {
    /* Сбрасываем трюк Bootstrap с заменой текста картинкой */
    text-indent: 0 !important;       /* ВЕРНУТЬ ТЕКСТ */
    overflow: visible !important;    /* ПОКАЗАТЬ ЕГО */
    width: auto !important;
    height: auto !important;
    
    background: transparent !important;
    background-image: none !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    position: static !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    opacity: 0.8 !important;
}

/* Сам символ '×' внутри кнопки */
.select2-container--bootstrap-5 .select2-selection__choice .select2-selection__choice__remove span {
    color: #ffffff !important;
    font-size: 1.2rem !important;
    line-height: 0.8 !important;
    font-weight: 300 !important;
    margin: 0 !important;
    display: block !important;
}

.select2-container--bootstrap-5 .select2-selection__choice .select2-selection__choice__remove:hover {
    opacity: 1 !important;
}

/* 5. УБИРАЕМ СТРОКУ ПОИСКА (Textarea) */
.select2-container--bootstrap-5 .select2-search--inline,
.select2-container--bootstrap-5 .select2-search__field {
    width: 0 !important;
    height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    min-height: 0 !important;
    position: absolute !important;
    opacity: 0 !important;
    pointer-events: none !important;
    border: none !important;
    overflow: hidden !important;
}

/* 6. ВЫПАДАЮЩИЙ СПИСОК */
.select2-dropdown, 
.select2-container--bootstrap-5 .select2-dropdown {
    background-color: var(--bg-card) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
    z-index: 9999 !important;
}
.select2-container--bootstrap-5 .select2-results__option {
    padding: 6px 10px !important;
    font-size: 0.85rem !important;
}
.select2-container--bootstrap-5 .select2-results__option--highlighted[aria-selected] {
    background-color: var(--accent-color) !important;
    color: #ffffff !important;
}

/* =========================================
   MAIN STYLES
   ========================================= */

/* --- Header --- */
.dashboard-header {
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
    padding: 0.75rem 0;
    margin-bottom: 1.5rem;
    transition: background-color 0.3s;
    border-bottom: 1px solid var(--border-color);
}
.brand-logo {
    font-weight: 700; font-size: 1.1rem; color: var(--accent-color);
    text-decoration: none; display: flex; align-items: center; gap: 0.4rem;
}
.btn-logout {
    color: var(--text-secondary); font-weight: 500; text-decoration: none;
    padding: 0.4rem 0.8rem; border-radius: 0.4rem; transition: all 0.2s;
    background: transparent; border: 1px solid var(--border-color); font-size: 0.85rem;
}
.btn-logout:hover {
    background: rgba(239, 68, 68, 0.1); color: #ef4444; border-color: #ef4444;
}
.btn-theme-toggle {
    color: var(--text-secondary); background: transparent; border: none;
    font-size: 1rem; padding: 0.4rem; border-radius: 50%; transition: color 0.2s;
}
.btn-theme-toggle:hover {
    color: var(--accent-color); background: rgba(0,0,0,0.05);
}
[data-bs-theme="dark"] .btn-theme-toggle:hover {
    background: rgba(255,255,255,0.1);
}

/* --- Cards --- */
.card-box {
    background: var(--bg-card);
    border-radius: 0.75rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    padding: 1rem;
    margin-bottom: 1.5rem;
    transition: background-color 0.3s, border-color 0.3s;
}
.section-title {
    font-size: 1rem; font-weight: 600; color: var(--text-primary);
    margin-bottom: 0.75rem; display: flex; align-items: center; justify-content: space-between;
}

/* --- Forms (Standard) --- */
.form-label {
    font-size: 0.75rem; font-weight: 600; color: var(--text-secondary);
    margin-bottom: 0.3rem; text-transform: uppercase; letter-spacing: 0.02em;
}
.form-control, .form-select {
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 0.4rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    transition: all 0.2s;
    min-height: 38px;
}
.input-group-text {
    background-color: var(--icon-bg);
    border-color: var(--border-color);
    color: var(--text-secondary);
    font-size: 0.85rem;
    transition: all 0.3s;
}
:root .input-group-text { color: var(--accent-color); }
[data-bs-theme="light"] .input-group-text { color: var(--text-secondary); }

.form-select {
    padding-right: 2rem !important;
    text-overflow: ellipsis;
    overflow: hidden;
}
.form-control:focus, .form-select:focus {
    background-color: var(--bg-card);
    border-color: var(--accent-color);
    color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
    outline: none;
}

.btn-primary {
    background-color: var(--accent-color); border: none; border-radius: 0.4rem;
    padding: 0.4rem 1rem; font-weight: 500; box-shadow: none; color: #fff; font-size: 0.85rem;
}
.btn-primary:hover, .btn-primary:active {
    background-color: var(--accent-hover); color: #fff;
}

/* --- Tables --- */
.table-responsive { border-radius: 0.5rem; overflow: hidden; }
table.dataTable {
    border-collapse: collapse !important; width: 100% !important;
    margin-top: 0 !important; color: var(--text-primary) !important;
}
table.dataTable thead th {
    background-color: var(--table-head-bg) !important;
    color: var(--text-secondary) !important;
    font-weight: 600; font-size: 0.75rem; text-transform: uppercase;
    border-bottom: 1px solid var(--border-color) !important;
    border-right: 1px solid var(--border-color) !important;
    padding: 0.6rem 0.5rem !important;
}
table.dataTable tbody td {
    padding: 0.6rem 0.5rem !important; font-size: 0.85rem;
    border-bottom: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    color: var(--text-primary);
    background-color: var(--bg-card) !important;
}
table.dataTable thead th:last-child,
table.dataTable tbody td:last-child { border-right: none !important; }
table.dataTable tbody tr:hover td { background-color: var(--table-hover) !important; }

/* DataTables Components */
.dt-buttons .dt-button {
    background: #10b981 !important; color: white !important; border: none !important;
    border-radius: 0.4rem !important; padding: 0.3rem 0.8rem !important;
    font-size: 0.8rem !important; font-weight: 500 !important; margin-bottom: 0.5rem;
}
.dt-buttons .dt-button:hover { background: #059669 !important; }

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info {
    font-size: 0.8rem; color: var(--text-secondary) !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 0.2rem 0.6rem !important; font-size: 0.8rem !important; color: var(--text-secondary) !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--accent-color) !important; color: white !important; border: none !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--table-hover) !important; color: var(--text-primary) !important; border: 1px solid var(--border-color) !important;
}

/* --- Misc --- */
.creative-cell, .targeting-cell {
    max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    color: var(--text-secondary); cursor: help;
}
#preloader {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg-body); display: flex; align-items: center; justify-content: center; z-index: 9999;
}
.spinner {
    width: 40px; height: 40px; border: 3px solid var(--border-color);
    border-top-color: var(--accent-color); border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

tfoot tr { background-color: var(--input-bg); font-weight: 700; }
tfoot td {
    background-color: var(--input-bg) !important; color: var(--text-primary);
    border-top: 2px solid var(--border-color) !important; border-right: 1px solid var(--border-color) !important; font-size: 0.8rem;
}
tfoot td:last-child { border-right: none !important; }

/* Fix Phantom Row in DataTables Scroll */
.dataTables_scrollBody thead tr th {
    padding-top: 0 !important; padding-bottom: 0 !important; border-top: none !important;
    border-bottom: none !important; line-height: 0 !important; height: 0 !important; overflow: hidden !important;
}