:root {
    --bg-color: #0f1115;
    --card-bg: rgba(30, 32, 40, 0.7);
    --card-border: rgba(255, 255, 255, 0.1);
    --accent-primary: #8b5cf6; /* Violet */
    --accent-secondary: #3b82f6; /* Blue */
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --success: #10b981;
    --font-main: 'Inter', sans-serif;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    padding-top: 48px; /* Space for connection status banner */
    min-height: 100vh;
    overflow-x: hidden;
    background-image:
        radial-gradient(circle at 10% 20%, rgba(139, 92, 246, 0.15) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(59, 130, 246, 0.15) 0%, transparent 20%);
}

html, body {
    width: 100%;
    overflow-x: hidden;
}

.container {
    max-width: 100%;
    margin: 0;
    padding: 40px 20px 40px 0;
    width: 100%;
    box-sizing: border-box;
}

.navbar {
    background: rgba(15, 17, 21, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--card-border);
    padding: 12px 20px 12px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-content {
    max-width: 100%;
    margin: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    padding: 0 20px 0 0;
    box-sizing: border-box;
}

.nav-left {
    flex: 1;
    min-width: 0;
}

.nav-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
    background: linear-gradient(to right, #fff, #9ca3af);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
    text-transform: uppercase;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.nav-status {
    padding: 6px 12px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--card-border);
    font-size: 0.8rem;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.visitor-stats {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.donation-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.2);
    padding: 4px 8px;
    border-radius: 8px;
}

.donation-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.donation-address-small {
    color: var(--accent-primary);
    font-size: 0.7rem;
    font-family: 'Courier New', monospace;
    user-select: all;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.copy-btn-small {
    background: rgba(139, 92, 246, 0.2);
    border: 1px solid rgba(139, 92, 246, 0.3);
    color: var(--accent-primary);
    padding: 2px 6px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.7rem;
    transition: all 0.2s;
    line-height: 1;
}

.copy-btn-small:hover {
    background: rgba(139, 92, 246, 0.3);
    transform: scale(1.05);
}

header {
    text-align: center;
    margin-bottom: 40px;
    position: relative;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-top: 10px;
}

.controls {
    display: flex;
    justify-content: center;
    margin-bottom: 40px;
}

.btn {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-main);
}

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

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

.list-section {
    margin-bottom: 40px;
}

.list-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
    text-align: center;
}

.launches-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    overflow: hidden;
    min-height: 50px;
}

#launches-with-mcap {
    border: 2px solid rgba(16, 185, 129, 0.3);
}

#launches-with-mcap:empty::before {
    content: "No tokens with market cap yet";
    display: block;
    padding: 40px;
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
}

#launches-all:empty::before {
    content: "No launches yet";
    display: block;
    padding: 40px;
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
}

.launch-item {
    background: var(--card-bg);
    border-bottom: 1px solid var(--card-border);
    padding: 16px 20px;
    backdrop-filter: blur(10px);
    transition: all 0.2s ease;
    position: relative;
}

.launch-item:last-child {
    border-bottom: none;
}

.launch-item:hover {
    background: rgba(30, 32, 40, 0.9);
    border-left: 3px solid var(--accent-primary);
}

.launch-item.new {
    animation: slideIn 0.5s ease-out, glow 2s infinite;
    border-left: 3px solid var(--success);
}

.item-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.item-left {
    flex: 1;
    min-width: 0;
}

.token-name-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.token-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.token-symbol {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
}

