
/* IP Sorter Specific Styles */

/* THEME TOKENS */
:root {
    color-scheme: light dark;
    --bg: #ffffff;
    --fg: #111827;
    --muted: #6b7280;
    --panel: #f3f4f6;
    --border: #e5e7eb;
    --accent: #2563eb;
    --accent2: #7c3aed;
    --accent3: #059669;
    --accent4: #f59e0b;
    --danger: #ef4444;
    --chip: #e5e7eb;
    --chipfg: #111827;
    --stripe: #f9fafb;
}

[data-theme="system"] {
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b1220;
        --fg: #e5e7eb;
        --muted: #9ca3af;
        --panel: #0f172a;
        --border: #1f2937;
        --accent: #60a5fa;
        --accent2: #a78bfa;
        --accent3: #34d399;
        --accent4: #fbbf24;
        --danger: #f87171;
        --chip: #111827;
        --chipfg: #e5e7eb;
        --stripe: #0c1427;
    }
}

[data-theme="light"] {
    --bg: #ffffff;
    --fg: #111827;
    --muted: #6b7280;
    --panel: #f3f4f6;
    --border: #e5e7eb;
    --accent: #2563eb;
    --accent2: #7c3aed;
    --accent3: #059669;
    --accent4: #f59e0b;
    --danger: #ef4444;
    --chip: #e5e7eb;
    --chipfg: #111827;
    --stripe: #f9fafb;
}

[data-theme="dark"] {
    --bg: #0b1220;
    --fg: #e5e7eb;
    --muted: #9ca3af;
    --panel: #0f172a;
    --border: #1f2937;
    --accent: #60a5fa;
    --accent2: #a78bfa;
    --accent3: #34d399;
    --accent4: #fbbf24;
    --danger: #f87171;
    --chip: #111827;
    --chipfg: #e5e7eb;
    --stripe: #0c1427;
}

/* BASE */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

h1 {
    font-size: 1.2rem;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: #fff;
    font-weight: 800;
}

.toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.toggle {
    display: inline-flex;
    gap: 6px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--panel);
    padding: 4px;
}

.toggle button {
    border: none;
    background: transparent;
    color: var(--fg);
    padding: 6px 10px;
    border-radius: 999px;
    font-weight: 700;
    cursor: pointer;
}

.toggle button.active {
    background: var(--bg);
    border: 1px solid var(--border);
}

.btn {
    padding: 8px 12px;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--fg);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: transform .02s, border-color .15s, background .15s;
}

.btn:hover {
    transform: translateY(-1px);
    border-color: var(--accent);
}

.btn.primary {
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    border: none;
    color: #fff;
}

.btn.success {
    background: linear-gradient(135deg, var(--accent3), #16a34a);
    border: none;
    color: #fff;
}

.btn.warn {
    background: linear-gradient(135deg, var(--accent4), #d97706);
    border: none;
    color: #fff;
}

.btn.danger {
    background: linear-gradient(135deg, var(--danger), #dc2626);
    border: none;
    color: #fff;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    margin: 12px 0;
}

.muted {
    color: var(--muted);
}

/* Two-column layout */
.layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 16px;
    align-items: start;
}

.layout .left {
    min-width: 0;
    position: relative;
    overflow: visible;
}

.actions {
    width: 320px;
    min-width: 320px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: sticky;
    top: 12px;
}

.actions .btn {
    width: 100%;
    justify-content: center;
    white-space: normal;
    line-height: 1.2;
    padding: 10px 14px;
}

textarea#input {
    width: 100%;
    min-height: 220px;
    resize: vertical;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--fg);
    padding: 12px;
    font-family: ui-monospace, Consolas, Menlo, monospace;
    font-size: 0.95rem;
    box-sizing: border-box;
}

.chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.chip {
    background: var(--chip);
    color: var(--chipfg);
    padding: 4px 10px;
    border-radius: 999px;
    font-size: .85rem;
    border: 1px solid var(--border);
}

/* TABLE */
table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

th,
td {
    padding: 10px 12px;
    vertical-align: top;
    text-align: left;
}

thead th {
    background: linear-gradient(135deg, var(--panel), rgba(0, 0, 0, .03));
}

tbody tr:nth-child(odd) {
    background: var(--stripe);
}

.col {
    max-width: 100%;
    white-space: pre-wrap;
    word-break: break-word;
}

.line {
    display: block;
}

.results-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

/* Stack on small screens */
@media (max-width: 900px) {
    .layout {
        grid-template-columns: 1fr;
    }
    .actions {
        position: static;
        width: 100%;
        min-width: 0;
    }
    .actions .btn {
        width: 100%;
    }
}
