/* ============================================================
   Global
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

:root {
    --brand-blue:    #2563eb;
    --brand-blue-dk: #1d4ed8;
    --brand-green:   #16a34a;
    --brand-purple:  #7c3aed;
    --surface:       #ffffff;
    --bg:            #f1f5f9;
    --border:        #e2e8f0;
    --text:          #0f172a;
    --text-muted:    #64748b;
    --shadow-sm:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md:     0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
    --shadow-lg:     0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
    --radius:        10px;
    --transition:    .18s ease;
}

html, body { height: 100%; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.6;
    margin: 0;
}

/* ============================================================
   Login Page
   ============================================================ */
.login-body {
    background: var(--bg);
    min-height: 100vh;
    display: flex;
}

.login-wrapper {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* Left brand panel */
.login-brand-panel {
    display: none;
    width: 46%;
    background: linear-gradient(145deg, #1e3a8a 0%, #1d4ed8 50%, #2563eb 100%);
    padding: 60px 56px;
    position: relative;
    overflow: hidden;
}

.login-brand-panel::before {
    content: '';
    position: absolute;
    top: -120px;
    right: -120px;
    width: 420px;
    height: 420px;
    border-radius: 50%;
    background: rgba(255,255,255,.06);
}

.login-brand-panel::after {
    content: '';
    position: absolute;
    bottom: -80px;
    left: -80px;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: rgba(255,255,255,.04);
}

@media (min-width: 900px) {
    .login-brand-panel { display: flex; align-items: center; }
}

.login-brand-content { position: relative; z-index: 1; color: white; }

.brand-icon { margin-bottom: 28px; }

.brand-title {
    font-size: 2.6rem;
    font-weight: 700;
    line-height: 1.15;
    margin: 0 0 16px;
    color: white;
}

.brand-tagline {
    font-size: 1.05rem;
    color: rgba(255,255,255,.75);
    margin: 0 0 40px;
}

.brand-features {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.brand-features li {
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(255,255,255,.9);
    font-size: .95rem;
}

.feature-check {
    width: 18px;
    height: 18px;
    color: #86efac;
    flex-shrink: 0;
}

/* Right form panel */
.login-form-panel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
}

.login-card {
    width: 100%;
    max-width: 420px;
}

.login-card-header {
    margin-bottom: 32px;
    text-align: center;
}

.login-card-header h2 {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0 0 8px;
}

.login-card-header p {
    color: var(--text-muted);
    margin: 0;
    font-size: .95rem;
}

/* Google sign-in button — follows Google branding guidelines */
.btn-google-signin {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 13px 24px;
    background: #ffffff;
    color: #3c4043;
    border: 1.5px solid #dadce0;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    font-family: inherit;
    text-decoration: none;
    transition: background var(--transition), box-shadow var(--transition);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

.btn-google-signin:hover {
    background: #f8f9fa;
    box-shadow: var(--shadow-md);
    color: #3c4043;
    text-decoration: none;
}

.btn-google-signin:active {
    background: #f1f3f4;
}

.google-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.login-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 28px 0 20px;
    color: var(--text-muted);
    font-size: .8rem;
    text-align: center;
}

.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    border-top: 1px solid var(--border);
}

.login-note {
    color: var(--text-muted);
    font-size: .82rem;
    text-align: center;
    margin: 0;
    line-height: 1.5;
}

/* Flash messages on login page */
.flash-message {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: .9rem;
}

.flash-error   { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.flash-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }
.flash-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }

/* ============================================================
   App Navbar
   ============================================================ */
.app-navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0;
    height: 60px;
    box-shadow: var(--shadow-sm);
}

.app-navbar .navbar-brand {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
}

.app-navbar .nav-link {
    color: var(--text-muted);
    font-size: .9rem;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 6px;
    transition: background var(--transition), color var(--transition);
}

.app-navbar .nav-link:hover,
.app-navbar .nav-link.active {
    background: #f1f5f9;
    color: var(--brand-blue);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--brand-blue);
    color: white;
    font-size: .8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.fw-600 { font-weight: 600; }

/* ============================================================
   Main content area
   ============================================================ */
.app-main {
    padding-top: 8px;
    min-height: calc(100vh - 60px);
}

/* ============================================================
   Page header
   ============================================================ */
.page-header { padding-bottom: 8px; border-bottom: 1px solid var(--border); }

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 4px;
}

.page-subtitle {
    color: var(--text-muted);
    margin: 0;
    font-size: .95rem;
}

/* ============================================================
   Dashboard navigation cards
   ============================================================ */
.nav-card {
    display: flex;
    align-items: center;
    gap: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-decoration: none;
    color: var(--text);
    transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
    box-shadow: var(--shadow-sm);
    height: 100%;
}

.nav-card:hover {
    box-shadow: var(--shadow-lg);
    border-color: #cbd5e1;
    transform: translateY(-2px);
    color: var(--text);
    text-decoration: none;
}

