/* =========================================================
   Shopify-Odoo Sync Simulator -- Application Styles
   ========================================================= */

/* ---- Reset & base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #0f1117;
    color: #e0e0e6;
    min-height: 100vh;
    overflow-x: hidden;
}
a { color: #58a6ff; text-decoration: none; }
a:hover { text-decoration: underline; }
button {
    cursor: pointer;
    border: none;
    font-family: inherit;
    font-size: 0.9rem;
    border-radius: 6px;
    padding: 0.55rem 1.1rem;
    transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
}
button:active { transform: scale(0.97); }
input, select, textarea {
    font-family: inherit;
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid #2d2f3a;
    border-radius: 6px;
    background: #1a1c28;
    color: #e0e0e6;
    outline: none;
    transition: border-color 0.2s;
}
input:focus, select:focus, textarea:focus { border-color: #58a6ff; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.6rem 0.8rem; text-align: left; border-bottom: 1px solid #22242f; }
th { color: #9ca3b0; font-weight: 600; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; }
td { font-size: 0.88rem; }
tbody tr:hover { background: #1a1c28; }

/* ---- Layout ---- */
#app { display: flex; min-height: 100vh; }

/* ---- Sidebar ---- */
.sidebar {
    width: 240px;
    background: #161822;
    border-right: 1px solid #22242f;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    overflow-y: auto;
}
.sidebar-header { padding: 1.5rem 1.2rem 1rem; border-bottom: 1px solid #22242f; }
.logo { font-size: 1.35rem; font-weight: 700; color: #fff; }
.logo-icon { margin-right: 0.3rem; font-size: 1.4rem; }
.logo-accent { color: #58a6ff; }
.logo-sub { font-size: 0.75rem; color: #6b7280; margin-top: 0.2rem; }
.nav-links { list-style: none; padding: 0.8rem 0; flex: 1; }
.nav-link {
    display: block;
    padding: 0.65rem 1.2rem;
    color: #9ca3b0;
    font-size: 0.9rem;
    transition: background 0.15s, color 0.15s;
    border-left: 3px solid transparent;
}
.nav-link:hover { background: #1e2030; color: #e0e0e6; text-decoration: none; }
.nav-link.active { color: #58a6ff; background: #1a1f35; border-left-color: #58a6ff; }
.sidebar-footer { padding: 1rem 1.2rem; border-top: 1px solid #22242f; }

/* ---- Health indicator ---- */
.health-indicator { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8rem; color: #6b7280; }
.health-dot { width: 8px; height: 8px; border-radius: 50%; background: #6b7280; }
.health-dot.ok { background: #22c55e; box-shadow: 0 0 6px rgba(34,197,94,0.4); }
.health-dot.error { background: #ef4444; box-shadow: 0 0 6px rgba(239,68,68,0.4); }

/* ---- Main content ---- */
.main-content { margin-left: 240px; flex: 1; padding: 2rem; min-height: 100vh; }

/* ---- Page header ---- */
.page-header { margin-bottom: 1.8rem; }
.page-header h2 { font-size: 1.5rem; font-weight: 700; color: #fff; margin-bottom: 0.3rem; }
.page-header p { color: #6b7280; font-size: 0.9rem; }

/* ---- Cards ---- */
.card {
    background: #161822;
    border: 1px solid #22242f;
    border-radius: 10px;
    padding: 1.3rem;
    margin-bottom: 1.2rem;
}
.card-title { font-size: 0.85rem; color: #6b7280; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.6rem; }

/* ---- Stats grid ---- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
    background: #161822;
    border: 1px solid #22242f;
    border-radius: 10px;
    padding: 1.2rem;
    text-align: center;
}
.stat-value { font-size: 2rem; font-weight: 700; color: #fff; }
.stat-label { font-size: 0.8rem; color: #6b7280; margin-top: 0.3rem; text-transform: uppercase; letter-spacing: 0.03em; }
.stat-card.success .stat-value { color: #22c55e; }
.stat-card.danger .stat-value { color: #ef4444; }
.stat-card.warning .stat-value { color: #f59e0b; }
.stat-card.info .stat-value { color: #58a6ff; }

/* ---- Buttons ---- */
.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; box-shadow: 0 2px 8px rgba(37,99,235,0.3); }
.btn-success { background: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: #d97706; color: #fff; }
.btn-warning:hover { background: #b45309; }
.btn-secondary { background: #374151; color: #e0e0e6; }
.btn-secondary:hover { background: #4b5563; }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
.btn-group { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.btn:disabled, button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- Badges ---- */
.badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}
.badge-success { background: rgba(34,197,94,0.15); color: #22c55e; }
.badge-fail, .badge-danger { background: rgba(239,68,68,0.15); color: #ef4444; }
.badge-warning { background: rgba(245,158,11,0.15); color: #f59e0b; }
.badge-info { background: rgba(88,166,255,0.15); color: #58a6ff; }
.badge-secondary { background: rgba(107,114,128,0.15); color: #9ca3b0; }

/* ---- Sync control ---- */
.sync-panel { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.2rem; margin-bottom: 1.5rem; }
.sync-card {
    background: #161822;
    border: 1px solid #22242f;
    border-radius: 10px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}
.sync-card h3 { font-size: 1.05rem; color: #fff; }
.sync-card p { font-size: 0.85rem; color: #6b7280; flex: 1; }

/* ---- Job list ---- */
.job-row { cursor: pointer; }
.job-row:hover { background: #1e2030; }
.log-detail { padding: 1rem; }
.log-list { max-height: 400px; overflow-y: auto; }
.log-entry { padding: 0.4rem 0.6rem; border-bottom: 1px solid #1a1c28; font-size: 0.82rem; display: flex; gap: 0.6rem; align-items: center; }
.log-entry .log-id { color: #6b7280; min-width: 80px; }
.log-entry .log-status { min-width: 70px; }
.log-entry .log-msg { color: #9ca3b0; flex: 1; }

/* ---- Mapping editor ---- */
.mapping-form { display: grid; grid-template-columns: 1fr 1fr 1fr auto auto; gap: 0.6rem; align-items: center; margin-bottom: 0.6rem; }
.mapping-form.header { font-weight: 600; color: #9ca3b0; font-size: 0.82rem; }

/* ---- Dead letter ---- */
.dlq-payload { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.8rem; color: #6b7280; }
.dlq-payload:hover { white-space: normal; word-break: break-all; }

/* ---- Toast notifications ---- */
.toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999; display: flex; flex-direction: column; gap: 0.5rem; }
.toast {
    padding: 0.8rem 1.2rem;
    border-radius: 8px;
    font-size: 0.88rem;
    animation: toastIn 0.3s ease, toastOut 0.4s ease 3.6s forwards;
    max-width: 380px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.toast.success { background: #16a34a; color: #fff; }
.toast.error { background: #dc2626; color: #fff; }
.toast.info { background: #2563eb; color: #fff; }

@keyframes toastIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(-10px); } }

/* ---- Loading ---- */
.loading-spinner { text-align: center; padding: 3rem; color: #6b7280; font-size: 1.1rem; }

/* ---- Empty state ---- */
.empty-state { text-align: center; padding: 3rem; color: #6b7280; }
.empty-state h3 { color: #9ca3b0; margin-bottom: 0.5rem; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar .logo-sub, .sidebar .nav-link span { display: none; }
    .main-content { margin-left: 60px; padding: 1rem; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .sync-panel { grid-template-columns: 1fr; }
    .mapping-form { grid-template-columns: 1fr; }
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #0f1117; }
::-webkit-scrollbar-thumb { background: #2d2f3a; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #3d3f4a; }

/* ---- Misc ---- */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-sm { gap: 0.5rem; }
.gap-md { gap: 1rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.text-muted { color: #6b7280; }
.text-sm { font-size: 0.82rem; }
.text-right { text-align: right; }
.mono { font-family: 'Cascadia Code', 'Fira Code', monospace; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }

/* ---- Direction arrows ---- */
.direction-arrow { font-size: 1.2rem; color: #58a6ff; }
.direction-arrow.reverse { transform: scaleX(-1); display: inline-block; }

/* ---- Progress bar ---- */
.progress-bar { height: 6px; background: #22242f; border-radius: 3px; overflow: hidden; margin-top: 0.4rem; }
.progress-bar .fill { height: 100%; border-radius: 3px; transition: width 0.4s ease; }
.progress-bar .fill.success { background: #22c55e; }
.progress-bar .fill.danger { background: #ef4444; }
.progress-bar .fill.info { background: #58a6ff; }

/* ---- System pair indicators ---- */
.system-pair { display: flex; align-items: center; gap: 0.5rem; }
.system-badge { padding: 0.25rem 0.6rem; border-radius: 4px; font-size: 0.78rem; font-weight: 600; }
.system-badge.shopify { background: rgba(150,191,72,0.15); color: #96bf48; }
.system-badge.odoo { background: rgba(113,75,165,0.15); color: #714ba5; }

/* ---- Tabs ---- */
.tab-bar { display: flex; border-bottom: 1px solid #22242f; margin-bottom: 1rem; }
.tab-bar .tab {
    padding: 0.6rem 1rem;
    color: #6b7280;
    font-size: 0.88rem;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}
.tab-bar .tab:hover { color: #e0e0e6; }
.tab-bar .tab.active { color: #58a6ff; border-bottom-color: #58a6ff; }
