/**
 * Shared Design System - shadcn-inspired minimalist theme
 * jcom.es Keywords Management System
 */

/* ========== CSS Variables ========== */
:root {
    /* Colors - Neutral palette */
    --background: #ffffff;
    --foreground: #0a0a0a;
    --card: #ffffff;
    --card-foreground: #0a0a0a;
    --popover: #ffffff;
    --popover-foreground: #0a0a0a;
    --primary: #171717;
    --primary-foreground: #fafafa;
    --secondary: #f5f5f5;
    --secondary-foreground: #171717;
    --muted: #f5f5f5;
    --muted-foreground: #737373;
    --accent: #f5f5f5;
    --accent-foreground: #171717;
    --destructive: #ef4444;
    --destructive-foreground: #fafafa;
    --border: #e5e5e5;
    --input: #e5e5e5;
    --ring: #0a0a0a;

    /* Success/Warning states */
    --success: #22c55e;
    --success-foreground: #ffffff;
    --warning: #f59e0b;
    --warning-foreground: #ffffff;
    --info: #3b82f6;
    --info-foreground: #ffffff;

    /* Radius */
    --radius: 0.5rem;
    --radius-sm: 0.375rem;
    --radius-lg: 0.75rem;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

    /* Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

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

body {
    font-family: var(--font-sans);
    background: var(--secondary);
    color: var(--foreground);
    line-height: 1.6;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========== Typography ========== */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    letter-spacing: -0.025em;
    color: var(--foreground);
}

h1 { font-size: 1.875rem; line-height: 2.25rem; }
h2 { font-size: 1.25rem; line-height: 1.75rem; }
h3 { font-size: 1.125rem; line-height: 1.5rem; }

p { color: var(--muted-foreground); }

code {
    font-family: var(--font-mono);
    font-size: 0.875em;
    background: var(--muted);
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
}

/* ========== Layout ========== */
.main-content {
    padding: 1.5rem;
    min-height: calc(100vh - 60px);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: var(--card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 1.5rem;
}

.page-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.page-header p {
    margin-top: 0.25rem;
    font-size: 0.875rem;
}

/* ========== Cards ========== */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.card-header {
    margin-bottom: 1rem;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.card-description {
    font-size: 0.875rem;
    color: var(--muted-foreground);
}

/* ========== Stats Grid ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: transparent;
    padding: 0;
}

.stat-card h3 {
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--muted-foreground);
    text-transform: none;
    letter-spacing: normal;
    margin-bottom: 0.375rem;
}

.stat-card .value {
    font-size: 2rem;
    font-weight: 600;
    color: var(--foreground);
    letter-spacing: -0.025em;
    line-height: 1;
}

.stat-card .subtext {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    margin-top: 0.25rem;
}

/* Bordered variant */
.stats-grid.bordered {
    gap: 1rem;
}

.stats-grid.bordered .stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    padding: 1rem;
    border-radius: var(--radius);
}

/* ========== Buttons ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: var(--primary-foreground);
    border-color: var(--primary);
}

.btn-primary:hover:not(:disabled) {
    opacity: 0.9;
}

.btn-secondary {
    background: var(--secondary);
    color: var(--secondary-foreground);
    border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--accent);
}

.btn-outline {
    background: transparent;
    color: var(--foreground);
    border-color: var(--border);
}

.btn-outline:hover:not(:disabled) {
    background: var(--accent);
}

.btn-destructive {
    background: var(--destructive);
    color: var(--destructive-foreground);
    border-color: var(--destructive);
}

.btn-destructive:hover:not(:disabled) {
    opacity: 0.9;
}

.btn-success {
    background: var(--success);
    color: var(--success-foreground);
    border-color: var(--success);
}

.btn-success:hover:not(:disabled) {
    opacity: 0.9;
}

.btn-warning {
    background: var(--warning);
    color: var(--warning-foreground);
    border-color: var(--warning);
}

.btn-warning:hover:not(:disabled) {
    opacity: 0.9;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-lg {
    padding: 0.625rem 1.25rem;
    font-size: 1rem;
}

/* ========== Form Elements ========== */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.375rem;
    color: var(--foreground);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid var(--input);
    border-radius: var(--radius);
    background: var(--background);
    color: var(--foreground);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--ring);
    box-shadow: 0 0 0 2px rgb(10 10 10 / 0.1);
}

