:root {
    --bg-dark: #020617;
    /* Midnight Blue */
    --bg-light: #f8fafc;
    --card-bg: #ffffff;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --sidebar-width: 260px;
    --accent-blue: #60a5fa;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-light);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

.dashboard-container {
    display: flex;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-dark);
    color: white;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
}

.logo-area {
    margin-bottom: 3rem;
}

.logo-area h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.logo-area p {
    font-size: 0.8rem;
    opacity: 0.6;
}

.nav-menu {
    flex: 1;
}

.nav-item {
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    opacity: 0.8;
}

.nav-item:hover,
.nav-item.active {
    background-color: rgba(255, 255, 255, 0.1);
    opacity: 1;
}

.sidebar-footer {
    font-size: 0.8rem;
    opacity: 0.4;
    text-align: center;
}

/* Last-update badge */
@keyframes update-breathe {
    0%, 100% { opacity: 0.55; }
    50%       { opacity: 1;    }
}

@keyframes dot-ping {
    0%, 100% { opacity: 1;   transform: scale(1);   }
    50%      { opacity: 0.3; transform: scale(0.65); }
}

.update-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 0.75rem;
    font-size: 0.7rem;
    animation: update-breathe 3s ease-in-out infinite;
    color: rgba(255,255,255,0.7);
}

.update-badge .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #34d399;
    flex-shrink: 0;
    animation: dot-ping 3s ease-in-out infinite;
    box-shadow: 0 0 5px #34d399;
}

.update-badge a {
    color: #60a5fa;
    text-decoration: underline;
    text-underline-offset: 2px;
    font-weight: 600;
    cursor: pointer;
}

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    position: relative;
}

.view-section {
    display: none;
    max-width: 1200px;
    margin: 0 auto;
}

.view-section.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.top-bar h2 {
    font-size: 1.8rem;
    font-weight: 600;
}

.controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

/* Cards & Grid */
.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
}

.card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.card-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

input[type="text"],
input[type="number"],
textarea {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.95rem;
}

textarea {
    min-height: 100px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
}

.input-with-btn {
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    padding: 0 1rem;
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
}

.action-btn:hover {
    background: #e2e8f0;
}

.primary-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

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

.full-width {
    width: 100%;
}

/* Toggles */
.toggle-switch {
    background: var(--bg-light);
    padding: 0.25rem;
    border-radius: 6px;
    display: flex;
}

.toggle-btn {
    border: none;
    background: none;
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 4px;
    color: var(--text-muted);
}

.toggle-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.ref-content {
    display: none;
}

.ref-content.active {
    display: block;
}

/* Upload */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s;
}

.upload-area:hover {
    border-color: var(--primary);
}

.upload-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.link-text {
    color: var(--primary);
    text-decoration: underline;
    cursor: pointer;
}

.file-list {
    margin-top: 1rem;
    text-align: left;
    font-size: 0.9rem;
}

/* Results */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    text-align: center;
}

.stat-card .label {
    display: block;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card .value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-main);
}

.full-width-card {
    grid-column: 1 / -1;
}

.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th,
td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--bg-light);
    font-weight: 600;
    color: var(--text-muted);
}

td {
    vertical-align: middle;
}

.seq-font {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
}

/* Badges */
.badge {
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-wt {
    background: #e0f2fe;
    color: #0284c7;
}

.badge-del {
    background: #fee2e2;
    color: #dc2626;
}

.badge-ins {
    background: #dcfce7;
    color: #16a34a;
}

.badge-frame-in {
    background: #f3e8ff;
    color: #9333ea;
}

.badge-frame-out {
    background: #ffedd5;
    color: #ea580c;
}

.hidden {
    display: none;
}

/* Loader & Progress */
.loader {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.progress-bar-container {
    width: 100%;
    max-width: 400px;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    margin: 0 auto 1rem;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.2s;
}

.status-msg {
    margin-top: 0.5rem;
    font-size: 0.85rem;
}

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

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

/* Clone Grid & Cards */
#clones-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}

.clone-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.clone-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.clone-card.selected {
    border-color: var(--primary);
    background-color: #eff6ff;
    /* Light blue tint */
    box-shadow: 0 0 0 2px var(--primary-hover);
}

.clone-card h4 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    word-break: break-all;
    /* Handle long filenames */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.clone-card canvas {
    max-width: 100px;
    max-height: 100px;
    margin-bottom: 0.5rem;
}

.clone-card .mini-stat {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* V2 Sequence Highlighting */
.seq-del {
    background-color: #f1f5f9;
    color: #94a3b8;
    font-weight: 700;
    letter-spacing: 1px;
}

.seq-ki {
    background-color: #fef08a;
    /* Yellow-200 */
    color: #854d0e;
    /* Yellow-800 */
    font-weight: 700;
}

.seq-snp {
    background-color: #fef08a;
    /* Yellow-200, same as KI per request */
    color: #854d0e;
    /* Yellow-800 */
    font-weight: 700;
}

.seq-pad {
    opacity: 0.2;
}

/* Updated for JS-based truncation */
.seq-pair {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2px;
    /* Remove fixed width and visible overflow handling so JS provides content */
    width: auto;
    overflow: visible;
    white-space: pre;
}

.seq-gap-ins {
    color: #94a3b8;
    /* Slate 400 */
    opacity: 1.0;
    font-weight: normal;
}

.seq-mh {
    background-color: #dbeafe;
    /* Light Blue/Purple */
    text-decoration: underline;
    text-decoration-color: #7c3aed;
    /* Purple */
    text-decoration-thickness: 2px;
}

/* Compact Table for Clones Summary */
.compact-table th,
.compact-table td {
    padding: 0.5rem 0.75rem;
    /* Reduced padding */
    font-size: 0.85rem;
    /* Smaller font */
}

.compact-table th {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Custom summary marker handling */
details>summary {
    list-style: none;
    outline: none;
}

details>summary::-webkit-details-marker {
    display: none;
}

/* --- Pulse Animation for Info Button --- */
@keyframes pulse-ring {
    0% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7);
    }

    70% {
        box-shadow: 0 0 0 6px rgba(59, 130, 246, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
    }
}

#info-btn {
    animation: pulse-ring 2s infinite;
    border-radius: 50%;
}

#info-btn:hover {
    animation: none;
    transform: scale(1.1);
}

/* Tooltip Functionality */
.tooltip-container .tooltip-content {
    display: block;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    /* Prevent interference */
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.tooltip-container:hover .tooltip-content {
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 1000 !important;
}

/* Mini-Map visualizer */
.mini-map-container {
    margin-top: 1rem;
    padding: 1rem;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

.mini-map-track {
    height: 14px;
    background: #cbd5e1;
    border-radius: 4px;
    position: relative;
    margin: 24px 0 12px;
    border: 1px solid #94a3b8;
}

.mini-map-window {
    position: absolute;
    height: 100%;
    background: rgba(59, 130, 246, 0.4) !important;
    /* Primary Blue */
    border-left: 2px solid var(--primary);
    border-right: 2px solid var(--primary);
    z-index: 2;
}

.mini-map-be {
    position: absolute;
    height: 100%;
    background: rgba(139, 92, 246, 0.4) !important;
    /* Purple */
    border-left: 2px solid #8b5cf6;
    border-right: 2px solid #8b5cf6;
    z-index: 3;
}

.mini-map-marker {
    position: absolute;
    top: -15px;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    transform: translateX(-50%);
}