:root {
    --primary: #0742ab;
    --primary-hover: #052f7a;
    --secondary: #10b981;
    --bg: #f8fafc;
    --surface: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --danger: #ef4444;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.05);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

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

.top-bar {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: white;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
}
.back-link:hover { background: #f1f5f9; color: var(--text); }
.back-link i { width: 16px; height: 16px; }

.title-block h1 {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1.1;
}
.title-block p {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

main {
    display: grid;
    gap: 1.5rem;
}

.form-card, .preview-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.85rem;
    padding: 1.75rem;
    box-shadow: var(--shadow-sm);
}

.form-card h2, .preview-card h2 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
}

.hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
}

.url-input {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1rem;
}
.url-input label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}
.url-input .optional {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.8rem;
}
.url-input input {
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.9rem;
    font-family: inherit;
    background: white;
    transition: border 0.2s, box-shadow 0.2s;
}
.url-input input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(7, 66, 171, 0.1);
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1.25rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 0.5rem;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary i { width: 16px; height: 16px; }

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.85rem;
    background: white;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}
.btn-secondary:hover { background: #f1f5f9; }
.btn-secondary i { width: 14px; height: 14px; }

.error-msg {
    margin-top: 1rem;
    padding: 0.7rem 0.85rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    border-radius: 0.5rem;
    font-size: 0.85rem;
}

.drive-status {
    margin-top: 0.5rem;
    padding: 0.55rem 0.8rem;
    border-radius: 0.4rem;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.drive-status.ok {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #065f46;
}
.drive-status.error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}
.drive-status.checking {
    background: #f1f5f9;
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.upload-section {
    margin-top: 2rem;
    padding: 1.25rem;
    border: 1px dashed var(--border);
    border-radius: 0.6rem;
    background: #fafbfc;
}
.upload-section h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
}
.upload-section .hint {
    margin-bottom: 1rem;
}
.btn-upload {
    background: #dc2626 !important;
    font-size: 0.95rem !important;
    padding: 0.8rem 1.5rem !important;
}
.btn-upload:hover:not(:disabled) { background: #b91c1c !important; }
.btn-upload:disabled { background: #cbd5e1 !important; cursor: not-allowed; }

.upload-status {
    margin-top: 1rem;
    padding: 0.85rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.9rem;
}
.upload-status.uploading {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
}
.upload-status.success {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #065f46;
}
.upload-status.success a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: underline;
}
.upload-status.error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

/* Editor de recortes ----------------------------------------------------- */
#clip-editor-section { margin-top: 1.5rem; }

.clip-uploader {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
}

.clip-drop {
    flex: 1;
    min-width: 280px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 1.5rem;
    border: 2px dashed var(--border);
    border-radius: 0.6rem;
    background: #fafbfc;
    cursor: pointer;
    transition: border 0.2s, background 0.2s;
}
.clip-drop:hover { border-color: var(--primary); background: #f1f5f9; }
.clip-drop i { width: 32px; height: 32px; color: var(--primary); }
.clip-drop-text { font-weight: 600; font-size: 0.95rem; }
.clip-drop-hint { font-size: 0.8rem; color: var(--text-muted); }
.clip-drop.has-file {
    background: #ecfdf5;
    border-color: #34d399;
    border-style: solid;
}
.clip-drop.has-file i { color: var(--secondary); }

.btn-edit-clip { background: var(--primary) !important; padding: 0.8rem 1.5rem !important; }
.btn-edit-clip:disabled { background: #cbd5e1 !important; cursor: not-allowed; }

.clip-result {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}
.clip-result h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 0.85rem; }
.clip-result video {
    width: 100%;
    max-width: 400px;
    border-radius: 0.5rem;
    background: black;
    display: block;
    margin-bottom: 0.85rem;
}

.titulos-edit {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 0.6rem;
    padding: 1rem 1.25rem 1.25rem;
    margin-top: 1.25rem;
    margin-bottom: 1.25rem;
}
.titulos-edit h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
}
.titulos-edit .hint {
    margin-bottom: 1rem;
}
.titulos-edit .url-input { margin-bottom: 0.6rem; }
.titulos-edit .url-input:last-child { margin-bottom: 0; }

.titulo-section { margin-bottom: 1.25rem; }
.titulo-section:last-child { margin-bottom: 0; }
.titulo-section h4 {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.5rem;
}
.titulo-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem;
}
.titulo-pair .url-input { margin-bottom: 0; }
@media (max-width: 768px) {
    .titulo-pair { grid-template-columns: 1fr; gap: 0.5rem; }
}

.portada-wrapper.regenerating img,
.reel-wrapper.regenerating img {
    opacity: 0.4;
    transition: opacity 0.2s;
}

.reels-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem;
    margin-top: 0.5rem;
}
.reel-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}
.reel-wrapper {
    width: 100%;
    background: #f1f5f9;
    border-radius: 0.5rem;
    overflow: hidden;
}
.reel-wrapper img {
    width: 100%;
    height: auto;
    display: block;
}
.reel-item .btn-secondary {
    width: 100%;
    justify-content: center;
}

.preview-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 2rem;
}

.preview-portada h3,
.preview-text h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.6rem;
    color: var(--text);
}

.portada-wrapper {
    background: #f1f5f9;
    border-radius: 0.5rem;
    overflow: hidden;
    margin-bottom: 0.85rem;
}
.portada-wrapper img {
    width: 100%;
    height: auto;
    display: block;
}

.field-group {
    margin-bottom: 1.25rem;
}
.field-group label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
}
.field-group textarea {
    width: 100%;
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.85rem;
    font-family: inherit;
    line-height: 1.5;
    resize: vertical;
    background: white;
}
.field-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(7, 66, 171, 0.1);
}

.btn-copy {
    background: none;
    border: 1px solid var(--border);
    border-radius: 0.4rem;
    padding: 0.3rem;
    cursor: pointer;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.btn-copy:hover { background: #f1f5f9; color: var(--text); }
.btn-copy i { width: 14px; height: 14px; }
.btn-copy.copied {
    background: #ecfdf5;
    color: var(--secondary);
    border-color: #a7f3d0;
}

.hidden { display: none !important; }

@media (max-width: 768px) {
    .container { padding: 1rem; }
    .preview-grid { grid-template-columns: 1fr; gap: 1.5rem; }
    .title-block h1 { font-size: 1.3rem; }
}
