/* =============================================
   Madruga Thumbnail Tester — Design System
   ============================================= */

:root {
    --yellow: #f5e642;
    --yellow-soft: #faf3a0;
    --black: #0f0f0f;
    --white: #ffffff;
    --gray-100: #f5f5f5;
    --gray-200: #e5e5e5;
    --gray-400: #9ca3af;
    --gray-600: #4b5563;
    --gray-800: #1f1f1f;
    --radius: 8px;
    --radius-sm: 4px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --sidebar-width: 380px;
    --transition: 0.15s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background: var(--gray-100);
    color: var(--black);
    line-height: 1.5;
    min-height: 100vh;
}

/* --- Header --- */
.header {
    background: var(--black);
    color: var(--white);
    padding: 1.25rem 2rem;
    border-bottom: 3px solid var(--yellow);
}

.header__brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header__title {
    font-size: 1.375rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.header__subtitle {
    color: var(--gray-400);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.badge {
    background: var(--yellow);
    color: var(--black);
    font-size: 0.625rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    letter-spacing: 0.05em;
}

/* --- Layout --- */
.main {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    gap: 0;
    min-height: calc(100vh - 80px);
}

.sidebar {
    background: var(--white);
    border-right: 1px solid var(--gray-200);
    padding: 1.5rem;
    overflow-y: auto;
    max-height: calc(100vh - 80px);
}

.content {
    padding: 1.5rem;
    overflow-y: auto;
    max-height: calc(100vh - 80px);
}

/* --- Panels --- */
.panel {
    margin-bottom: 1.5rem;
}

.panel__title {
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--gray-600);
    margin-bottom: 1rem;
}

.panel--simulator {
    margin-bottom: 1rem;
}

/* --- Forms --- */
.form-group {
    margin-bottom: 0.875rem;
}

.form-group label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    margin-bottom: 0.35rem;
    color: var(--gray-600);
}

.form-group input[type="text"],
.form-group input[type="url"] {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.875rem;
    transition: border-color var(--transition);
}

.form-group input:focus {
    outline: none;
    border-color: var(--black);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.required { color: #dc2626; }
.optional { color: var(--gray-400); font-weight: 400; font-size: 0.75rem; }
.hint { font-size: 0.75rem; color: var(--gray-400); margin-top: 0.5rem; }
.hint--status { color: var(--gray-600); font-style: italic; }

/* --- Thumbnail Upload --- */
.thumb-uploads {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.thumb-upload__label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    margin-bottom: 0.35rem;
    color: var(--gray-600);
}

.thumb-upload__input {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
}

.thumb-upload__zone {
    aspect-ratio: 16 / 9;
    border: 2px dashed var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color var(--transition);
    position: relative;
}

.thumb-upload__zone:hover,
.thumb-upload__zone.dragover {
    border-color: var(--yellow);
    background: var(--yellow-soft);
}

.thumb-upload__trigger {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    min-height: 120px;
    color: var(--gray-400);
    font-size: 0.75rem;
    gap: 0.25rem;
    cursor: pointer;
    margin: 0;
}

.thumb-upload__hint {
    font-size: 0.6875rem;
}

.thumb-upload__trigger img,
.thumb-upload__zone img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    display: block;
}

.thumb-upload__zone.has-image .thumb-upload__trigger {
    display: block;
    padding: 0;
    min-height: 0;
}

.thumb-upload__zone.has-image .thumb-upload__trigger span { display: none; }

.thumb-upload__remove {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0,0,0,0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 14px;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3;
    pointer-events: auto;
}

.thumb-upload__zone.has-image .thumb-upload__remove { display: flex; }

/* --- Avatar --- */
.avatar-upload {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.avatar-preview {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--gray-200);
}

/* --- Buttons --- */
.btn {
    font-family: var(--font);
    font-size: 0.8125rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn--primary {
    background: var(--black);
    color: var(--white);
}

.btn--primary:hover:not(:disabled) { background: var(--gray-800); }

.btn--accent {
    background: var(--yellow);
    color: var(--black);
    font-weight: 600;
}

.btn--accent:hover:not(:disabled) { background: #e6d63b; }

.btn--ghost {
    background: transparent;
    border-color: var(--gray-200);
    color: var(--gray-600);
}

.btn--ghost:hover:not(:disabled) {
    border-color: var(--black);
    color: var(--black);
}

.btn--sm { padding: 0.35rem 0.75rem; font-size: 0.75rem; }

/* --- Variant selector --- */
.variant-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.875rem;
}

.variant-selector__label {
    font-size: 0.75rem;
    color: var(--gray-600);
}

.variant-btns {
    display: flex;
    gap: 0.25rem;
}

.variant-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--gray-200);
    background: var(--white);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.variant-btn.active {
    background: var(--yellow);
    border-color: var(--black);
    color: var(--black);
}

.variant-btn:hover:not(.active) { border-color: var(--gray-600); }

.hidden { display: none !important; }

/* --- Add video --- */
.add-video {
    display: flex;
    gap: 0.5rem;
}

.add-video input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.875rem;
}

