/*
 * Legacy dashboard styles — extracted from index.html inline <style>
 * block in v3.4.21 (Phase F). No rule deletion in this pass; the purge of
 * unused rules is a separate visual-audit cycle. Moving these 630 lines
 * out of index.html means:
 *   - index.html drops from 1,814 → 1,184 lines (35% leaner)
 *   - CSP strict-src stays happy (external file under /static/css/)
 *   - Browser can cache the CSS independently of the HTML
 *
 * Live panes currently depend on: .stat-card*, #graph-container, .memory-*,
 * .sortable, .cluster-card, .entity-badge, .profile-select, .theme-toggle,
 * .backup-stat, .score-*, footer, plus the three @media blocks. Audit
 * before deleting any rule from this file.
 */

        :root {
            --slm-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            --slm-gradient-success: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
            --slm-gradient-info: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
            --slm-gradient-warning: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
        }

        html {
            scroll-behavior: smooth;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            overflow-x: auto;
            overflow-y: scroll;
            min-width: min-content;
        }

        [data-bs-theme="light"] body,
        [data-bs-theme="light"] {
            background: #f8f9fa;
        }

        .navbar {
            background: var(--slm-gradient);
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }

        /* Cloud account widget — sidebar (v3.4.10) */
        #ng-account-widget:hover { background: rgba(255,255,255,0.06) !important; }
        .account-dest-item { padding: 6px 0; display: flex; align-items: center; gap: 8px; }
        .account-dest-badge { font-size: 10px; padding: 1px 6px; border-radius: 4px; }
        .account-dest-badge.synced { background: rgba(0,212,170,0.15); color: #00D4AA; }
        .account-dest-badge.failed { background: rgba(255,71,87,0.15); color: #ff4757; }
        .account-dest-badge.never { background: rgba(255,255,255,0.06); color: #888; }

        /* Stat cards with gradient backgrounds */
        .stat-card {
            border: none;
            border-radius: 12px;
            box-shadow: 0 4px 15px rgba(0,0,0,0.08);
            transition: transform 0.2s, box-shadow 0.2s;
            overflow: hidden;
            position: relative;
        }

        .stat-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 8px 25px rgba(0,0,0,0.12);
        }

        .stat-card .stat-bg {
            position: absolute;
            top: 0; left: 0; right: 0; bottom: 0;
            opacity: 0.08;
            border-radius: 12px;
        }

        .stat-card-memories .stat-bg { background: var(--slm-gradient); }
        .stat-card-clusters .stat-bg { background: var(--slm-gradient-success); }
        .stat-card-nodes .stat-bg { background: var(--slm-gradient-info); }
        .stat-card-edges .stat-bg { background: var(--slm-gradient-warning); }

        .stat-icon {
            font-size: 2rem;
            opacity: 0.8;
        }

        .stat-value {
            font-size: 1.75rem;
            font-weight: 700;
            margin: 0;
        }

        .tab-content {
            min-height: 700px;
            overflow-x: auto;
            overflow-y: visible;
        }

        .tab-pane {
            overflow-x: auto;
            overflow-y: visible;
        }

        #graph-container {
            background: var(--bs-body-bg);
            border-radius: 10px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
            height: 600px !important;
            max-height: 600px;
            width: 100% !important;
            position: relative;
            overflow: hidden;
            /* Mobile touch support - prevent default gestures */
            touch-action: none;
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none;
        }

        #graph-container canvas {
            max-width: 100% !important;
            max-height: 100% !important;
        }

        .node {
            cursor: pointer;
            stroke: #fff;
            stroke-width: 2px;
        }

        .link {
            stroke: #999;
            stroke-opacity: 0.6;
        }

        .node-label {
            font-size: 10px;
            pointer-events: none;
            fill: #333;
        }

        /* Memory table styling */
        .memory-table {
            font-size: 0.9rem;
        }

        .memory-table tbody tr {
            cursor: pointer;
            transition: background-color 0.15s;
        }

        .memory-table tbody tr:hover {
            background-color: rgba(102, 126, 234, 0.08) !important;
        }

        .memory-content {
            max-width: 350px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .badge-importance {
            min-width: 30px;
        }

        .search-box {
            border-radius: 20px;
        }

        .cluster-card {
            border-left: 4px solid;
            margin-bottom: 1rem;
        }

        .entity-badge {
            margin: 2px;
            font-size: 0.8rem;
        }

        /* Loading spinner */
        .loading {
            text-align: center;
            padding: 60px 40px;
            color: #888;
        }

        .loading .spinner-border {
            width: 2rem;
            height: 2rem;
            margin-bottom: 12px;
        }

        /* Empty state */
        .empty-state {
            text-align: center;
            padding: 60px 40px;
            color: #888;
        }

        .empty-state i {
            font-size: 3rem;
            opacity: 0.3;
            margin-bottom: 12px;
        }

        .tooltip-custom {
            position: absolute;
            padding: 10px;
            background: rgba(0,0,0,0.8);
            color: white;
            border-radius: 5px;
            pointer-events: none;
            font-size: 12px;
            z-index: 1000;
            max-width: 300px;
        }

        .timeline-chart {
            min-height: 300px;
        }

        /* Score bar for search results */
        .score-bar-container {
            width: 80px;
            display: inline-block;
            vertical-align: middle;
        }

        .score-bar {
            height: 8px;
            border-radius: 4px;
            background: #e9ecef;
            overflow: hidden;
        }

        .score-bar-fill {
            height: 100%;
            border-radius: 4px;
            transition: width 0.4s ease;
        }

        .score-label {
            font-size: 0.75rem;
            font-weight: 600;
            min-width: 36px;
            display: inline-block;
            text-align: right;
            margin-right: 6px;
            vertical-align: middle;
        }

        /* Project select in navbar */
        .profile-select {
            background: rgba(255,255,255,0.15);
            border: 1px solid rgba(255,255,255,0.3);
            color: white;
            border-radius: 20px;
            padding: 2px 28px 2px 10px;
            font-size: 0.85rem;
            min-width: 120px;
            cursor: pointer;
        }

        .profile-select option {
            background: var(--bs-body-bg);
            color: var(--bs-body-color);
        }

        /* Sortable table headers */
        .sortable {
            cursor: pointer;
            user-select: none;
            position: relative;
            padding-right: 18px !important;
        }

        .sortable:hover {
            background-color: rgba(102, 126, 234, 0.08);
        }

        .sortable::after {
            content: '\F282';
            font-family: 'bootstrap-icons';
            position: absolute;
            right: 4px;
            opacity: 0.3;
            font-size: 0.7rem;
        }

        .sortable.sort-asc::after {
            content: '\F235';
            opacity: 0.8;
        }

        .sortable.sort-desc::after {
            content: '\F229';
            opacity: 0.8;
        }

        /* Confidence bar for patterns */
        .confidence-bar {
            height: 6px;
            border-radius: 3px;
            background: var(--bs-border-color);
            overflow: hidden;
            margin-top: 4px;
        }

        .confidence-fill {
            height: 100%;
            border-radius: 3px;
            transition: width 0.6s ease;
        }

        /* Backup status cards */
        .backup-stat {
            padding: 12px;
            border-radius: 8px;
            background: var(--bs-tertiary-bg);
            text-align: center;
        }

        .backup-stat .value {
            font-size: 1.3rem;
            font-weight: 700;
        }

        .backup-stat .label {
            font-size: 0.75rem;
            color: var(--bs-secondary-color);
            text-transform: uppercase;
        }

        /* Project delete button */
        .btn-delete-profile {
            padding: 2px 8px;
            font-size: 0.75rem;
        }

        /* Dark mode toggle button */
        .theme-toggle {
            background: none;
            border: 1px solid rgba(255,255,255,0.3);
            color: white;
            border-radius: 20px;
            padding: 4px 12px;
            font-size: 0.9rem;
            cursor: pointer;
            transition: background 0.2s;
        }

        .theme-toggle:hover {
            background: rgba(255,255,255,0.15);
        }

        /* Modal content formatting */
        .memory-detail-content {
            white-space: pre-wrap;
            word-break: break-word;
            font-size: 0.95rem;
            line-height: 1.6;
            max-height: 400px;
            overflow-y: auto;
            padding: 16px;
            background: var(--bs-tertiary-bg);
            border-radius: 8px;
        }

        .memory-detail-meta dt {
            font-weight: 600;
            color: var(--bs-secondary-color);
            font-size: 0.8rem;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .memory-detail-meta dd {
            margin-bottom: 12px;
        }

        /* Export dropdown */
        .export-dropdown .dropdown-menu {
            min-width: 200px;
        }

        /* Tab badge */
        .tab-count {
            font-size: 0.7rem;
            vertical-align: super;
            margin-left: 2px;
        }

        /* Footer */
        footer {
            text-align: center;
            padding: 20px;
            margin-top: 40px;
            border-top: 1px solid var(--bs-border-color);
            color: var(--bs-secondary-color);
        }

        footer a {
            color: #667eea;
        }

        [data-bs-theme="dark"] footer a {
            color: #8fa4ff;
        }

        /* ========================================
           MOBILE & TABLET RESPONSIVE STYLES
           ======================================== */

        /* Tablet (768px and below) */
        @media (max-width: 768px) {
            .navbar-brand {
                font-size: 1rem;
            }

            #navbar-subtitle {
                display: none !important;
            }

            .stat-card {
                margin-bottom: 12px;
            }

            .stat-value {
                font-size: 1.4rem;
            }

            .stat-icon {
                font-size: 1.5rem;
            }

            /* Graph container - smaller on tablet */
            #graph-container {
                height: 450px !important;
                max-height: 450px;
            }

            /* Stack controls vertically on tablet */
            .tab-pane .row > .col-md-6,
            .tab-pane .row > .col-md-8,
            .tab-pane .row > .col-md-4 {
                margin-bottom: 10px;
            }

            /* Smaller buttons on mobile */
            .btn-sm {
                font-size: 0.8rem;
                padding: 4px 8px;
            }

            /* Memory table - hide less important columns */
            .memory-table th:nth-child(4),
            .memory-table td:nth-child(4),
            .memory-table th:nth-child(5),
            .memory-table td:nth-child(5) {
                display: none;
            }

            .memory-content {
                max-width: 200px;
            }
        }

        /* Mobile (480px and below) */
        @media (max-width: 480px) {
            body {
                font-size: 0.9rem;
            }

            .navbar-brand {
                font-size: 0.9rem;
            }

            .container-fluid {
                padding-left: 10px;
                padding-right: 10px;
            }

            /* Stat cards - 2 per row on mobile */
            .col-6.mb-3 {
                padding-left: 5px;
                padding-right: 5px;
            }

            .stat-card {
                padding: 12px 8px !important;
            }

            .stat-value {
                font-size: 1.2rem;
            }

            .stat-icon {
                font-size: 1.2rem;
            }

            .stat-card small {
                font-size: 0.7rem;
            }

            /* Graph container - even smaller on mobile */
            #graph-container {
                height: 350px !important;
                max-height: 350px;
                border-radius: 6px;
            }

            /* Tabs - smaller text */
            .nav-tabs .nav-link {
                font-size: 0.8rem;
                padding: 8px 10px;
            }

            .nav-tabs .nav-link i {
                display: none;
            }

            /* Search controls - stack vertically */
            #memories-pane .row > div {
                margin-bottom: 8px;
            }

            /* Memory table - show only essentials */
            .memory-table {
                font-size: 0.8rem;
            }

            .memory-table th:nth-child(3),
            .memory-table td:nth-child(3),
            .memory-table th:nth-child(4),
            .memory-table td:nth-child(4),
            .memory-table th:nth-child(5),
            .memory-table td:nth-child(5) {
                display: none;
            }

            .memory-content {
                max-width: 150px;
                font-size: 0.75rem;
            }

            /* Modal - full screen on mobile */
            .modal-dialog {
                margin: 0;
                max-width: 100%;
                height: 100vh;
            }

            .modal-content {
                height: 100%;
                border-radius: 0;
            }

            /* Dropdown controls */
            .form-select-sm {
                font-size: 0.8rem;
                padding: 4px 8px;
            }

            /* Project select - smaller */
            .profile-select {
                min-width: 90px;
                font-size: 0.75rem;
                padding: 2px 24px 2px 8px;
            }

            /* Theme toggle - smaller */
            .theme-toggle {
                font-size: 0.8rem;
                padding: 3px 10px;
            }

            /* Footer - smaller text */
            footer {
                font-size: 0.75rem;
                padding: 15px;
                margin-top: 20px;
            }

            /* Graph controls - stack vertically on mobile */
            #graph-pane .card .row > div {
                margin-bottom: 10px;
            }

            /* Hide "Show All Memories" button text on mobile, icon only */
            #graph-status-filtered .btn span {
                display: none;
            }

            #graph-status-filtered .btn i::after {
                content: ' All';
            }
        }

        /* Landscape mobile (small height) */
        @media (max-height: 500px) and (orientation: landscape) {
            #graph-container {
                height: 250px !important;
                max-height: 250px;
            }

            .stat-card {
                padding: 8px !important;
            }

            .stat-value {
                font-size: 1rem;
            }

            .navbar {
                padding: 5px 0;
            }
        }

        /* Touch feedback for interactive elements */
        @media (hover: none) and (pointer: coarse) {
            /* This targets touch devices only */
            .btn:active,
            .nav-link:active,
            .sortable:active {
                opacity: 0.7;
                transform: scale(0.98);
            }

            /* Larger tap targets on touch devices */
            .btn {
                min-height: 44px;
                min-width: 44px;
            }

            .nav-tabs .nav-link {
                min-height: 44px;
            }

            /* Prevent accidental double-tap zoom on buttons */
            .btn,
            .nav-link,
            .form-control,
            .form-select {
                touch-action: manipulation;
            }
        }
