:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-dark: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #10b981;
    --danger: #ef4444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    background-image: 
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(16, 185, 129, 0.1) 0px, transparent 50%);
    min-height: 100vh;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    margin-bottom: 3rem;
    text-align: center;
}

h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, #818cf8, #34d399);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    margin-top: 1rem;
}

.header-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.2s;
    border-bottom: 1px solid transparent;
}

.header-link:hover {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.version-badge {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    padding: 0.2rem 0.6rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    font-weight: 800;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.column {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-width: 0;
}

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

.grid-stack {
    margin-bottom: 2rem;
}

.grid-stack-item-content {
    background: transparent !important;
    overflow: visible !important;
    inset: 0 !important;
}

.card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 1.5rem;
    padding: 1.5rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: transform 0.2s, border-color 0.2s;
    overflow: hidden;
}

.grid-stack-placeholder > .grid-stack-item-content {
    background: rgba(129, 140, 248, 0.05) !important;
    border: 2px dashed rgba(129, 140, 248, 0.2) !important;
    border-radius: 1.5rem !important;
}

.drag-handle {
    user-select: none;
    cursor: move;
    opacity: 0.3;
    transition: opacity 0.2s;
}
.drag-handle:hover {
    opacity: 0.8;
}

.card:hover {
    border-color: rgba(99, 102, 241, 0.3);
}

.card h2 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text-main);
}

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

label {
    display: block;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

input, textarea, select {
    width: 100%;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    color: white;
    outline: none;
    transition: border-color 0.2s;
}

input:focus, textarea:focus {
    border-color: var(--primary);
}

button {
    cursor: pointer;
    border: none;
    border-radius: 0.75rem;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.queue-list {
    margin-top: 1rem;
    max-height: 400px;
    overflow-y: auto;
}

.queue-item {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 0.75rem;
    padding: 1rem;
    margin-bottom: 0.75rem;
    border-left: 4px solid var(--primary);
}

.queue-item.downloading {
    border-left-color: var(--accent);
    background: rgba(16, 185, 129, 0.05);
}

.queue-item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.filename {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.group-tag {
    font-size: 0.7rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 0.1rem 0.4rem;
    border-radius: 0.4rem;
    color: var(--text-muted);
}

.progress-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

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

.status-badge {
    padding: 0.2rem 0.6rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.loading-bar-container {
    width: 100%;
    height: 4px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
    margin-bottom: 1rem;
    overflow: hidden;
    display: none; /* Escondido por padrão */
}

.loading-bar-fill {
    height: 100%;
    width: 30%;
    background: var(--primary);
    box-shadow: 0 0 10px var(--primary);
    border-radius: 2px;
    animation: loading-shimmer 1.5s infinite ease-in-out;
}

@keyframes loading-shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(400%); }
}

.bib-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0.75rem 0.6rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    font-size: 0.8rem;
    line-height: 1.4;
    gap: 1rem;
}

.bib-item-text {
    flex: 1;
    word-break: break-word;
    color: var(--text-main);
}

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

.bib-tag {
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-weight: 700;
    text-transform: uppercase;
}

.tag-waiting { background: #4b5563; color: #f3f4f6; }
.tag-searching { 
    background: #ca8a04; color: #fefce8; 
    animation: tag-pulse 1.5s infinite;
}
.tag-downloading { 
    background: #2563eb; color: #eff6ff; 
    animation: tag-pulse 1.5s infinite;
}

@keyframes tag-pulse {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.05); }
    100% { opacity: 1; transform: scale(1); }
}
.tag-done { background: #059669; color: #ecfdf5; }
.tag-error { background: #dc2626; color: #fef2f2; }

.scroll-area {
    overflow-y: auto;
    background: rgba(0,0,0,0.2);
    resize: vertical;
    min-height: 80px;
}

.logs {
    background: #000;
    border-radius: 1rem;
    padding: 1rem;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 0.8rem;
    color: #10b981;
    height: 200px;
    overflow-y: auto;
    margin-top: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.top-groups {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.group-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 0.75rem;
    border: 1px solid transparent;
    cursor: pointer;
}

.group-item:hover {
    border-color: rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
}

.group-info {
    display: flex;
    flex-direction: column;
}

.group-name {
    font-size: 0.9rem;
    font-weight: 600;
}

.group-count {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    visibility: hidden;
}

.login-card {
    background: var(--bg-dark);
    border: 1px solid var(--primary);
    padding: 2rem;
    border-radius: 1.5rem;
    width: 400px;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.loading-dots::after {
    content: '...';
    animation: pulse 1.5s infinite;
}

@media (max-width: 1024px) {
    .container {
        padding: 1rem;
    }

    header {
        margin-bottom: 1.5rem;
    }

    h1 {
        font-size: 2.1rem;
    }

    .header-links {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .grid-stack {
        margin-bottom: 1rem;
    }

    .card {
        padding: 1rem;
        border-radius: 1rem;
    }

    .drag-handle {
        display: none;
    }

    .grid-stack-item-content,
    .grid-stack-item-content .card {
        height: auto !important;
    }

    .grid-stack-item-content .card h2 {
        font-size: 1rem;
    }
}

@media (max-width: 640px) {
    .container {
        padding: 0.75rem;
    }

    h1 {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 0.95rem;
    }

    .header-link,
    .version-badge {
        font-size: 0.72rem;
    }

    button,
    input,
    textarea,
    select {
        font-size: 0.92rem;
    }

    .bib-item {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .group-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .login-card {
        width: min(92vw, 400px);
        padding: 1.25rem;
    }
}