.add-video input:focus {
    outline: none;
    border-color: var(--black);
}

/* --- Competitor list --- */
.competitor-list {
    list-style: none;
    margin-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.competitor-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    background: var(--gray-100);
    border-radius: var(--radius-sm);
    cursor: grab;
    transition: background var(--transition);
}

.competitor-item:active { cursor: grabbing; }
.competitor-item.dragging { opacity: 0.5; }
.competitor-item.drag-over { border-top: 2px solid var(--yellow); }

.competitor-item__thumb {
    width: 80px;
    aspect-ratio: 16/9;
    object-fit: cover;
    border-radius: 3px;
    flex-shrink: 0;
}

.competitor-item__info {
    flex: 1;
    min-width: 0;
}

.competitor-item__title {
    font-size: 0.8125rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.competitor-item__channel {
    font-size: 0.75rem;
    color: var(--gray-400);
}

.competitor-item__remove {
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    font-size: 1.125rem;
    padding: 0.25rem;
    line-height: 1;
}

.competitor-item__remove:hover { color: #dc2626; }

.competitor-item__loading {
    padding: 0.75rem;
    text-align: center;
    color: var(--gray-400);
    font-size: 0.8125rem;
}

.competitor-item__error {
    padding: 0.75rem;
    background: #fef2f2;
    color: #dc2626;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
}

/* --- Simulator --- */
.simulator-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.simulator-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.view-toggle--theme {
    margin-left: 0.25rem;
}

.view-toggle {
    display: flex;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.view-toggle__btn {
    padding: 0.35rem 0.875rem;
    border: none;
    background: var(--white);
    font-family: var(--font);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    color: var(--gray-600);
}

.view-toggle__btn.active {
    background: var(--black);
    color: var(--white);
}

.simulator-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--gray-200);
}

.simulator-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.checkbox-label, .radio-label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8125rem;
    color: var(--gray-600);
    cursor: pointer;
}

.simulator-viewport {
    border-radius: var(--radius);
    min-height: 400px;
    overflow: hidden;
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* YouTube — tema escuro (padrão) */
.simulator-viewport--dark {
    --yt-bg: #0f0f0f;
    --yt-text: #f1f1f1;
    --yt-text-secondary: #aaaaaa;
    --yt-thumb-bg: #272727;
    background: var(--yt-bg);
}

/* YouTube — tema claro */
.simulator-viewport--light {
    --yt-bg: #ffffff;
    --yt-text: #0f0f0f;
    --yt-text-secondary: #606060;
    --yt-thumb-bg: #e5e5e5;
    background: var(--yt-bg);
    border: 1px solid var(--gray-200);
}

.feed-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    color: var(--yt-text-secondary);
    font-size: 0.875rem;
    padding: 2rem;
    text-align: center;
}

/* --- YouTube Feed Desktop --- */
.feed-container--desktop {
    padding: 1.5rem;
}

.yt-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem 1rem;
}

.yt-card {
    cursor: default;
}

.yt-card__thumb-wrap {
    position: relative;
    aspect-ratio: 16/9;
    border-radius: 12px;
    overflow: hidden;
    background: var(--yt-thumb-bg);
    margin-bottom: 0.75rem;
}

.yt-card__thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.yt-card__duration {
    position: absolute;
    bottom: 6px;
    right: 6px;
    background: rgba(0,0,0,0.8);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 2px 4px;
    border-radius: 4px;
    letter-spacing: 0.02em;
}

.yt-card__badge {
    position: absolute;
    top: 6px;
    left: 6px;
    background: var(--yellow);
    color: var(--black);
    font-size: 0.625rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 3px;
    letter-spacing: 0.04em;
}

.yt-card__meta {
    display: flex;
    gap: 0.75rem;
}

.yt-card__avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--yt-thumb-bg);
}

.yt-card__details { min-width: 0; }

.yt-card__title {
    color: var(--yt-text);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 0.25rem;
}

.yt-card__channel {
    color: var(--yt-text-secondary);
    font-size: 0.8125rem;
}

.yt-card__stats {
    color: var(--yt-text-secondary);
    font-size: 0.8125rem;
}

/* --- Mobile Feed --- */
.feed-container--mobile {
    display: flex;
    justify-content: center;
    padding: 2rem 1rem;
}

