/* ============================================================
   Point Zero OSINT Tool - Styles
   ============================================================ */

/* ============================================================
   CSS переменные для темной и светлой темы
   ============================================================ */

/* CSS переменные для темной темы (по умолчанию) */
:root {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #3a3a3a;
    --text-primary: #e0e0e0;
    --text-secondary: #999;
    --accent: #e94560;
    --accent-hover: #c73e54;
    --border: #404040;
    --error: #e94560;
    --success: #4CAF50;
    --warning: #FF9800;
}

/* CSS переменные для светлой темы */
:root.light-theme {
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8e8e8;
    --text-primary: #333;
    --text-secondary: #666;
    --accent: #d32f2f;
    --accent-hover: #b71c1c;
    --border: #ddd;
    --error: #d32f2f;
    --success: #388e3c;
    --warning: #f57c00;
}

/* ============================================================
   Базовые стили
   ============================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: background 0.3s, color 0.3s;
}

/* ============================================================
   Layout контейнеры
   ============================================================ */

.container {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 350px;
    padding: 20px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    overflow-y: auto;
}

.sidebar h1 {
    font-size: 22px;
    margin-bottom: 20px;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
}

/* Маленький логотип в sidebar */
.sidebar-logo {
    width: 80px;
    height: 80px;
    border-radius: 12px;
    flex-shrink: 0;
    cursor: pointer;
    transition: transform 0.3s;
}

.sidebar-logo:hover {
    transform: scale(1.05);
}

/* Анимация пульсации для клика */
@keyframes logo-pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 rgba(233, 69, 96, 0);
    }
    30% {
        transform: scale(1.12);
        box-shadow: 0 0 20px rgba(233, 69, 96, 0.5);
    }
    60% {
        transform: scale(1.18);
        box-shadow: 0 0 30px rgba(233, 69, 96, 0.7);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 rgba(233, 69, 96, 0);
    }
}

.sidebar-logo.pulse {
    animation: logo-pulse 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Анимация кувырка для 10-го клика */
@keyframes logo-flip {
    0% {
        transform: rotate(0deg) scale(1);
        box-shadow: 0 0 0 rgba(233, 69, 96, 0);
    }
    15% {
        transform: rotate(45deg) scale(1.15);
        box-shadow: 0 0 25px rgba(233, 69, 96, 0.6);
    }
    30% {
        transform: rotate(90deg) scale(1.25);
        box-shadow: 0 0 35px rgba(233, 69, 96, 0.7);
    }
    45% {
        transform: rotate(135deg) scale(1.3);
        box-shadow: 0 0 40px rgba(233, 69, 96, 0.8);
    }
    60% {
        transform: rotate(180deg) scale(1.35);
        box-shadow: 0 0 45px rgba(233, 69, 96, 0.9);
    }
    75% {
        transform: rotate(270deg) scale(1.25);
        box-shadow: 0 0 35px rgba(233, 69, 96, 0.7);
    }
    90% {
        transform: rotate(315deg) scale(1.1);
        box-shadow: 0 0 20px rgba(233, 69, 96, 0.5);
    }
    100% {
        transform: rotate(360deg) scale(1);
        box-shadow: 0 0 0 rgba(233, 69, 96, 0);
    }
}

.sidebar-logo.flip {
    animation: logo-flip 1.6s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

/* ============================================================
   Header кнопки
   ============================================================ */

.header-buttons {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

/* ============================================================
   Map Container и Header над картой
   ============================================================ */

.map-container {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.map-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 70px;
}

.app-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}

#map {
    flex: 1;
}

/* ============================================================
   Кнопка переключения темы
   ============================================================ */

.theme-toggle,
.ai-history-toggle,
.settings-toggle {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    padding: 8px 12px;
    cursor: pointer;
    font-size: 18px;
    border-radius: 6px;
    transition: all 0.3s;
    width: auto;
    min-width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover,
.ai-history-toggle:hover,
.settings-toggle:hover {
    background: var(--accent);
    transform: scale(1.1);
    border-color: var(--accent);
}

/* ============================================================
   Формы и инпуты
   ============================================================ */

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--bg-tertiary);
    box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.1);
}

