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

:root {
    --bg:           #0f1117;
    --bg-surface:   #181c27;
    --bg-elevated:  #1e2333;
    --bg-hover:     #242840;
    --border:       #2a2f45;
    --border-light: #343a54;

    --teal:         #09B1BA;
    --teal-dim:     #0a8f96;
    --teal-glow:    rgba(9,177,186,0.15);
    --green:        #22c55e;
    --purple:       #8b5cf6;
    --red:          #ef4444;
    --orange:       #f97316;
    --discord:      #5865F2;

    --text:         #e8eaf2;
    --text-muted:   #7b82a0;
    --text-dim:     #4a5070;

    --font-ui:      'Inter', sans-serif;
    --font-display: 'Space Grotesk', sans-serif;

    --sidebar-w:    240px;
    --radius:       12px;
    --radius-sm:    8px;
}

html, body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* === LAYOUT === */
body { display: flex; }

.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    z-index: 100;
}

.main {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-height: 100vh;
    padding: 2rem;
    max-width: calc(100vw - var(--sidebar-w));
}

/* === SIDEBAR === */
.sidebar-brand {
    padding: 1.5rem 1.25rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border);
    font-family: var(--font-display);
    font-size: 1.1rem;
    color: var(--text);
}
.sidebar-brand strong { color: var(--teal); }

