/* static/css/app.css - Общие стили приложения */

/* ===== БАЗОВЫЕ ===== */
* {
    box-sizing: border-box;
}

html, body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
    position: relative;
}

.main-content {
    transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: calc(100vw - 72px);
    overflow-x: hidden;
}

@media (max-width: 768px) {
    .main-content {
        margin-left: 0 !important;
        max-width: 100vw;
    }
}

/* ===== САЙДБАР ===== */
.sidebar {
    position: fixed;
    top: 64px;
    left: 0;
    width: 72px;
    height: calc(100vh - 64px);
    background: white;
    border-right: 1px solid #e5e7eb;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 40;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

.sidebar:hover {
    width: 280px;
    box-shadow: 2px 0 24px rgba(0, 0, 0, 0.06);
}

.sidebar .sidebar-text {
    opacity: 0;
    transition: opacity 0.2s ease 0.05s;
    white-space: nowrap;
}

.sidebar:hover .sidebar-text {
    opacity: 1;
}

.sidebar-icon {
    font-size: 24px;
    min-width: 24px;
    text-align: center;
    transition: transform 0.15s;
}

.sidebar-link:hover .sidebar-icon {
    transform: scale(1.1);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    color: #6b7280;
    border-radius: 10px;
    margin: 4px 8px;
    position: relative;
}

.sidebar-link .tooltip {
    position: absolute;
    left: 80px;
    background: #1f2937;
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s, visibility 0.15s;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 50;
}

.sidebar-link .tooltip::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-right-color: #1f2937;
}

.sidebar:not(:hover) .sidebar-link:hover .tooltip {
    opacity: 1;
    visibility: visible;
}

.sidebar-link:hover {
    background-color: #f3f4f6;
    color: #111827;
}

.sidebar-link.active {
    background: linear-gradient(135deg, #eff6ff 0%, #e0f2fe 100%);
    color: #2563eb;
}

.sidebar-link.active .sidebar-icon {
    color: #2563eb;
}

.sidebar-link.danger {
    color: #dc2626;
}

.sidebar-link.danger:hover {
    background-color: #fee2e2;
    color: #b91c1c;
}

.sidebar-divider {
    height: 1px;
    background: #e5e7eb;
    margin: 8px 16px;
    opacity: 0;
    transition: opacity 0.2s ease 0.05s;
}

.sidebar:hover .sidebar-divider {
    opacity: 1;
}

.sidebar-section-header {
    padding: 8px 16px 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #9ca3af;
    opacity: 0;
    transition: opacity 0.2s ease 0.05s;
    white-space: nowrap;
}

.sidebar:hover .sidebar-section-header {
    opacity: 1;
}

.sidebar-footer {
    margin-top: auto;
    padding-bottom: 8px;
}

.sidebar-subtext {
    font-size: 12px;
    color: #9ca3af;
    margin-left: 40px;
    margin-top: -8px;
    margin-bottom: 4px;
    opacity: 0;
    transition: opacity 0.2s ease 0.05s;
    white-space: nowrap;
}

.sidebar:hover .sidebar-subtext {
    opacity: 1;
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s;
    z-index: 39;
}

.sidebar-overlay.open {
    opacity: 1;
    visibility: visible;
}

@media (max-width: 768px) {
    .sidebar {
        left: -100%;
        width: 100% !important;
        transition: left 0.3s ease;
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar:hover {
        width: 100% !important;
        box-shadow: none;
    }

    .sidebar .sidebar-text,
    .sidebar .sidebar-divider,
    .sidebar .sidebar-section-header,
    .sidebar .sidebar-subtext {
        opacity: 1 !important;
    }

    .sidebar-link .tooltip {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
    }
}

/* ===== ТАБЫ ===== */
.tab-btn {
    transition: all 0.2s;
}
.tab-content {
    transition: opacity 0.2s;
}

.tasks-tab {
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    color: #6b7280;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    cursor: pointer;
}
.tasks-tab.active {
    color: #2563eb;
    border-bottom-color: #2563eb;
}
.tasks-tab:hover {
    color: #374151;
}

/* ===== АНИМАЦИИ ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.animate-fade-in {
    animation: fadeIn 0.3s ease-out;
}

@keyframes modal-in {
    from { opacity: 0; transform: scale(0.95) translateY(-10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.animate-modal-in {
    animation: modal-in 0.2s ease-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}
.animate-shake {
    animation: shake 0.2s ease-in-out;
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.animate-spin {
    animation: spin 1s linear infinite;
    display: inline-block;
}

/* ===== СЛАЙДЕРЫ ===== */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
}
input[type="range"]::-webkit-slider-thumb,
input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    border: 2px solid currentColor;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
    margin-top: -6px;
}
input[type="range"]::-webkit-slider-runnable-track,
input[type="range"]::-moz-range-track {
    height: 8px;
    border-radius: 4px;
}