.form-input::placeholder {
    color: var(--muted-foreground);
}

.form-hint {
    font-size: 0.8125rem;
    color: var(--muted-foreground);
    margin-top: 0.375rem;
}

/* ========== Messages / Alerts ========== */
.message {
    padding: 0.875rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 1rem;
    border: 1px solid;
}

.message.success {
    background: #f0fdf4;
    color: #166534;
    border-color: #bbf7d0;
}

.message.error {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

.message.warning {
    background: #fffbeb;
    color: #92400e;
    border-color: #fde68a;
}

.message.info {
    background: #eff6ff;
    color: #1e40af;
    border-color: #bfdbfe;
}

/* ========== Tables ========== */
.table-container {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.table th {
    background: var(--muted);
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted-foreground);
    border-bottom: 1px solid var(--border);
}

.table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--foreground);
}

.table tr:last-child td {
    border-bottom: none;
}

.table tr:hover td {
    background: var(--muted);
}

/* ========== Badges ========== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
    border: 1px solid transparent;
}

.badge-default {
    background: var(--secondary);
    color: var(--secondary-foreground);
    border-color: var(--border);
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-error {
    background: #fee2e2;
    color: #991b1b;
}

.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

/* ========== Progress Bar ========== */
.progress {
    height: 0.5rem;
    background: var(--muted);
    border-radius: 9999px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 9999px;
    transition: width 0.3s ease;
}

.progress-bar.success { background: var(--success); }
.progress-bar.warning { background: var(--warning); }
.progress-bar.info { background: var(--info); }

/* ========== Divider ========== */
.divider {
    height: 1px;
    background: var(--border);
    margin: 1rem 0;
}

/* ========== Drop Zone ========== */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    text-align: center;
    transition: all 0.15s ease;
    cursor: pointer;
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--primary);
    background: var(--muted);
}

.drop-zone-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.5;
}

.drop-zone-text {
    font-size: 0.875rem;
    color: var(--muted-foreground);
}

.drop-zone-text strong {
    color: var(--foreground);
}

/* ========== Pipeline / Steps ========== */
.pipeline {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.pipeline-step {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: all 0.15s ease;
}

.pipeline-step:hover {
    border-color: var(--primary);
}

.pipeline-step-number {
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--muted);
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--muted-foreground);
    flex-shrink: 0;
}

.pipeline-step.completed .pipeline-step-number {
    background: var(--success);
    color: white;
}

.pipeline-step.active .pipeline-step-number {
    background: var(--primary);
    color: white;
}

.pipeline-step-content {
    flex: 1;
    min-width: 0;
}

.pipeline-step-title {
    font-weight: 500;
    color: var(--foreground);
    margin-bottom: 0.125rem;
}

.pipeline-step-description {
    font-size: 0.8125rem;
    color: var(--muted-foreground);
}

.pipeline-step-stats {
    display: flex;
    gap: 1rem;
    margin-left: auto;
    flex-shrink: 0;
}

.pipeline-step-stat {
    text-align: right;
}

.pipeline-step-stat-value {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--foreground);
}

.pipeline-step-stat-label {
    font-size: 0.6875rem;
    color: var(--muted-foreground);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ========== Action Groups ========== */
.action-group {
    padding: 1rem;
    background: var(--muted);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
}

.action-group:last-child {
    margin-bottom: 0;
}

.action-group-title {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.action-group-description {
    font-size: 0.8125rem;
    color: var(--muted-foreground);
    margin-bottom: 0.75rem;
}

/* ========== Results Grid ========== */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.75rem;
}

.result-item {
    text-align: center;
    padding: 1rem;
    background: var(--muted);
    border-radius: var(--radius);
}

.result-item .number {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--foreground);
}

.result-item .label {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    margin-top: 0.25rem;
}

/* ========== Utility Classes ========== */
.text-muted { color: var(--muted-foreground); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-error { color: var(--destructive); }
.text-info { color: var(--info); }

.font-mono { font-family: var(--font-mono); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }

.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .main-content {
        padding: 1rem;
    }

    .container {
        padding: 1rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .pipeline-step {
        flex-wrap: wrap;
    }

    .pipeline-step-stats {
        width: 100%;
        margin-left: 0;
        margin-top: 0.75rem;
        padding-top: 0.75rem;
        border-top: 1px solid var(--border);
    }
}