.new-badge {
    background: var(--success);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dead-badge {
    background: #6b7280;
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.launch-item.dead {
    opacity: 0.6;
    background: rgba(30, 32, 40, 0.5);
}

.launch-item.dead:hover {
    background: rgba(30, 32, 40, 0.7);
}

.item-details {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 0.85rem;
}

.separator {
    color: var(--text-secondary);
    opacity: 0.5;
}

.mcap {
    color: var(--success);
    font-weight: 600;
}

.time {
    color: var(--text-secondary);
}

.item-right {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.link-btn {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    transition: all 0.2s;
    white-space: nowrap;
}

.link-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.address-link {
    font-family: 'Courier New', monospace;
    color: var(--accent-secondary);
    text-decoration: none;
    font-size: 0.85rem;
}

.address-link:hover {
    text-decoration: underline;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.9;
        transform: scale(1.02);
    }
}

@keyframes glow {
    0% { box-shadow: 0 0 0 rgba(16, 185, 129, 0); }
    50% { box-shadow: 0 0 20px rgba(16, 185, 129, 0.2); }
    100% { box-shadow: 0 0 0 rgba(16, 185, 129, 0); }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #444;
}

/* Table Styles */
.table-container {
    overflow-x: auto;
    width: 100%;
    border: 1px solid var(--card-border);
    border-radius: 12px;
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    -webkit-overflow-scrolling: touch;
}

.table-container::-webkit-scrollbar {
    height: 8px;
}

.table-container::-webkit-scrollbar-track {
    background: rgba(30, 32, 40, 0.5);
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.launches-table {
    width: 100%;
    min-width: 800px;
    border-collapse: collapse;
    font-size: 0.875rem;
    table-layout: auto;
}

.launches-table thead {
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 2px solid var(--card-border);
}

.launches-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.launches-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.launches-table th.sortable:hover {
    background: rgba(139, 92, 246, 0.1);
}

.sort-arrow {
    color: var(--accent-primary);
    font-size: 0.75rem;
    margin-left: 4px;
    display: inline-block;
}

.launches-table tbody tr {
    border-bottom: 1px solid var(--card-border);
    transition: background 0.2s;
}

.launches-table tbody tr:hover {
    background: rgba(30, 32, 40, 0.7);
}

.launches-table tbody tr.dead {
    opacity: 0.6;
}

.launches-table td {
    padding: 12px 16px;
    vertical-align: middle;
}

.time-cell {
    min-width: 120px;
}

.time-display {
    font-weight: 500;
    color: var(--text-primary);
}

.time-ago {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.token-cell {
    min-width: 200px;
}

.mcap-cell {
    text-align: right;
    font-weight: 600;
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
}

.mcap-cell.has-mcap {
    color: var(--success);
}

.address-cell {
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
}

.links-cell {
    white-space: nowrap;
}

.launch-row.new {
    animation: slideIn 0.5s ease-out;
    border-left: 3px solid var(--success);
}

/* Factory layout - using flexbox so collapsed factories take minimal width */
.factories-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 20px;
    width: 100%;
    box-sizing: border-box;
    align-items: start;
}

/* Factory sections - consistent sizing */
.factory-section {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 200px;
    width: 100%;
}

/* When factory is collapsed, it becomes narrow but still maintains grid */
.factory-section.collapsed {
    grid-column: span 1;
    min-width: 200px;
    max-width: 200px;
    padding: 12px;
    cursor: pointer;
}

.factory-section.collapsed .factory-content {
    display: none;
}

.factory-section.collapsed .factory-title {
    font-size: 1rem;
    padding: 8px;
    padding-left: 35px;
    margin-bottom: 0;
}

/* Drag and drop styles */
.factory-section[draggable="true"] {
    cursor: grab;
}

.factory-section[draggable="true"]:active {
    cursor: grabbing;
}

.factory-section.dragging {
    opacity: 0.5;
    transform: scale(0.98);
    z-index: 1000;
}

.factory-section.drag-over {
    border: 2px dashed var(--accent-primary);
    background: rgba(139, 92, 246, 0.1);
}

.factory-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
}

@media (max-width: 1400px) {
    .factories-container {
        grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    }
}

@media (max-width: 1000px) {
    .factories-container {
        grid-template-columns: 1fr;
    }

    .factory-section.collapsed {
        min-width: 180px;
        max-width: 180px;
    }
}

@media (max-width: 1800px) {
    .factories-container {
        flex-wrap: wrap;
    }

    .factory-section {
        flex: 1 1 calc(50% - 10px);
        min-width: 350px;
    }
}

.factory-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
    transition: opacity 0.3s ease;
}

.factory-section.collapsed .factory-content {
    display: none;
}

.factory-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    padding: 10px 12px;
    padding-left: 45px; /* Space for drag handle */
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
    position: relative;
}

.factory-title:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Drag handle visual indicator */
.factory-title::before {
    content: '⋮⋮';
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 0.75rem;
    letter-spacing: -2px;
    opacity: 0.4;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.factory-title:hover::before {
    opacity: 0.8;
}

.factory-toggle {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: transform 0.2s;
}

.factory-toggle:hover {
    transform: scale(1.1);
}

.list-section {
    margin-bottom: 24px;
}

.list-title {
    font-size: 1.2rem;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.list-title:hover {
    background: rgba(30, 32, 40, 0.5);
}

.section-toggle {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: transform 0.2s;
}

.section-toggle:hover {
    transform: scale(1.1);
}

.toggle-icon {
    transition: transform 0.2s;
    display: inline-block;
}

.section-content {
    transition: opacity 0.2s, max-height 0.3s ease;
    overflow: hidden;
}

.factory-section .list-title {
    font-size: 1.2rem;
    margin-bottom: 12px;
}

/* Responsive: stack on smaller screens */
@media (max-width: 1400px) {
    .factories-container {
        grid-template-columns: 1fr;
    }

    .container {
        max-width: 100%;
        padding: 20px 16px 20px 0;
    }

    .nav-content {
        padding: 0 16px 0 0;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 16px 12px 16px 0;
    }

    .nav-content {
        padding: 0 12px 0 0;
    }

    .launches-table {
        min-width: 600px;
        font-size: 0.9rem;
    }

    .launches-table td,
    .launches-table th {
        padding: 8px 12px;
    }

    .factory-title {
        font-size: 1.2rem;
        padding: 12px;
    }

    .list-title {
        font-size: 1rem;
    }
}