.nav-card-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.nav-card-icon--blue   { background: #dbeafe; color: var(--brand-blue); }
.nav-card-icon--green  { background: #dcfce7; color: var(--brand-green); }
.nav-card-icon--purple { background: #ede9fe; color: var(--brand-purple); }

.nav-card-body { flex: 1; }

.nav-card-body h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 4px;
}

.nav-card-body p {
    font-size: .85rem;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.5;
}

.nav-card-arrow {
    font-size: 1.25rem;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: color var(--transition);
}

.nav-card:hover .nav-card-arrow { color: var(--brand-blue); }

/* ============================================================
   Floating flash toasts
   ============================================================ */
.app-toast {
    min-width: 300px;
    max-width: 440px;
    background: #fff;
    border: 1px solid var(--border);
    border-left-width: 4px;
    border-radius: var(--radius);
    box-shadow: 0 4px 24px rgba(0,0,0,.13);
    font-size: .9rem;
    color: var(--text);
}
.app-toast--danger  { border-left-color: #ef4444; }
.app-toast--success { border-left-color: #22c55e; }
.app-toast--warning { border-left-color: #f59e0b; }
.app-toast--info    { border-left-color: #3b82f6; }

.app-toast--danger  .app-toast-icon { color: #ef4444; }
.app-toast--success .app-toast-icon { color: #22c55e; }
.app-toast--warning .app-toast-icon { color: #f59e0b; }
.app-toast--info    .app-toast-icon { color: #3b82f6; }

.app-toast-icon { font-size: 1.05rem; }
.app-toast-close { opacity: .45; }
.app-toast-close:hover { opacity: 1; }

/* ============================================================
   Configuration page — section cards
   ============================================================ */
.config-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.config-card-header {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: .95rem;
    color: var(--text);
    min-height: 50px;
}

.config-card-body {
    padding: 20px 24px;
}

.config-label {
    font-weight: 500;
    font-size: .9rem;
    color: var(--text);
}

.config-label-required {
    color: #dc2626;
    margin-left: 2px;
}

/* Dynamic list (competitors / emails) */
.dynamic-list {
    min-height: 40px;
}

.dynamic-list-item input.form-control {
    font-size: .9rem;
}

.btn-remove-item {
    flex-shrink: 0;
}

/* Chevron rotation for Advanced accordion */
.config-chevron {
    display: inline-block;
    transition: transform var(--transition);
    font-size: .85rem;
    color: var(--text-muted);
}

/* ============================================================
   Products page — spreadsheet-style grid
   ============================================================ */

.products-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

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

.products-table thead th {
    background: #f8fafc;
    border-bottom: 2px solid var(--border);
    padding: 10px 14px;
    font-weight: 600;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    white-space: nowrap;
}

.products-table tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.products-table tbody tr:last-child td { border-bottom: none; }
.products-table tbody tr:hover         { background: #f8fafc; }

/* Row highlighted while it is being edited in the form below */
.products-table tbody tr.editing {
    background: #fffbeb;
    box-shadow: inset 3px 0 0 #f59e0b;
}

/* Column widths */
.col-num             { width: 36px;   text-align: center; }
.col-sku             { width: 110px;  }
.col-name            { min-width: 180px; }
.col-itemid          { width: 140px;  }
.col-category        { width: 100px;  }
.col-keywords        { min-width: 140px; max-width: 200px; }
.col-competitor-ids  { min-width: 180px; }
.col-threshold       { width: 90px;   text-align: center; }
.col-group           { width: 110px;  }
.col-actions         { width: 88px;   }

/* SKU code chip */
.sku-code {
    background: #f1f5f9;
    color: var(--text);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: .8rem;
}

/* Competitor item ID badge */
.item-id-badge {
    display: inline-block;
    background: #e0f2fe;
    color: #0369a1;
    font-size: .72rem;
    padding: 2px 8px;
    border-radius: 10px;
    margin: 1px 2px 1px 0;
    white-space: nowrap;
    font-family: 'SF Mono', 'Fira Code', ui-monospace, monospace;
}

/* Ended / invalid eBay listing — amber warning state */
.item-id-badge--invalid {
    background: #fef9c3;
    color: #854d0e;
    border: 1px solid #fde68a;
}
.competitor-id-title--invalid {
    font-size: .72rem;
    color: #92400e;
    font-style: italic;
}
.owner-title--invalid {
    font-size: .82rem;
    color: #92400e;
    font-style: italic;
}

/* Price threshold pill */
.threshold-pill {
    display: inline-block;
    background: #dcfce7;
    color: #166534;
    font-size: .8rem;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 10px;
}

/* eBay item ID link in the Owner Item ID column */
.item-id-link {
    color: var(--brand-blue);
    text-decoration: none;
    font-family: 'SF Mono', 'Fira Code', ui-monospace, monospace;
    font-size: .82rem;
}
.item-id-link:hover { text-decoration: underline; }
.link-icon { font-size: .7rem; opacity: .6; }

/* Empty state */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 52px 24px;
}

/* Utility */
.fw-500             { font-weight: 500; }
.text-truncate-cell { display: block; }

/* ============================================================
   Competitor IDs column — column-level expand/collapse
   ============================================================ */

/* Short view (default): first 3 badges + overflow count */
.ids-short {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 3px;
}

.ids-overflow-count {
    font-size: .72rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Full view: all badges; visible only when column is expanded */
.ids-full {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

/* Wider column when expanded — applied to both th and every td */
.col-competitor-ids.ids-col-expanded {
    min-width: 440px;
}

/* Column header expand / collapse button */
.btn-col-expand {
    background: none;
    border: none;
    padding: 0 0 0 6px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: .78rem;
    vertical-align: middle;
    line-height: 1;
    transition: color var(--transition);
}
.btn-col-expand:hover { color: var(--brand-blue); }

/* ============================================================
   Account ID display (configuration + reports pages)
   ============================================================ */
.account-id-code {
    font-family: 'SF Mono', 'Fira Code', ui-monospace, monospace;
    font-size: .82rem;
    background: #f1f5f9;
    padding: 3px 8px;
    border-radius: 4px;
    color: var(--text);
    user-select: all;
}