/* Специальные стили для date inputs для лучшей видимости */
.form-group input[type="date"] {
    color: var(--text-primary);
    font-weight: 500;
}

.form-group input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.8);
    cursor: pointer;
}

/* Светлая тема - инвертируем календарь обратно */
:root.light-theme .form-group input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.2);
}

.form-group input[type="date"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.form-group input[type="date"]:disabled::-webkit-calendar-picker-indicator {
    opacity: 0.3;
}

/* ============================================================
   Стили валидации
   ============================================================ */

.form-group input.input-error {
    border-color: var(--error) !important;
    box-shadow: 0 0 5px rgba(233, 69, 96, 0.5);
}

.validation-message {
    font-size: 11px;
    color: var(--error);
    margin-top: 5px;
    display: none;
}

.validation-message.show {
    display: block;
}

/* ============================================================
   Кнопки
   ============================================================ */

button {
    width: 100%;
    padding: 12px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

button:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(233, 69, 96, 0.3);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    background: #555;
    cursor: not-allowed;
    opacity: 0.6;
}

button.test-btn {
    background: var(--bg-tertiary);
    font-size: 14px;
    padding: 8px;
    margin-bottom: 10px;
}

button.test-btn:hover {
    background: var(--border);
}

button.secondary-btn {
    background: var(--bg-tertiary);
    margin-top: 10px;
}

button.secondary-btn:hover {
    background: var(--border);
}

/* ============================================================
   Фильтры
   ============================================================ */

.filters {
    margin-top: 20px;
    padding: 15px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.filters h3 {
    font-size: 16px;
    margin-bottom: 15px;
    color: var(--accent);
}

.filter-item {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.filter-item input[type="checkbox"] {
    width: auto;
    margin-right: 10px;
}

.filter-item label {
    font-size: 14px;
    cursor: pointer;
}

/* ============================================================
   Результаты
   ============================================================ */

.results {
    margin-top: 20px;
    padding: 15px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.results h3 {
    font-size: 16px;
    margin-bottom: 15px;
    color: var(--accent);
}

.result-item {
    padding: 12px;
    background: var(--bg-tertiary);
    border: 1px solid transparent;
    border-radius: 6px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.result-item:hover {
    background: var(--bg-secondary);
    border-color: var(--accent);
    transform: translateX(4px);
}

.result-item .type {
    font-size: 12px;
    color: var(--accent);
    margin-bottom: 5px;
}

.result-item .name {
    font-size: 14px;
    font-weight: 500;
}

/* ============================================================
   Легенда
   ============================================================ */

.legend {
    margin-top: 20px;
    padding: 15px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.legend h3 {
    font-size: 16px;
    margin-bottom: 15px;
    color: var(--accent);
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.legend-item .marker {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    margin-right: 10px;
}

.legend-item .marker.military {
    background: #e94560;
}

.legend-item .marker.hospital {
    background: #4CAF50;
}

/* ============================================================
   Статус и загрузка
   ============================================================ */

.loading {
    text-align: center;
    padding: 20px;
    color: var(--accent);
}

.info-box {
    padding: 10px;
    margin-top: 10px;
    background: var(--bg-primary);
    border-left: 3px solid var(--accent);
    border-radius: 3px;
    font-size: 12px;
}

.status {
    padding: 10px;
    margin-top: 10px;
    background: var(--bg-primary);
    border-radius: 5px;
    font-size: 12px;
    color: var(--text-secondary);
}

.status-item {
    padding: 3px 0;
}

.status-item.success {
    color: var(--success);
}

.status-item.error {
    color: var(--error);
}

.status-item.pending {
    color: var(--warning);
}

/* ============================================================
   Модальное окно экспорта
   ============================================================ */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

.modal.show {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: var(--bg-secondary);
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
    border: 1px solid var(--border);
}

.modal-header {
    font-size: 20px;
    margin-bottom: 20px;
    color: var(--accent);
}

.modal-close {
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: var(--text-secondary);
}

.modal-close:hover {
    color: var(--accent);
}

.export-format-selector {
    margin-bottom: 20px;
}

.export-format-selector label {
    display: block;
    margin-bottom: 8px;
}

.export-format-selector select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
}

.export-format-selector select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.1);
}

/* ============================================================
   История поисков
   ============================================================ */

.history {
    margin-top: 20px;
    padding: 15px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.history h3 {
    font-size: 16px;
    margin-bottom: 10px;
    color: var(--accent);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-list {
    max-height: 300px;
    overflow-y: auto;
    display: none;
}

.history-list.show {
    display: block;
}

.history-item {
    padding: 10px;
    background: var(--bg-tertiary);
    border: 1px solid transparent;
    border-radius: 6px;
    margin-bottom: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s;
}

.history-item:hover {
    background: var(--bg-secondary);
    border-color: var(--accent);
    transform: translateX(4px);
}

.history-item .time {
    color: var(--text-secondary);
    font-size: 10px;
}

/* ============================================================
   Share секция
   ============================================================ */

.share-section {
    margin-top: 20px;
    padding: 15px;
    background: var(--bg-tertiary);
    border-radius: 5px;
}

.share-section h3 {
    font-size: 16px;
    margin-bottom: 10px;
    color: var(--accent);
}

.share-url-container {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.share-url-input {
    flex: 1;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 12px;
    font-family: monospace;
}

.copy-btn {
    padding: 8px 16px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
}

.copy-btn:hover {
    background: var(--accent-hover);
}

.copy-btn.copied {
    background: var(--success);
}

/* ============================================================
   Map Controls и Animations
   ============================================================ */

/* Leaflet control кнопки */
.leaflet-control-recenter {
    transition: all 0.2s;
}

.leaflet-control-recenter:hover {
    background: var(--accent) !important;
    color: white;
    transform: scale(1.1);
}

.leaflet-control-recenter:active {
    transform: scale(0.95);
}

/* Анимация pulse для клик-маркера */
@keyframes pulse {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Курсор для draggable маркера */
.leaflet-marker-draggable {
    cursor: move !important;
}

/* Стили для Leaflet popup */
.leaflet-popup-content {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 13px;
}

.leaflet-popup-content b {
    color: var(--accent);
}

/* ============================================================
   AI Sidebar
   ============================================================ */

.ai-sidebar {
    position: fixed;
    top: 0;
    right: -400px; /* Скрыт по умолчанию */
    width: 400px;
    height: 100vh;
    background: var(--bg-secondary);
    border-left: 2px solid var(--border);
    box-shadow: -5px 0 20px rgba(0, 0, 0, 0.3);
    z-index: 1001;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.ai-sidebar.show {
    right: 0;
}

.ai-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 2px solid var(--border);
    background: var(--bg-primary);
}

.ai-sidebar-header h3 {
    margin: 0;
    font-size: 18px;
    color: var(--accent);
}

.ai-sidebar-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 5px;
    transition: all 0.2s;
}

.ai-sidebar-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.ai-sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.ai-description-header {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.ai-description-header strong {
    font-size: 16px;
    color: var(--text-primary);
}

.ai-description-body {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    margin-bottom: 20px;
    white-space: pre-wrap;
}

.ai-description-footer {
    display: flex;
    gap: 10px;
    padding-top: 15px;
    border-top: 1px solid var(--border);
}

.ai-copy-btn,
.ai-close-btn {
    flex: 1;
    padding: 10px;
    font-size: 13px;
    border-radius: 5px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-copy-btn {
    background: var(--accent);
    color: white;
}

.ai-copy-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

.ai-close-btn {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.ai-close-btn:hover {
    background: var(--bg-hover);
}

/* Адаптивность для AI sidebar */
@media (max-width: 768px) {
    .ai-sidebar {
        width: 100%;
        right: -100%;
    }
}

/* ============================================================
   AI Describe Button в Popup
   ============================================================ */

.ai-describe-btn {
    display: inline-block;
    margin-top: 10px;
    padding: 8px 12px;
    background: linear-gradient(135deg, var(--accent), #9333ea);
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.ai-describe-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}

.ai-describe-btn:active {
    transform: translateY(0);
}

.ai-describe-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}
