:root {
    --primary: #ef4444;
    /* Elmo Red */
    --primary-hover: #dc2626;
    --accent: #f59e0b;
    /* Elmo Orange */
    --bg: #0f172a;
    --card-bg: #1e293b;
    --text: #f8fafc;
    --text-light: #94a3b8;
    --border: #334155;
    --success: #10b981;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    padding: 2rem;
    line-height: 1.6;
}

.container {
    max-width: 900px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 3rem;
}

.elmo-logo {
    font-size: 4rem;
    margin-bottom: 0.5rem;
    display: inline-block;
}

h1 {
    font-size: 3rem;
    font-weight: 800;
    background: linear-gradient(to bottom, var(--primary), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 1.5rem;
    border: 1px solid var(--border);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
    margin-bottom: 2rem;
}

.input-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.chip-container {
    background: #0f172a;
    padding: 1rem;
    border-radius: 1rem;
    margin-bottom: 1.5rem;
    min-height: 60px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    border: 1px dashed var(--border);
}

.url-chip {
    background: var(--primary);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.url-chip span {
    cursor: pointer;
    font-weight: bold;
}

.secondary-btn {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
    padding: 0.5rem 1rem;
    border-radius: 0.75rem;
    font-size: 0.85rem;
    cursor: pointer;
    font-weight: 600;
}

.row {
    display: flex;
    gap: 1.5rem;
}

.input-group {
    flex: 1;
    margin-bottom: 1.5rem;
}

.label-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 0.5rem;
}

.label-row label {
    margin-bottom: 0;
}

label {
    color: var(--text-light);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    display: block;
}

input,
textarea {
    width: 100%;
    padding: 0.85rem;
    background: #0f172a;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    color: white;
    font-family: inherit;
}

/* Toggle Switch */
.toggle-group {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 2rem;
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #334155;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--primary);
}

input:checked+.slider:before {
    transform: translateX(20px);
}

.mission-actions {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
}

#start-btn {
    flex: 2;
    padding: 1.2rem;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border: none;
    border-radius: 1rem;
    color: white;
    font-size: 1.2rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.abort-btn {
    flex: 1;
    background: #334155;
    color: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.abort-btn:hover {
    background: #475569;
    border-color: var(--primary);
}

#start-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.5);
}

#start-btn:active {
    transform: translateY(1px) scale(0.98);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
    filter: brightness(0.9);
}

.log-container {
    background: #020617;
    height: 180px;
    overflow-y: auto;
    padding: 1rem;
    border-radius: 0.75rem;
    font-family: monospace;
    font-size: 0.8rem;
}

.results-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.result-item {
    background: #0f172a;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    overflow: hidden;
    /* Added to contain any overflow */
}

.result-info {
    flex: 1;
    min-width: 0;
    /* Forces flex child to shrink below content size */
}

.result-item h4 {
    font-size: 0.85rem;
    font-weight: 700;
    color: white;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.info-btn {
    width: 16px;
    height: 16px;
    background: #475569;
    color: white;
    border-radius: 50%;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: help;
    position: relative;
}

.info-btn:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 130%;
    left: 50%;
    transform: translateX(-50%);
    background: black;
    padding: 0.8rem;
    border-radius: 0.5rem;
    width: 200px;
    z-index: 100;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
}

.modal-content {
    background: var(--card-bg);
    margin: 5vh auto;
    width: 90%;
    max-width: 1000px;
    height: 85vh;
    border-radius: 1.5rem;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    animation: fadeIn 0.3s ease-out;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
}

.modal-body {
    padding: 2rem;
    overflow-y: auto;
    flex: 1;
}

.close-modal,
.close-preview {
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--text-light);
    transition: color 0.2s;
}

.close-modal:hover,
.close-preview:hover {
    color: white;
}

#save-batch-btn {
    width: 100%;
    margin-top: 1rem;
    padding: 0.8rem;
    border-radius: 0.75rem;
    background: var(--primary);
    border: none;
    color: white;
    font-weight: bold;
    cursor: pointer;
}

.preview-content {
    width: 80%;
    max-width: 900px;
}

pre {
    white-space: pre-wrap;
    font-size: 0.95rem;
    font-family: inherit;
    line-height: 1.6;
    color: #e2e8f0;
}

/* Success Celebration */
.success-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 2000;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.5s ease-out;
}

.success-circle {
    width: 300px;
    height: 300px;
    border-radius: 50%;
    overflow: hidden;
    border: 8px solid var(--primary);
    box-shadow: 0 0 50px var(--primary);
    margin-bottom: 2rem;
}

.success-circle img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.success-text {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--primary);
    text-shadow: 0 0 20px rgba(239, 68, 68, 0.8);
    text-align: center;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes scaleUp {
    from {
        transform: scale(0.5);
    }

    to {
        transform: scale(1);
    }
}

/* Pagination Styles */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.page-btn {
    padding: 6px 12px;
    background: #1e293b;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-light);
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.page-btn:hover {
    background: #334155;
    border-color: var(--primary);
}

.page-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Text Truncation and Mobile Adjustments */
.result-info {
    flex: 1;
    min-width: 0;
    /* Critical for truncation inside flex */
}

.result-item h4,
.result-item p {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    header h1 {
        font-size: 2rem;
    }

    .row {
        flex-direction: column;
        gap: 0;
    }

    .card {
        padding: 1.25rem;
    }

    .result-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .result-item div {
        width: 100%;
    }

    .result-item div:last-child {
        display: flex;
        justify-content: space-between;
    }

    .modal-content {
        width: 95% !important;
        margin: 5% auto;
    }

    .mission-actions {
        flex-direction: column;
    }
}

/* Mission Grouping Styles */
.mission-card {
    background: #0f172a;
    padding: 1.25rem;
    border-radius: 1rem;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.mission-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    background: #1e293b;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
}

.mission-card::after {
    content: 'View Details →';
    position: absolute;
    bottom: -20px;
    right: 20px;
    font-size: 10px;
    color: var(--primary);
    transition: all 0.3s;
    opacity: 0;
}

.mission-card:hover::after {
    bottom: 10px;
    opacity: 1;
}

.mission-info {
    flex: 1;
    min-width: 0;
}

.mission-name {
    font-weight: 700;
    font-size: 1rem;
    color: white;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mission-meta {
    font-size: 0.8rem;
    color: var(--text-light);
    display: flex;
    gap: 8px;
    align-items: center;
}

.mission-count {
    background: #334155;
    color: #f8fafc;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    border: 1px solid var(--border);
}

.mission-card:hover .mission-count {
    background: var(--primary);
    border-color: var(--primary);
}