.mobile-frame {
    width: 375px;
    max-width: 100%;
    background: #000;
    border-radius: 32px;
    padding: 12px;
    box-shadow: 0 0 0 2px #333;
}

.mobile-frame__screen {
    background: var(--yt-bg);
    border-radius: 24px;
    overflow-y: auto;
    max-height: 700px;
    padding: 0.5rem 0;
}

.yt-mobile-card {
    margin-bottom: 1.25rem;
}

.yt-mobile-card__thumb-wrap {
    position: relative;
    aspect-ratio: 16/9;
    background: var(--yt-thumb-bg);
}

.yt-mobile-card__thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.yt-mobile-card__duration {
    position: absolute;
    bottom: 6px;
    right: 6px;
    background: rgba(0,0,0,0.8);
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 500;
    padding: 2px 4px;
    border-radius: 3px;
}

.yt-mobile-card__badge {
    position: absolute;
    top: 6px;
    left: 6px;
    background: var(--yellow);
    color: var(--black);
    font-size: 0.5625rem;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 3px;
}

.yt-mobile-card__meta {
    display: flex;
    gap: 0.625rem;
    padding: 0.625rem 0.75rem;
}

.yt-mobile-card__avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.yt-mobile-card__title {
    color: var(--yt-text);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.yt-mobile-card__channel,
.yt-mobile-card__stats {
    color: var(--yt-text-secondary);
    font-size: 0.75rem;
}

/* --- Analysis --- */
.analysis-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.analysis-mode {
    display: flex;
    gap: 1rem;
}

.analysis-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.analysis-loading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.5rem;
    color: var(--gray-600);
    font-size: 0.875rem;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--gray-200);
    border-top-color: var(--black);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.analysis-error {
    padding: 1rem;
    background: #fef2f2;
    color: #dc2626;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

/* Score bars */
.score-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.score-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.score-item__header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.score-item__label {
    font-size: 0.8125rem;
    color: var(--gray-600);
}

.score-item__value {
    font-size: 1.125rem;
    font-weight: 700;
}

.score-item__bar {
    height: 4px;
    background: var(--gray-200);
    border-radius: 2px;
    overflow: hidden;
}

.score-item__fill {
    height: 100%;
    background: var(--yellow);
    border-radius: 2px;
    transition: width 0.6s ease;
}

.score-tooltip {
    cursor: help;
    border-bottom: 1px dotted var(--gray-400);
}

.clutter-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.clutter-badge--low { background: #dcfce7; color: #166534; }
.clutter-badge--medium { background: #fef9c3; color: #854d0e; }
.clutter-badge--high { background: #fee2e2; color: #991b1b; }

.feed-rank {
    background: var(--black);
    color: var(--white);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

.feed-rank strong { color: var(--yellow); }

.feedback-section {
    margin-bottom: 1.25rem;
}

.feedback-section h3 {
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gray-600);
    margin-bottom: 0.5rem;
}

.feedback-section ul {
    list-style: none;
    padding: 0;
}

.feedback-section li {
    font-size: 0.875rem;
    padding: 0.35rem 0;
    padding-left: 1rem;
    position: relative;
}

.feedback-section li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--yellow);
    font-weight: bold;
}

.feedback-recommendation {
    background: var(--yellow-soft);
    border-left: 3px solid var(--yellow);
    padding: 1rem;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 0.875rem;
    line-height: 1.6;
}

/* Compare table */
.compare-table-wrap {
    overflow-x: auto;
    margin-bottom: 1.5rem;
}

.compare-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.compare-table th,
.compare-table td {
    padding: 0.5rem 0.75rem;
    text-align: center;
    border-bottom: 1px solid var(--gray-200);
}

.compare-table th {
    background: var(--gray-100);
    font-weight: 600;
    text-align: left;
}

.compare-table th:not(:first-child),
.compare-table td:not(:first-child) {
    text-align: center;
}

.compare-table .winner {
    background: var(--yellow-soft);
    font-weight: 700;
}

.compare-winner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.compare-winner__trophy { font-size: 1.25rem; }

/* --- Responsive --- */
@media (max-width: 1200px) {
    .main {
        grid-template-columns: 1fr;
    }

    .sidebar {
        max-height: none;
        border-right: none;
        border-bottom: 1px solid var(--gray-200);
    }

    .content {
        max-height: none;
    }
}

@media (max-width: 640px) {
    .header { padding: 1rem; }
    .sidebar, .content { padding: 1rem; }
    .form-row { grid-template-columns: 1fr; }
    .add-video { flex-direction: column; }
    .simulator-toolbar { flex-direction: column; align-items: flex-start; }
}
