/* ============================================
   KRITIS Security Analyzer - Styles
   ============================================ */

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #1a1a2e;
}

#container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ============================================
   Sidebar
   ============================================ */

#sidebar {
    width: 360px;
    min-width: 0;
    max-width: 90vw;
    background: linear-gradient(180deg, #16213e 0%, #1a1a2e 100%);
    color: #e8e8e8;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

#sidebar.collapsed {
    width: 0 !important;
    min-width: 0 !important;
}

/* ============================================
   Sidebar Resizer / Collapse Toggle
   ============================================ */

.sidebar-resizer {
    width: 6px;
    flex-shrink: 0;
    background: #0f3460;
    cursor: col-resize;
    position: relative;
    z-index: 10;
    transition: background 0.15s;
}

.sidebar-resizer:hover,
.sidebar-resizer.dragging {
    background: #e94560;
}

.sidebar-toggle-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 44px;
    padding: 0;
    border-radius: 6px;
    border: 1px solid #0f3460;
    background: #16213e;
    color: #e8e8e8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    z-index: 11;
}

.sidebar-toggle-btn:hover {
    background: #e94560;
    border-color: #e94560;
}

.sidebar-header {
    background: linear-gradient(135deg, #0f3460 0%, #16213e 100%);
    padding: 20px;
    text-align: center;
    border-bottom: 2px solid #e94560;
}

.sidebar-header h1 {
    margin: 0;
    font-size: 1.5rem;
    color: #fff;
    letter-spacing: 1px;
}

.sidebar-header .subtitle {
    font-size: 0.8rem;
    color: #e94560;
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* ============================================
   Tabs
   ============================================ */

.tabs {
    display: flex;
    background: #0f3460;
    border-bottom: 1px solid #16213e;
}

.tab-btn {
    flex: 1;
    padding: 12px 8px;
    background: transparent;
    border: none;
    color: #8892b0;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 3px solid transparent;
}

.tab-btn:hover {
    background: rgba(233, 69, 96, 0.1);
    color: #e94560;
}

.tab-btn.active {
    color: #e94560;
    border-bottom-color: #e94560;
    background: rgba(233, 69, 96, 0.1);
}

.tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.tab-content.active {
    display: block;
}

/* ============================================
   Panels
   ============================================ */

.panel {
    background: rgba(15, 52, 96, 0.5);
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 15px;
    border: 1px solid #0f3460;
}

.panel h3 {
    margin: 0 0 12px 0;
    font-size: 1rem;
    color: #e94560;
    display: flex;
    align-items: center;
    gap: 8px;
}

.help-text {
    font-size: 0.8rem;
    color: #8892b0;
    margin: 0 0 12px 0;
}

/* ============================================
   Forms
   ============================================ */

.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    color: #8892b0;
    margin-bottom: 5px;
}

input[type="text"],
input[type="number"] {
    width: 100%;
    padding: 10px 12px;
    background: #1a1a2e;
    border: 1px solid #0f3460;
    border-radius: 6px;
    color: #fff;
    font-size: 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus,
input[type="number"]:focus {
    outline: none;
    border-color: #e94560;
    box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.2);
}

input::placeholder {
    color: #536390;
}

/* ============================================
   Buttons
   ============================================ */

.primary-btn {
    width: 100%;
    padding: 14px 20px;
    background: linear-gradient(135deg, #e94560 0%, #c23a52 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(233, 69, 96, 0.3);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(233, 69, 96, 0.4);
}

.primary-btn:active {
    transform: translateY(0);
}

.secondary-btn {
    width: 100%;
    padding: 10px 16px;
    background: #0f3460;
    color: #e8e8e8;
    border: 1px solid #1a4b8c;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 8px;
}

.secondary-btn:hover {
    background: #1a4b8c;
    border-color: #e94560;
}

.text-btn {
    background: transparent;
    border: none;
    color: #8892b0;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 8px;
    margin-top: 5px;
}

.text-btn:hover {
    color: #e94560;
}

.button-row {
    display: flex;
    gap: 10px;
}

.button-row button {
    flex: 1;
    padding: 10px;
    background: #0f3460;
    border: 1px solid #1a4b8c;
    border-radius: 6px;
    color: #e8e8e8;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.button-row button:hover {
    background: #1a4b8c;
    border-color: #e94560;
}

.button-row button.active {
    background: #e94560;
    border-color: #e94560;
}

/* ============================================
   Search Input
   ============================================ */

.search-input-wrapper {
    display: flex;
    gap: 8px;
}

.search-input-wrapper input {
    flex: 1;
}

.search-input-wrapper button {
    padding: 10px 15px;
    background: #e94560;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s;
}

.search-input-wrapper button:hover {
    background: #c23a52;
}

/* ============================================
   Spinner
   ============================================ */

.spinner-container {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 15px;
    background: rgba(233, 69, 96, 0.1);
    border-radius: 8px;
    margin-top: 10px;
    border: 1px solid #e94560;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #0f3460;
    border-top-color: #e94560;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.spinner-container span {
    color: #e94560;
    font-size: 0.9rem;
}

/* ============================================
   Statistics
   ============================================ */

.stats-empty {
    color: #536390;
    font-style: italic;
    font-size: 0.85rem;
    margin: 0;
    text-align: center;
    padding: 10px;
}

.stats-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #0f3460;
    font-size: 0.85rem;
}

.stats-item:last-child {
    border-bottom: none;
}

.stats-item .label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stats-item .color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid #fff;
}

