/* ================================================
   SKU Processor Web — Styles
   Inspirado en la UI de migrar-peya2gestiondemenu
   ================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-page: #e5e7eb;
    --bg-workspace: #f9fafb;
    --bg-card: #ffffff;
    --border-color: #e5e7eb;
    --border-input: #d1d5db;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --orange-primary: #ea580c;
    --orange-hover: #c2410c;
    --orange-light: #ffedd5;
    --orange-ring: rgba(249, 115, 22, 0.3);
    --green-primary: #16a34a;
    --green-hover: #15803d;
    --red-bg: #fef2f2;
    --red-border: #fecaca;
    --red-text: #dc2626;
    --radius: 8px;
    --radius-sm: 4px;
    --shadow-card: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --transition: 0.2s ease-in-out;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-page);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* --- Layout Container --- */
.app-container {
    max-width: 540px;
    margin: 0 auto;
    padding: 40px 16px 60px;
}

/* --- Cards --- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-card);
}

/* --- Login Card (Estilo idéntico a LoginPage.tsx de migrar-peya2gestiondemenu) --- */
.login-card {
    max-width: 384px;
    margin: 60px auto 0;
    padding: 32px 24px;
    text-align: center;
}

.login-subtitle {
    font-size: 16px;
    font-weight: 700;
    color: #000000;
    line-height: 1.35;
    margin-bottom: 12px;
}

.brand-title {
    font-size: 30px;
    font-weight: 700;
    color: var(--orange-primary);
    letter-spacing: 0.05em;
    margin-bottom: 24px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.form-group {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.form-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    background: #ffffff;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:focus {
    border-color: #f97316;
    box-shadow: 0 0 0 3px var(--orange-ring);
}

.form-textarea {
    resize: vertical;
    font-family: inherit;
    line-height: 1.4;
}

.btn-login-submit {
    width: 100%;
    padding: 11px 16px;
    background: var(--orange-primary);
    border: none;
    border-radius: var(--radius-sm);
    color: #ffffff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: background-color var(--transition);
}

.btn-login-submit:hover {
    background: var(--orange-hover);
}

.btn-login-submit:disabled {
    background: #fdba74;
    cursor: not-allowed;
}

/* --- Top Header (Estilo DashboardPage.tsx) --- */
.top-header {
    margin-bottom: 24px;
}

.top-header-content {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
    padding-top: 8px;
}

.app-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.user-greeting {
    font-size: 14px;
    color: var(--text-secondary);
}

.user-greeting .user-name {
    font-weight: 500;
    color: #374151;
}

.session-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cluster-select {
    padding: 4px 8px;
    font-size: 12px;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-sm);
    background: #ffffff;
}

.btn-logout {
    font-size: 14px;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: color var(--transition);
    white-space: nowrap;
}

.btn-logout:hover {
    color: var(--text-primary);
}

/* --- Dropzones --- */
.card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.dropzone-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.dropzone {
    position: relative;
    border: 2px dashed var(--border-input);
    border-radius: var(--radius);
    padding: 24px 12px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: #fafafa;
    overflow: hidden;
}

.dropzone:hover {
    border-color: var(--orange-primary);
    background: var(--orange-light);
}

.dropzone.dragover {
    border-color: var(--orange-primary);
    background: var(--orange-light);
}

.dropzone.has-file {
    border-color: var(--green-primary);
    border-style: solid;
    background: #f0fdf4;
}

.dropzone-icon {
    font-size: 24px;
    margin-bottom: 6px;
    display: block;
}

.dropzone-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    display: block;
    margin-bottom: 2px;
}

.dropzone-hint {
    font-size: 11px;
    color: var(--text-secondary);
    display: block;
}

.dropzone-filename {
    font-size: 11px;
    font-weight: 600;
    color: var(--green-primary);
    margin-top: 6px;
    word-break: break-all;
    display: block;
}

.dropzone input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

/* --- Configuración Avanzada --- */
.settings-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
}

.settings-toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.settings-toggle-arrow {
    font-size: 11px;
    color: var(--text-secondary);
    transition: transform var(--transition);
}

.settings-toggle-arrow.open {
    transform: rotate(180deg);
}

.settings-content {
    display: none;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.settings-content.visible {
    display: block;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.slider-container input[type="range"] {
    flex: 1;
    accent-color: var(--orange-primary);
}

.slider-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--orange-primary);
    min-width: 40px;
    text-align: right;
}

.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.toggle-label {
    font-size: 13px;
    color: var(--text-primary);
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: #d1d5db;
    transition: var(--transition);
    border-radius: 22px;
}

.toggle-slider::before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: var(--transition);
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--orange-primary);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(18px);
}

/* --- Botón Procesar --- */
.btn-process {
    width: 100%;
    padding: 14px 20px;
    background: var(--orange-primary);
    border: none;
    border-radius: var(--radius);
    color: #ffffff;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.05em;
    cursor: pointer;
    margin-bottom: 20px;
    box-shadow: var(--shadow-card);
    transition: background-color var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-process:hover:not(:disabled) {
    background: var(--orange-hover);
}

.btn-process:disabled {
    background: #fdba74;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-process .btn-loading-text,
.btn-process .spinner {
    display: none;
}

.btn-process.loading .btn-text {
    display: none;
}

.btn-process.loading .btn-loading-text,
.btn-process.loading .spinner {
    display: inline-block;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- Progreso y Logs --- */
.progress-section {
    display: none;
}

.progress-section.visible {
    display: block;
}

.progress-bar-container {
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-bar {
    height: 100%;
    background: var(--orange-primary);
    width: 0%;
    transition: width var(--transition);
}

.progress-bar.indeterminate {
    width: 30%;
    animation: indeterminate 1.5s infinite ease-in-out;
}

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

.log-container {
    background: #1e293b;
    color: #f8fafc;
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 12px;
    line-height: 1.6;
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 16px;
}

.log-entry {
    display: flex;
    gap: 8px;
}

.log-entry .time {
    color: #64748b;
    user-select: none;
}

.log-entry.success { color: #4ade80; }
.log-entry.error { color: #f87171; }
.log-entry.warning { color: #fbbf24; }

/* --- Estadísticas y Descarga Integrados --- */
.progress-results {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

.stat-card {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px;
    text-align: center;
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--orange-primary);
}

.stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.btn-download {
    width: 100%;
    padding: 12px 16px;
    background: var(--green-primary);
    border: none;
    border-radius: var(--radius-sm);
    color: #ffffff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color var(--transition);
}

.btn-download:hover {
    background: var(--green-hover);
}

.token-status.error {
    font-size: 13px;
    color: var(--red-text);
    background: var(--red-bg);
    border: 1px solid var(--red-border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    margin-top: 4px;
}

/* --- Responsive --- */
@media (max-width: 480px) {
    .app-container {
        padding: 20px 12px;
    }

    .dropzone-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
}