.brand-icon {
    width: 32px; height: 32px;
    background: var(--teal);
    color: #000;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}

.sidebar-nav {
    list-style: none;
    padding: 1rem 0.75rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-weight: 500;
    transition: all 0.15s;
}
.sidebar-nav a svg {
    width: 16px; height: 16px;
    stroke: currentColor; fill: none;
    stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
    flex-shrink: 0;
}
.sidebar-nav a:hover { background: var(--bg-hover); color: var(--text); }
.sidebar-nav a.active { background: var(--teal-glow); color: var(--teal); }

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex; align-items: center; gap: 0.75rem;
    color: var(--text-muted); font-size: 0.78rem;
}
.status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-dot.online  { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.offline { background: var(--text-dim); }

/* === PAGE HEADER === */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.75rem;
    flex-wrap: wrap;
    gap: 1rem;
}
.page-header h1 {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
}
.subtitle { color: var(--text-muted); margin-top: 0.2rem; }

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    border: 1.5px solid transparent;
    transition: all 0.15s;
    white-space: nowrap;
}
.btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary  { background: var(--teal); color: #000; border-color: var(--teal); }
.btn-primary:hover { background: var(--teal-dim); border-color: var(--teal-dim); }
.btn-ghost    { background: transparent; color: var(--text-muted); border-color: var(--border-light); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-danger   { background: var(--red); color: #fff; border-color: var(--red); }
.btn-danger:hover { opacity: 0.85; }
.btn-icon     { background: transparent; border: none; cursor: pointer; font-size: 1rem; padding: 0.3rem; border-radius: 6px; transition: background 0.1s; }
.btn-icon:hover { background: var(--bg-hover); }
.btn-icon.danger:hover { background: rgba(239,68,68,0.15); }

/* === STATS === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}
.stat-icon {
    width: 44px; height: 44px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.stat-icon svg { width: 20px; height: 20px; stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.stat-icon.teal   { background: var(--teal-glow); }
.stat-icon.teal svg { stroke: var(--teal); }
.stat-icon.green  { background: rgba(34,197,94,0.12); }
.stat-icon.green svg { stroke: var(--green); }
.stat-icon.purple { background: rgba(139,92,246,0.12); }
.stat-icon.purple svg { stroke: var(--purple); }
.stat-value { font-family: var(--font-display); font-size: 1.6rem; font-weight: 700; line-height: 1; }
.stat-label { color: var(--text-muted); font-size: 0.8rem; margin-top: 2px; }

/* === FILTERS === */
.filters-bar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}
.filter-chip {
    padding: 0.35rem 0.85rem;
    border-radius: 99px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 500;
    transition: all 0.15s;
}
.filter-chip:hover { border-color: var(--teal); color: var(--teal); }
.filter-chip.active { background: var(--teal-glow); border-color: var(--teal); color: var(--teal); }
.chip-badge { font-size: 0.65rem; background: var(--border); border-radius: 4px; padding: 1px 4px; margin-left: 4px; }
.chip-badge.off { background: rgba(239,68,68,0.2); color: var(--red); }

/* === ITEMS GRID === */
.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.item-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
}
.item-card:hover {
    border-color: var(--teal);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(9,177,186,0.1);
}
.item-img-wrap {
    position: relative;
    aspect-ratio: 1;
    background: var(--bg-elevated);
    overflow: hidden;
}
.item-img-wrap img {
    width: 100%; height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}
.item-card:hover .item-img-wrap img { transform: scale(1.04); }
.item-img-placeholder {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    font-size: 2.5rem; color: var(--text-dim);
}
.item-price {
    position: absolute;
    bottom: 0.5rem; right: 0.5rem;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(6px);
    color: #fff;
    font-weight: 700;
    font-size: 0.88rem;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    font-family: var(--font-display);
}
.item-body {
    padding: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    flex: 1;
}
.item-title {
    font-weight: 600;
    font-size: 0.87rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.item-meta { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.tag {
    background: var(--bg-elevated);
    color: var(--text-muted);
    border-radius: 4px;
    padding: 2px 7px;
    font-size: 0.74rem;
    font-weight: 500;
    border: 1px solid var(--border);
}
.item-footer {
    display: flex;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 0.4rem;
}
.item-seller { color: var(--text-muted); font-size: 0.76rem; }
.item-date   { color: var(--text-dim);   font-size: 0.73rem; }
.item-search-badge {
    font-size: 0.72rem;
    color: var(--teal);
    background: var(--teal-glow);
    padding: 2px 6px;
    border-radius: 4px;
    align-self: flex-start;
    margin-top: 2px;
}

/* === PAGINATION === */
.pagination {
    display: flex;
    gap: 0.4rem;
    justify-content: center;
    margin: 1.5rem 0;
}
.page-btn {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-weight: 600;
    transition: all 0.15s;
}
.page-btn:hover { border-color: var(--teal); color: var(--teal); }
.page-btn.active { background: var(--teal); border-color: var(--teal); color: #000; }

/* === LOGS === */
.logs-section { margin-top: 2rem; }
.logs-section h2 { font-family: var(--font-display); font-size: 1.1rem; margin-bottom: 0.75rem; }
.logs-list {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.log-entry {
    display: flex;
    gap: 1rem;
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.82rem;
    align-items: center;
}
.log-entry:last-child { border-bottom: none; }
.log-time { color: var(--text-dim); flex-shrink: 0; font-variant-numeric: tabular-nums; }
.log-success .log-time::before { content: '✓ '; color: var(--green); }
.log-error   .log-time::before { content: '✗ '; color: var(--red); }
.log-info    .log-time::before { content: '· '; color: var(--teal); }

/* === ALERTS === */
.alert {
    padding: 0.85rem 1.1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    font-weight: 500;
    border-left: 3px solid;
}
.alert-success { background: rgba(34,197,94,0.1); border-color: var(--green); color: var(--green); }
.alert-error   { background: rgba(239,68,68,0.1); border-color: var(--red);   color: var(--red);   }
.alert-info    { background: rgba(9,177,186,0.1);  border-color: var(--teal); color: var(--teal);  }

/* === EMPTY STATE === */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--bg-surface);
    border: 1px dashed var(--border-light);
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
}
.empty-state.small { padding: 2rem; }
.empty-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state h3 { font-family: var(--font-display); font-size: 1.2rem; margin-bottom: 0.5rem; }
.empty-state p { color: var(--text-muted); margin-bottom: 1.25rem; }

/* === CONFIG PAGE === */
.config-layout {
    display: grid;
    grid-template-columns: 1fr 1.3fr;
    gap: 1.5rem;
    align-items: start;
}
@media (max-width: 900px) { .config-layout { grid-template-columns: 1fr; } }

.form-card, .searches-list {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}
.form-card h2, .searches-list h2 {
    font-family: var(--font-display);
    font-size: 1.05rem;
    margin-bottom: 1.25rem;
}

/* === FORMS === */
.form-group { margin-bottom: 1.1rem; }
.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.4rem;
}
.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="url"] {
    width: 100%;
    background: var(--bg-elevated);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 0.6rem 0.85rem;
    outline: none;
    transition: border-color 0.15s;
}
.form-group input:focus { border-color: var(--teal); }
.form-group input::placeholder { color: var(--text-dim); }
.form-hint { display: block; color: var(--text-dim); font-size: 0.76rem; margin-top: 0.3rem; }
.form-hint code { background: var(--bg-elevated); padding: 1px 5px; border-radius: 4px; color: var(--teal); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.form-actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; align-items: center; }

/* Toggle switch */
.form-toggle { display: flex; align-items: center; }
.toggle-label { display: flex; align-items: center; gap: 0.75rem; cursor: pointer; font-size: 0.9rem; font-weight: 500; }
.toggle-label input[type=checkbox] { display: none; }
.toggle-switch {
    width: 42px; height: 24px;
    background: var(--border-light);
    border-radius: 99px;
    position: relative;
    transition: background 0.2s;
    flex-shrink: 0;
}
.toggle-switch::after {
    content: '';
    position: absolute;
    width: 18px; height: 18px;
    background: #fff;
    border-radius: 50%;
    top: 3px; left: 3px;
    transition: transform 0.2s;
}
input[type=checkbox]:checked + .toggle-switch { background: var(--teal); }
input[type=checkbox]:checked + .toggle-switch::after { transform: translateX(18px); }

/* === SEARCH ROWS === */
.search-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 0;
    border-bottom: 1px solid var(--border);
}
.search-row:last-child { border-bottom: none; }
.search-row.inactive { opacity: 0.5; }
.search-name { font-weight: 600; display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.3rem; }
.search-status {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 99px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.search-status.on  { background: rgba(34,197,94,0.15); color: var(--green); }
.search-status.off { background: rgba(239,68,68,0.1);  color: var(--red);  }
.search-details { display: flex; gap: 0.75rem; flex-wrap: wrap; color: var(--text-muted); font-size: 0.78rem; }
.search-actions { display: flex; gap: 0.25rem; flex-shrink: 0; }

/* === SETTINGS PAGE === */
.settings-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media (max-width: 900px) { .settings-layout { grid-template-columns: 1fr; } }
.full-width { grid-column: 1 / -1; }

.settings-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}
.settings-card-header {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-bottom: 1.25rem;
}
.settings-card-header h2 {
    font-family: var(--font-display);
    font-size: 1.05rem;
}
.settings-icon {
    width: 38px; height: 38px;
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    color: #fff;
}
.settings-icon svg { width: 18px; height: 18px; }