/* ===== SCREEN ===== */
.screen {
    transition: opacity 0.2s;
}

/* ===== ТЕГИ РЕГИОНОВ ===== */
#selected-regions-tags {
    min-height: 32px;
}
#selected-regions-tags > span {
    background: white;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    max-width: 100%;
    word-break: break-word;
}
#selected-regions-tags > span button {
    flex-shrink: 0;
    font-size: 16px;
    line-height: 1;
    padding: 0 2px;
}
#selected-regions-tags > span button:hover {
    background: #fee2e2;
    border-radius: 3px;
}

/* ===== DETAILS/SUMMARY ===== */
details summary::-webkit-details-marker {
    display: none;
}

/* ===== СОРТИРОВКА ===== */
th.sortable {
    position: relative;
    padding-right: 24px !important;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.sort-indicator {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    color: #9ca3af;
    opacity: 0.5;
    transition: opacity 0.2s, color 0.2s;
}
th.sortable:hover .sort-indicator {
    opacity: 0.8;
    color: #6b7280;
}
th.sort-asc .sort-indicator,
th.sort-desc .sort-indicator {
    opacity: 1;
    color: #2563eb;
}
th.sortable .sort-indicator::before {
    content: '▾▴';
    font-size: 12px;
    letter-spacing: -2px;
}
th.sort-asc .sort-indicator::before {
    content: '▲';
    font-size: 10px;
    letter-spacing: normal;
}
th.sort-desc .sort-indicator::before {
    content: '▼';
    font-size: 10px;
    letter-spacing: normal;
}

/* ===== ТАБЛИЦЫ ===== */
thead th {
    height: 48px;
    vertical-align: middle;
}

.keywords-table th,
.keywords-table td {
    padding: 8px 12px !important;
}
.group-badge {
    background: none !important;
    padding: 0 !important;
    font-size: 13px;
    color: #374151;
}
.actions-cell {
    white-space: nowrap;
    width: 70px;
}
.actions-cell .flex {
    gap: 4px !important;
}
.actions-cell button {
    padding: 4px 6px !important;
    font-size: 11px !important;
}
.num-cell {
    text-align: center;
    width: 35px;
    font-size: 12px;
    color: #6b7280;
}
.freq-cell, .position-cell {
    text-align: center;
    width: 70px;
}
.position-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}
.expand-competitors-btn {
    background: #eff6ff;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    color: #1d4ed8;
    transition: all 0.2s;
    cursor: pointer;
    border: none;
}
.expand-competitors-btn:hover {
    background: #dbeafe;
    transform: scale(1.02);
}
.hidden-competitors {
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px dashed #e5e7eb;
}
.break-all { word-break: break-all; }
.break-words { word-break: break-word; }
td a {
    word-break: break-all;
    display: inline-block;
    max-width: 100%;
}

/* ===== КАЛЕНДАРЬ (ИСТОРИЯ) ===== */
#calendar-days {
    gap: 2px;
}
#calendar-days > div {
    padding: 8px 4px;
    border-radius: 8px;
    font-size: 14px;
}

@media (max-width: 640px) {
    #calendar-days > div {
        padding: 6px 2px;
        font-size: 12px;
    }
}

/* ===== КАЛЕНДАРЬ ===== */
.compact-calendar {
    max-width: 100%;
    margin: 0 auto;
}
.compact-calendar #calendar-days {
    gap: 2px;
}
@media (max-width: 640px) {
    .compact-calendar .grid-cols-7 {
        gap: 1px;
    }
}

/* ===== ДИНАМИКА ===== */
.expand-dynamics-btn { cursor: pointer; }
.keywords-row td:first-child { padding-left: 1rem; }
@media (min-width: 640px) {
    .keywords-row td:first-child { padding-left: 2rem; }
}

/* ===== СТАТИСТИКА ===== */
#stats-panel > div {
    transition: all 0.2s ease;
    cursor: pointer;
}
#stats-panel > div:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* ===== ЗАГОЛОВКИ ДАТ ===== */
.date-header {
    cursor: pointer;
    transition: all 0.2s ease;
}
.date-header:hover {
    background-color: #f3f4f6;
}

/* ===== КОНТЕКСТНОЕ МЕНЮ ===== */
.context-menu-item {
    transition: background-color 0.15s;
}