.stats-item .count {
    font-weight: 600;
    color: #e94560;
    background: rgba(233, 69, 96, 0.2);
    padding: 2px 8px;
    border-radius: 10px;
}

.stats-total {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 2px solid #e94560 !important;
    font-weight: 700;
    font-size: 1rem;
}

/* ============================================
   Results Box
   ============================================ */

.results-box {
    margin-top: 12px;
    padding: 10px;
    background: #1a1a2e;
    border-radius: 6px;
    font-size: 0.85rem;
    max-height: 400px;
    overflow-y: auto;
    display: none;
}

.results-box.visible {
    display: block;
}

.full-analysis-results {
    max-height: 600px;
    line-height: 1.5;
}

.full-analysis-results h4 {
    color: #e94560;
    margin: 14px 0 6px;
}

.full-analysis-results h4:first-child {
    margin-top: 0;
}

.full-analysis-results strong {
    color: #fff;
}

.full-analysis-results hr {
    border: none;
    border-top: 1px solid #0f3460;
    margin: 10px 0;
}

.address-results {
    display: none;
    margin-top: 6px;
    background: #1a1a2e;
    border: 1px solid #0f3460;
    border-radius: 6px;
    max-height: 200px;
    overflow-y: auto;
}

.address-results.visible {
    display: block;
}

.address-result-item {
    padding: 8px 10px;
    font-size: 0.85rem;
    cursor: pointer;
    border-bottom: 1px solid #0f3460;
}

.address-result-item:last-child {
    border-bottom: none;
}

.address-result-item:hover {
    background: #16213e;
}

/* ============================================
   Risk Indicators
   ============================================ */

.risk-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}

.risk-badge.high {
    background: rgba(255, 71, 87, 0.2);
    color: #ff4757;
}

.risk-badge.medium {
    background: rgba(255, 165, 2, 0.2);
    color: #ffa502;
}

.risk-badge.low {
    background: rgba(46, 213, 115, 0.2);
    color: #2ed573;
}

/* ============================================
   Route Points
   ============================================ */

/* ============================================
   Sessions List
   ============================================ */

.sessions-list {
    max-height: 200px;
    overflow-y: auto;
}

.session-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: #1a1a2e;
    border-radius: 6px;
    margin-bottom: 8px;
    border: 1px solid #0f3460;
}

.session-item .name {
    font-weight: 500;
}

.session-item .date {
    font-size: 0.75rem;
    color: #536390;
}

.session-item .actions {
    display: flex;
    gap: 5px;
}

.session-item button {
    padding: 5px 10px;
    font-size: 0.75rem;
    background: #0f3460;
    border: none;
    border-radius: 4px;
    color: #e8e8e8;
    cursor: pointer;
}

.session-item button:hover {
    background: #e94560;
}

.session-item button.delete:hover {
    background: #ff4757;
}

/* ============================================
   Share Link
   ============================================ */

.share-link-box {
    margin-top: 10px;
    padding: 10px;
    background: #1a1a2e;
    border-radius: 6px;
    word-break: break-all;
    font-size: 0.8rem;
    color: #2ed573;
    display: none;
}

.share-link-box.visible {
    display: block;
}

/* ============================================
   Error Display
   ============================================ */

.error-display {
    display: none;
    background: #ff4757;
    color: #fff;
    padding: 12px 15px;
    margin: 15px;
    border-radius: 8px;
    font-size: 0.9rem;
}

.error-display.visible {
    display: block;
}

/* ============================================
   Categories Tree
   ============================================ */

.categories-panel {
    max-height: 400px;
    overflow-y: auto;
}

#categoryFilter {
    margin-bottom: 10px;
}

#treeview {
    list-style: none;
    padding: 0;
    margin: 0;
}

.tree-rnode {
    margin-bottom: 8px;
}

.tree-rnode>label {
    display: block;
    padding: 10px 12px;
    background: #0f3460;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    color: #e8e8e8;
    transition: all 0.2s;
    border-left: 3px solid #e94560;
}

.tree-rnode>label:hover {
    background: #1a4b8c;
}

.tree-rnode>label.expanded {
    border-radius: 6px 6px 0 0;
}

.tree-node {
    padding-left: 0;
}

.tree-node ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
    background: rgba(15, 52, 96, 0.3);
    border-radius: 0 0 6px 6px;
}

.tree-node li {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid #0f3460;
    font-size: 0.85rem;
}

.tree-node li:last-child {
    border-bottom: none;
}

.tree-node input[type="checkbox"] {
    margin-right: 10px;
    accent-color: #e94560;
    width: 16px;
    height: 16px;
}

.tree-node .color-indicator {
    margin-right: 8px;
    font-size: 1rem;
}

