/* Ecomedes Product Extractor — Design System
   Aligned with ecomedes sandbox (sandbox.ecomedes.com) visual language */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

:root {
    --eco-teal: #0d9488;
    --eco-teal-light: #14b8a6;
    --eco-teal-dark: #0f766e;
    --eco-teal-bg: #f0fdfa;
    --eco-emerald: #059669;
    --eco-amber: #d97706;
    --eco-amber-bg: #fffbeb;
    --eco-red: #dc2626;
    --eco-red-bg: #fef2f2;
    --eco-blue: #2563eb;
    --eco-blue-bg: #eff6ff;
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #94a3b8;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
    --radius: 10px;
    --radius-lg: 14px;
}

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

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* --- Header --- */
.header {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}
.header-brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-primary);
    text-decoration: none;
}
.header-brand .eco-mark {
    width: 28px;
    height: 28px;
    background: var(--eco-teal);
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.75rem;
}
.header-nav { display: flex; gap: 1.5rem; align-items: center; }
.header-nav a {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
}
.header-nav a:hover { color: var(--eco-teal); }

/* --- Container --- */
.container { max-width: 1200px; margin: 0 auto; padding: 2rem; }

/* --- Cards --- */
.card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
}
.card-header {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
    font-weight: 600;
    margin-bottom: 1rem;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1.25rem;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: all 0.15s;
}
.btn-primary { background: var(--eco-teal); color: white; }
.btn-primary:hover { background: var(--eco-teal-dark); }
.btn-secondary { background: var(--bg-tertiary); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-sm { padding: 0.3125rem 0.75rem; font-size: 0.75rem; }

/* --- Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.badge-complete { background: var(--eco-teal-bg); color: var(--eco-teal-dark); }
.badge-running { background: var(--eco-blue-bg); color: var(--eco-blue); animation: pulse 2s infinite; }
.badge-error { background: var(--eco-red-bg); color: var(--eco-red); }
.badge-exact { background: var(--eco-teal-bg); color: var(--eco-teal-dark); }
.badge-closest { background: var(--eco-amber-bg); color: var(--eco-amber); }
.badge-none { background: var(--bg-tertiary); color: var(--text-tertiary); }
.badge-scraped { background: #eef2ff; color: #4f46e5; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* --- Tables --- */
table { width: 100%; border-collapse: collapse; }
th {
    text-align: left;
    padding: 0.75rem 0.625rem;
    border-bottom: 2px solid var(--border);
    color: var(--text-tertiary);
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    white-space: nowrap;
    background: var(--bg-primary);
    position: sticky;
    top: 0;
    z-index: 10;
    cursor: pointer;
    user-select: none;
    box-shadow: inset 0 -2px 0 var(--border);
}
/* Card with table: scroll container for both axes; sticky th works within */
.card-table { padding: 0; overflow: auto; max-height: calc(100vh - 220px); }
th:hover { color: var(--text-secondary); }
th .sort-arrow { font-size: 0.5rem; margin-left: 0.25rem; opacity: 0.3; }
th.sorted-asc .sort-arrow::after { content: '\25B2'; opacity: 1; }
th.sorted-desc .sort-arrow::after { content: '\25BC'; opacity: 1; }
td {
    padding: 0.625rem;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.8125rem;
    vertical-align: top;
}
tr:hover { background: var(--bg-secondary); }
.mono { font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace; font-size: 0.75rem; }
.truncate { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Links --- */
a { color: var(--eco-teal); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Forms --- */
input[type="text"], input[type="password"] {
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-family: inherit;
    transition: border-color 0.15s;
}
input[type="text"]:focus, input[type="password"]:focus {
    outline: none;
    border-color: var(--eco-teal);
    box-shadow: 0 0 0 3px rgba(13,148,136,0.1);
}
.correction-input {
    width: 100%;
    min-width: 220px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.375rem 0.5rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-family: 'SF Mono', monospace;
}
.correction-input:focus { outline: none; border-color: var(--eco-teal); }
.correction-input.has-value { border-color: var(--eco-emerald); background: #f0fdf4; }

/* --- Progress --- */
.progress-section {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}
.progress-bar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
    height: 6px;
    margin-bottom: 0.75rem;
    overflow: hidden;
}
.progress-bar-fill {
    background: var(--eco-teal);
    height: 100%;
    transition: width 0.5s;
    border-radius: 4px;
}

/* --- Save bar --- */
.save-bar {
    position: sticky;
    bottom: 0;
    background: var(--bg-primary);
    border-top: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    text-align: right;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.04);
}

/* --- Empty state --- */
.empty {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-tertiary);
    font-size: 0.875rem;
}

/* --- Upload area --- */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    text-align: center;
    transition: all 0.2s;
    background: var(--bg-primary);
}
.upload-area:hover { border-color: var(--eco-teal); background: var(--eco-teal-bg); }
.upload-area label { display: block; cursor: pointer; }
.upload-area .upload-icon { font-size: 2rem; margin-bottom: 0.5rem; opacity: 0.3; }
.upload-area .upload-text { font-size: 0.875rem; color: var(--text-secondary); margin-bottom: 1rem; }
.upload-area input[type="file"] { display: none; }

/* --- Meta bar --- */
.meta-bar {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
    align-items: center;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}
.meta-bar .separator { color: var(--border); }