/* ===== ПРОЧЕЕ ===== */
.rotate-180 { transform: rotate(180deg); }
.group-checkbox { cursor: pointer; }
.toggle-track-btn { cursor: pointer; transition: all 0.2s; }
.collect-group-btn { cursor: pointer; }


/* ===== PREVIEW: ТАБЫ ===== */
.tab {
    padding: 10px 20px;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
}
.tab.active {
    border-bottom-color: #3b82f6;
    color: #3b82f6;
    font-weight: 600;
}
.tab-content {
    display: none;
}
.tab-content.active {
    display: block;
}

/* ===== PREVIEW: БУЛЛИТЫ ===== */
.bullet-0 { color: #1f2937; font-size: 1.2rem; margin-right: 8px; }
.bullet-1 { color: #4b5563; font-size: 1.1rem; margin-right: 8px; }
.bullet-2 { color: #6b7280; font-size: 1rem; margin-right: 8px; }
.bullet-3 { color: #9ca3af; font-size: 0.95rem; margin-right: 8px; }
.bullet-4 { color: #cbd5e1; font-size: 0.9rem; margin-right: 8px; }
.bullet-5 { color: #e2e8f0; font-size: 0.85rem; margin-right: 8px; }

/* ===== PREVIEW: КОММЕНТАРИИ ===== */
.comment-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: #eff6ff;
    border: 1px solid #3b82f6;
    color: #3b82f6;
    font-size: 1rem;
    cursor: pointer;
    margin-left: 6px;
    transition: all 0.2s;
    position: relative;
    vertical-align: middle;
}
.comment-icon:hover {
    background: #3b82f6;
    color: white;
}
.comment-popover {
    position: absolute;
    background: white;
    border: 1px solid #3b82f6;
    border-radius: 12px;
    padding: 12px 16px;
    min-width: 200px;
    max-width: 300px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    z-index: 100;
    font-size: 0.9rem;
    color: #1e40af;
    word-break: break-word;
    display: none;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 12px;
    border-left: 4px solid #3b82f6;
}
.comment-popover.show {
    display: block;
}
.comment-popover::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 8px solid #3b82f6;
}

/* ===== PREVIEW: УДАЛЕННЫЕ/ПЕРЕМЕЩЕННЫЕ ===== */
.deleted-item {
    text-decoration: line-through;
    color: #ef4444;
    opacity: 0.7;
}
.deleted-badge {
    font-size: 0.7rem;
    color: #ef4444;
    background: #fee2e2;
    padding: 2px 8px;
    border-radius: 999px;
    display: inline-block;
    margin-left: 8px;
    border: 1px solid #ef4444;
    vertical-align: middle;
}
.moved-item {
    background: #ecfdf5;
    padding: 2px 6px;
    border-radius: 4px;
    border-left: 3px solid #10b981;
    display: inline-block;
}
.old-parent-badge {
    font-size: 0.75rem;
    color: #b45309;
    background: #fef3c7;
    padding: 2px 10px;
    border-radius: 16px;
    margin-left: 10px;
    display: inline-block;
    border: 1px solid #b45309;
    vertical-align: middle;
}
.old-text {
    text-decoration: line-through;
    color: #9ca3af;
    margin-right: 8px;
}
.new-text {
    color: #059669;
    font-weight: 500;
}

/* ===== PREVIEW: ЛЕГЕНДА ===== */
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    padding: 12px 16px;
    background: #f8fafc;
    border-radius: 10px;
    font-size: 0.85rem;
    margin-bottom: 20px;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}
.legend-sample {
    padding: 2px 8px;
    font-size: 0.85rem;
}
.legend-sample.deleted { color: #ef4444; text-decoration: line-through; }
.legend-sample.moved { background: #ecfdf5; border-left: 3px solid #10b981; padding: 2px 6px; border-radius: 4px; }
.legend-sample.moved-from { background: #fef3c7; border-left: 3px solid #b45309; padding: 2px 6px; border-radius: 4px; }
.legend-sample.comment-icon-sample {
    width: 24px;
    height: 24px;
    border-radius: 999px;
    background: #eff6ff;
    border: 1px solid #3b82f6;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #3b82f6;
    font-size: 0.9rem;
}

/* ===== RESULT: ТАБЫ ===== */
.tab {
    padding: 12px 24px;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    font-weight: 500;
    color: #64748b;
    font-size: 0.95rem;
}
.tab:hover { color: #0f172a; background: #f8fafc; }
.tab.active { border-bottom-color: #3b82f6; color: #3b82f6; font-weight: 600; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== RESULT: КОММЕНТАРИИ ===== */
.comment-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 999px;
    background: #eff6ff;
    border: 1px solid #3b82f6;
    color: #3b82f6;
    font-size: 0.8rem;
    cursor: pointer;
    margin-left: 8px;
    transition: all 0.2s;
    text-decoration: none;
    vertical-align: middle;
    opacity: 0.7;
}
.comment-link:hover { background: #3b82f6; color: white; transform: scale(1.1); opacity: 1; }

/* ===== RESULT: ПАНЕЛЬ КОММЕНТАРИЕВ ===== */
.comments-panel {
    position: fixed;
    right: -380px;
    top: 0;
    width: 360px;
    height: 100vh;
    background: white;
    border-left: 1px solid #e2e8f0;
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    transition: right 0.3s cubic-bezier(0.4,0,0.2,1);
    z-index: 50;
    display: flex;
    flex-direction: column;
}
.comments-panel.open { right: 0; }
.comments-panel-header {
    padding: 20px 16px;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.comments-panel-header h3 { font-weight: 600; display: flex; align-items: center; gap: 8px; font-size: 1.1rem; }
.close-panel {
    background: none; border: none; font-size: 1.8rem; cursor: pointer;
    color: #64748b; padding: 0 8px; line-height: 1; transition: color 0.2s;
}
.close-panel:hover { color: #0f172a; }
.comments-panel-content { flex: 1; overflow-y: auto; padding: 16px; }
.comment-card {
    padding: 16px; border: 1px solid #e2e8f0; border-radius: 12px;
    margin-bottom: 12px; cursor: pointer; transition: all 0.2s;
    border-left: 4px solid transparent; background: white;
}
.comment-card:hover { background: #f8fafc; border-left-color: #3b82f6; transform: translateX(-4px); box-shadow: 0 4px 12px rgba(0,0,0,0.05); }
.comment-card.selected { background: #eff6ff; border-left-color: #3b82f6; box-shadow: 0 4px 12px rgba(59,130,246,0.15); }
.comment-path {
    font-size: 0.7rem; color: #64748b; background: #f1f5f9;
    padding: 4px 10px; border-radius: 20px; display: inline-block;
    margin-bottom: 10px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.comment-text { font-weight: 600; color: #0f172a; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 0.95rem; }
.comment-badge { font-size: 0.65rem; padding: 2px 8px; border-radius: 999px; background: #e2e8f0; color: #475569; font-weight: 500; }
.comment-badge.delete { background: #fee2e2; color: #dc2626; }
.comment-badge.edit { background: #fef3c7; color: #b45309; }
.comment-message { background: #eff6ff; padding: 10px 12px; border-radius: 8px; color: #1e40af; font-size: 0.9rem; margin-top: 8px; border-left: 3px solid #3b82f6; line-height: 1.5; }
.comment-context { font-size: 0.7rem; color: #94a3b8; margin-top: 8px; text-align: right; }

/* ===== RESULT: КНОПКА ПАНЕЛИ ===== */
.toggle-panel-btn {
    position: fixed; bottom: 24px; right: 24px;
    background: #3b82f6; color: white; border: none; border-radius: 999px;
    padding: 14px 24px; font-size: 1rem; font-weight: 500;
    box-shadow: 0 4px 16px rgba(59,130,246,0.4); cursor: pointer;
    z-index: 49; display: flex; align-items: center; gap: 10px; transition: all 0.2s;
}
.toggle-panel-btn:hover { background: #2563eb; transform: scale(1.05); box-shadow: 0 6px 20px rgba(37,99,235,0.5); }
.toggle-panel-btn .badge { background: white; color: #3b82f6; padding: 2px 10px; border-radius: 999px; font-size: 0.85rem; font-weight: 600; }

/* ===== RESULT: ОВЕРЛЕЙ ===== */
.panel-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4); opacity: 0; visibility: hidden;
    transition: all 0.3s; z-index: 48;
}
.panel-overlay.visible { opacity: 1; visibility: visible; }

/* ===== RESULT: ПОДСВЕТКА ===== */
.highlight-item { animation: pulse 2s ease-in-out; }
@keyframes pulse {
    0%, 100% { background-color: transparent; }
    30%, 70% { background-color: #fef9c3; }
}

/* ===== RESULT: СТАТУСЫ ===== */
.status-badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; font-size: 0.85rem; font-weight: 500; }
.status-badge.waiting { background: #fef3c7; color: #b45309; }
.status-badge.approved { background: #dcfce7; color: #166534; }