.tree-node .risk-score {
    margin-left: auto;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.3);
}

/* ============================================
   Map Container
   ============================================ */

#map-container {
    flex: 1;
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
    background: #1a1a2e;
}

/* ============================================
   Map Legend
   ============================================ */

.map-legend {
    position: absolute;
    bottom: 30px;
    right: 10px;
    background: rgba(22, 33, 62, 0.95);
    color: #fff;
    padding: 15px;
    border-radius: 10px;
    z-index: 1000;
    max-width: 220px;
    max-height: 300px;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    border: 1px solid #0f3460;
}

.map-legend h4 {
    margin: 0 0 12px 0;
    font-size: 1rem;
    color: #e94560;
    border-bottom: 1px solid #0f3460;
    padding-bottom: 8px;
}

.legend-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8rem;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid #fff;
    flex-shrink: 0;
}

.legend-placeholder {
    color: #536390;
    font-style: italic;
    font-size: 0.85rem;
}

/* ============================================
   Info Panel
   ============================================ */

.info-panel {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 320px;
    max-height: 80vh;
    background: rgba(22, 33, 62, 0.95);
    color: #fff;
    border-radius: 10px;
    z-index: 1001;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    border: 1px solid #0f3460;
    overflow: hidden;
}

.info-panel.hidden {
    display: none;
}

.info-panel .close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    border: none;
    color: #8892b0;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px;
    line-height: 1;
}

.info-panel .close-btn:hover {
    color: #e94560;
}

.info-panel h3 {
    margin: 0;
    padding: 15px 40px 15px 15px;
    background: #0f3460;
    color: #e94560;
    font-size: 1rem;
    border-bottom: 1px solid #1a4b8c;
}

#infoPanelContent {
    padding: 15px;
    max-height: calc(80vh - 60px);
    overflow-y: auto;
    font-size: 0.9rem;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #0f3460;
}

.info-row:last-child {
    border-bottom: none;
}

.info-row .key {
    color: #8892b0;
}

.info-row .value {
    color: #fff;
    text-align: right;
    max-width: 60%;
    word-break: break-word;
}

.info-row .value a {
    color: #e94560;
}

/* ============================================
   Custom Query Inputs
   ============================================ */

.custom-query-section {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #0f3460;
}

.custom-query-section h4 {
    font-size: 0.9rem;
    color: #e94560;
    margin: 0 0 10px 0;
}

.custom-query-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.custom-query-input {
    flex: 1;
    padding: 8px !important;
    font-size: 0.8rem !important;
}

/* ============================================
   Scrollbar Styling
   ============================================ */

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #1a1a2e;
}

::-webkit-scrollbar-thumb {
    background: #0f3460;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #1a4b8c;
}

/* ============================================
   Leaflet Customizations
   ============================================ */

.leaflet-popup-content-wrapper {
    background: rgba(22, 33, 62, 0.95);
    color: #e8e8e8;
    border-radius: 8px;
    border: 1px solid #0f3460;
}

.leaflet-popup-content {
    margin: 12px;
    font-size: 0.85rem;
}

.leaflet-popup-content b {
    color: #e94560;
}

.leaflet-popup-tip {
    background: rgba(22, 33, 62, 0.95);
    border: 1px solid #0f3460;
}

.leaflet-control-zoom a {
    background: #16213e !important;
    color: #e8e8e8 !important;
    border-color: #0f3460 !important;
}

.leaflet-control-zoom a:hover {
    background: #0f3460 !important;
}

.leaflet-control-attribution {
    background: rgba(22, 33, 62, 0.8) !important;
    color: #536390 !important;
}

.leaflet-control-attribution a {
    color: #8892b0 !important;
}

/* Cluster markers */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
    background-color: rgba(233, 69, 96, 0.6);
}

.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
    background-color: rgba(233, 69, 96, 0.9);
    color: #fff;
    font-weight: 600;
}

/* ============================================
   Search Mode Toggle
   ============================================ */

.search-mode-toggle {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.mode-btn {
    flex: 1;
    padding: 10px 12px;
    background: #1a1a2e;
    border: 1px solid #0f3460;
    border-radius: 6px;
    color: #8892b0;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.mode-btn:hover {
    border-color: #e94560;
    color: #e8e8e8;
}

.mode-btn.active {
    background: #e94560;
    border-color: #e94560;
    color: #fff;
}

.mode-info {
    padding: 8px;
    background: rgba(15, 52, 96, 0.3);
    border-radius: 6px;
}

.mode-info small {
    color: #8892b0;
}

.polygon-status {
    margin-top: 8px;
    padding: 8px 12px;
    background: #1a1a2e;
    border-radius: 6px;
    font-size: 0.85rem;
    color: #536390;
    border: 1px dashed #0f3460;
}

.polygon-status.active {
    color: #2ed573;
    border-style: solid;
    border-color: #2ed573;
}

/* Leaflet Draw customization */
.leaflet-draw-toolbar a {
    background-color: #16213e !important;
    border-color: #0f3460 !important;
}

.leaflet-draw-toolbar a:hover {
    background-color: #0f3460 !important;
}