/* Radio chips for interval */
.interval-selector { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.5rem; }
.radio-chip { cursor: pointer; }
.radio-chip input { display: none; }
.radio-chip span {
    display: block;
    padding: 0.4rem 0.9rem;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    border: 1.5px solid var(--border);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.85rem;
    transition: all 0.15s;
}
.radio-chip input:checked + span { background: var(--teal-glow); border-color: var(--teal); color: var(--teal); }
.radio-chip:hover span { border-color: var(--border-light); color: var(--text); }

/* Cron instructions */
.instruction-steps { display: flex; flex-direction: column; gap: 1rem; }
.step { display: flex; gap: 1rem; align-items: flex-start; }
.step-num {
    width: 28px; height: 28px;
    background: var(--teal-glow);
    color: var(--teal);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
    margin-top: 2px;
}
.code-block {
    background: #0a0c14;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.65rem 1rem;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    color: var(--teal);
    margin-top: 0.5rem;
    word-break: break-all;
}

/* Danger zone */
.danger-zone { border-color: rgba(239,68,68,0.3); }
.danger-zone h2 { color: var(--red); font-family: var(--font-display); margin-bottom: 1rem; }
.danger-action { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.danger-action p { color: var(--text-muted); font-size: 0.83rem; margin-top: 0.3rem; }

/* === COOKIE STATUS === */
.cookie-status-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    margin-bottom: 1.25rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.cookie-badge {
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 99px;
    font-size: 0.78rem;
}
.cookie-badge.manual { background: rgba(139,92,246,0.15); color: var(--purple); }
.cookie-badge.auto   { background: rgba(34,197,94,0.12);  color: var(--green);  }
.cookie-badge.none   { background: rgba(239,68,68,0.1);   color: var(--red);    }
.cookie-info { color: var(--text-muted); font-size: 0.85rem; line-height: 1.6; }
.cookie-info code { background: var(--bg-elevated); padding: 1px 5px; border-radius: 4px; color: var(--teal); font-size: 0.8rem; }
