/* ====== IQONIC � Cosmic Dark UI ====== */
:root {
    --bg: #0b1020; /* page */
    --bg-soft: #0f1530; /* soft layer */
    --card: #121a3a; /* card */
    --border: #223056; /* stroke */
    --text: #e9eeff; /* body text */
    --muted: #aab1d6; /* secondary */
    --accent: #6ea8fe; /* primary */
    --ok: #22c55e;
    --warn: #facc15;
    --err: #ef4444;
    --radius: 14px;
    --shadow: 0 10px 30px rgba(6,12,36,.35);
    --sp4: 4px;
    --sp8: 8px;
    --sp12: 12px;
    --sp16: 16px;
    --sp20: 20px;
    --sp24: 24px;
    --sp32: 32px;
    --fz12: 12px;
    --fz14: 14px;
    --fz16: 16px;
    --fz20: 20px;
    --fz24: 24px;
    --fz28: 28px;
}

* {
    box-sizing: border-box
}

html, body {
    height: 100%
}

body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans";
    color: var(--text);
    background: radial-gradient(1200px 800px at 20% -10%, rgba(110,168,254,.12), transparent 65%), radial-gradient(1200px 800px at 110% 10%, rgba(124,58,237,.12), transparent 65%), linear-gradient(#090e1e, #0d132b);
    background-attachment: fixed;
    background-size: 100% 100%;
    min-height: 100vh;
}

/* ---- Topbar / Layout ---- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 14px;
    height: 58px;
    padding: 0 var(--sp20);
    background: rgba(12,18,44,.72);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    letter-spacing: .4px
}

.brand .dot {
    width: 28px;
    height: 28px;
    border-radius: 10px;
    background: linear-gradient(135deg,#6ea8fe, #7c3aed);
    box-shadow: var(--shadow)
}

.topnav {
    display: flex;
    gap: 8px;
    margin: 0 auto
}

.topnav a {
    padding: 8px 12px;
    border-radius: 10px;
    text-decoration: none;
    color: var(--muted);
    border: 1px solid transparent;
}

.topnav a:hover {
    color: var(--text);
    background: rgba(255,255,255,.04);
    border-color: var(--border)
}

.topnav a.active {
    color: #dfe8ff;
    background: rgba(110,168,254,.14);
    border-color: #3d5ca8
}

.iconbtn {
    color: var(--muted);
    text-decoration: none;
    background: transparent;
    border: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.container {
    max-width: 1240px;
    margin: 0 auto;
    padding: var(--sp24)
}

/* ---- Toolbar ---- */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp12);
    align-items: center;
    padding: var(--sp12);
    background: rgba(255,255,255,.03);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: var(--sp16);
}

.field {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted)
}

/* Generic inputs */
input[type="text"], input[type="url"], input[type="email"], input[type="password"], input[type="search"], input:not([type]), select, textarea, input[type="date"] {
    background: var(--bg-soft);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    outline: none;
}

label {
    color: var(--muted);
    font-size: var(--fz12)
}

.note {
    color: var(--muted);
    font-size: var(--fz12)
}

.btn {
    background: #29438c;
    color: #dbe7ff;
    border: 1px solid #3554ad;
    border-radius: 12px;
    padding: 10px 14px;
    cursor: pointer;
}

.btn:hover {
    background: #3552aa
}

.btn.secondary {
    background: transparent;
    border-color: var(--border);
    color: var(--text)
}

.btn.success {
    background: #1e8f52;
    border-color: #2dbd6f
}

/* Sizes & variants used on pages */
.btn-sm {
    padding: 6px 10px;
    border-radius: 8px;
    font-size: var(--fz12)
}

.btn-primary {
    background: #3552aa;
    border-color: #3d5ca8;
    color: #e9eeff
}

.btn-primary:hover {
    background: #3d5ca8
}

.btn-danger {
    background: #a11a2b;
    border-color: #d33b4b;
    color: #fff
}

.btn-danger:hover {
    background: #b72435
}

/* ---- KPI Cards ---- */
.kpi-grid {
    display: grid;
    gap: var(--sp16);
    grid-template-columns: repeat(auto-fit, minmax(240px,1fr))
}

.card {
    background: linear-gradient(180deg, rgba(21,29,64,.9), rgba(13,19,47,.9));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: var(--sp16);
}

.kpi-label {
    color: var(--muted);
    font-size: var(--fz14)
}

.kpi-value {
    font-weight: 800;
    font-size: var(--fz28);
    line-height: 1.2
}

.kpi-sub {
    color: var(--muted);
    font-size: var(--fz12);
    margin-top: 6px
}

/* Ampel-Badge */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 4px 8px;
    font-size: var(--fz12);
    border: 1px solid var(--border);
    background: rgba(255,255,255,.04)
}

.badge.green {
    color: var(--ok);
    border-color: rgba(34,197,94,.35);
    background: rgba(34,197,94,.08)
}

.badge.yellow {
    color: var(--warn);
    border-color: rgba(250,204,21,.35);
    background: rgba(250,204,21,.08)
}

.badge.red {
    color: var(--err);
    border-color: rgba(239,68,68,.35);
    background: rgba(239,68,68,.08)
}

/* ---- Chart Card ---- */
.chart-card {
    padding: var(--sp16)
}

.chart-card canvas {
    height: 320px !important
}

/* ---- Table ---- */
.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.table thead th {
    text-align: left;
    font-size: var(--fz12);
    letter-spacing: .4px;
    color: #c7cff7;
    background: rgba(255,255,255,.04);
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

.table tbody td {
    padding: 12px;
    border-bottom: 1px solid rgba(38,48,85,.6)
}

.table tbody tr:hover {
    background: rgba(255,255,255,.02)
}

.table .num {
    text-align: right;
    font-variant-numeric: tabular-nums
}

/* ---- Chips (f�r Models etc.) ---- */
.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px
}

.chip {
    padding: 8px 12px;
    font-size: var(--fz12);
    letter-spacing: .3px;
    color: #d7defa;
    border: 1px solid var(--border);
    background: rgba(255,255,255,.06);
    border-radius: 12px;
}

/* ---- Skeleton / Toast ---- */
.skeleton {
    position: relative;
    overflow: hidden;
    background: rgba(255,255,255,.07);
    border-radius: 10px;
    min-height: 60px
}

.skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,.12) 50%, transparent 100%);
    animation: shimmer 1.2s infinite
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%)
    }

    100% {
        transform: translateX(100%)
    }
}

.busy {
    position: fixed;
    top: 12px;
    right: 12px;
    padding: 8px 12px;
    background: #000;
    color: #fff;
    border-radius: 8px;
    opacity: .85;
    z-index: 9999;
}


.toast {
    position: fixed;
    right: 16px;
    bottom: 16px;
    background: rgba(13,19,47,.98);
    border: 1px solid var(--border);
    padding: 12px 14px;
    border-radius: 10px;
    box-shadow: var(--shadow)
}

/* ---- Modal Dialog (simplified, robust) ---- */
dialog.modal {
    position: fixed;
    inset: 10% auto auto 50%;
    transform: translateX(-50%);
    width: min(720px, 96vw);
    max-width: 96vw;
    max-height: 80vh;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--text);
    box-shadow: var(--shadow);
    padding: 0;
}

dialog.modal[open] { display: block; }

dialog.modal::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(2px) }

.modal-body { display: flex; flex-direction: column }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border) }
.modal-content { display: grid; gap: 12px; padding: 16px; overflow: auto; max-height: calc(80vh - 120px) }
.modal-footer { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--border) }

.modal-content input, .modal-content select, .modal-content textarea { width: 100%; }

/* ---- Modal Overlay (dialog replacement) ---- */
.modal-overlay[hidden] { display: none !important; }
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    backdrop-filter: blur(2px);
    z-index: 9999;
    display: grid;
    place-items: center;
}
.modal-panel {
    width: min(720px, 96vw);
    max-height: 80vh;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--text);
    box-shadow: var(--shadow);
}


/* Domains filter */
.toolbar .toolbar-search {
    flex: 1 1 220px;
    max-width: 320px;
    min-width: 200px;
}
/* Domain clipboard helpers */
.toolbar-messages {
    margin-top: 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.flash {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.75rem;
    border-radius: 0.5rem;
    font-weight: 600;
    border: 1px solid transparent;
    background: rgba(59, 130, 246, 0.12);
    color: #93c5fd;
}
.flash-info {
    background: rgba(59, 130, 246, 0.12);
    border-color: rgba(59, 130, 246, 0.45);
    color: #93c5fd;
}
.flash-success {
    background: rgba(16, 185, 129, 0.18);
    border-color: rgba(16, 185, 129, 0.45);
    color: #34d399;
}
.flash-error {
    background: rgba(239, 68, 68, 0.16);
    border-color: rgba(239, 68, 68, 0.45);
    color: #fca5a5;
}
.flash:not(.flash-info):not(.flash-success):not(.flash-error) {
    background: rgba(59, 130, 246, 0.12);
    border-color: rgba(59, 130, 246, 0.45);
    color: #93c5fd;
}
.toolbar-messages .flash {
    margin: 0;
}

.slug-cell {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding-left: 0;
}
.slug-cell .slug-text {
    white-space: nowrap;
    font-size: 0.95rem;
}

.btn-copy {
    background: transparent;
    border: none;
    color: #9ca3af;
    font-size: 1rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 0.45rem;
    flex-shrink: 0;
    transition: color 0.15s ease, transform 0.15s ease;
}
.btn-copy:hover,
.btn-copy:focus {
    color: #60a5fa;
    background: rgba(59, 130, 246, 0.15);
}
.btn-copy:focus-visible {
    outline: 2px solid #60a5fa;
    outline-offset: 2px;
}
.btn-copy.copied {
    color: #34d399;
    transform: scale(1.08);
}

.socials-cell {
    white-space: nowrap;
}

.social-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    text-decoration: none;
    padding: 0.4rem 0.5rem;
    border-radius: 0.4rem;
    transition: all 0.15s ease;
    flex-shrink: 0;
    margin-right: 0.3rem;
}
.social-icon:last-child {
    margin-right: 0;
}

.instagram-icon {
    color: #c13584;
    background: rgba(193, 53, 132, 0.1);
}
.instagram-icon:hover {
    color: #e4405f;
    background: rgba(228, 64, 95, 0.2);
    transform: scale(1.1);
}

.social-icon-img {
    width: 1rem;
    height: 1rem;
    display: block;
}

.group-row td {
    background: rgba(35, 42, 77, 0.55);
    border-top: 1px solid rgba(59, 76, 125, 0.4);
    padding: 0.55rem 1rem;
}
.group-row:first-child td {
    border-top: none;
}
.group-row.is-collapsed td {
    border-bottom: 1px solid rgba(35, 42, 77, 0.4);
}

.group-toggle {
    appearance: none;
    border: none;
    background: transparent;
    color: #e2e8ff;
    display: flex;
    align-items: center;
    width: 100%;
    font-size: 0.95rem;
    font-weight: 600;
    gap: 0.6rem;
    cursor: pointer;
    padding: 0;
    text-align: left;
}
.group-toggle:hover {
    color: #f8fafc;
}
.group-toggle:focus-visible {
    outline: 2px solid #60a5fa;
    outline-offset: 2px;
}
.group-toggle .chevron {
    width: 0.65rem;
    height: 0.65rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform 0.2s ease;
    margin-right: 0.2rem;
}
.group-row.is-collapsed .group-toggle .chevron {
    transform: rotate(-135deg);
}
.group-toggle .folder-icon {
    font-size: 1rem;
}
.group-toggle .label {
    flex: 1 1 auto;
}
.group-toggle .count {
    font-size: 0.75rem;
    font-weight: 500;
    color: #9ca3af;
    background: rgba(15, 23, 42, 0.55);
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
}
.group-toggle.forced-open .count {
    background: rgba(59, 130, 246, 0.35);
    color: #bfdbfe;
}

.group-item td {
    border-top: 1px solid rgba(26, 34, 74, 0.5);
}

.empty-row td {
    padding: 1rem;
    color: #9ca3af;
    text-align: center;
}

.table tr.highlight-new {
    animation: flashRow 1.4s ease-in-out 1;
}

@keyframes flashRow {
    0% {
        background-color: rgba(16, 185, 129, 0.22);
    }
    100% {
        background-color: transparent;
    }
}

/* ========================================
   RESPONSIVE DESIGN - GLOBAL
   ======================================== */

/* Tablet and Below - 1024px */
@media (max-width: 1024px) {
    .topbar {
        gap: 10px;
        padding: 0 var(--sp16);
    }

    .topnav {
        gap: 6px;
    }

    .topnav a {
        padding: 6px 10px;
        font-size: 0.9rem;
    }

    .container {
        padding: var(--sp20);
    }

    .toolbar {
        gap: var(--sp8);
        padding: var(--sp8);
    }

    .card-grid {
        grid-template-columns: 1fr;
        gap: var(--sp16);
    }
}

/* Mobile and Small Tablets - 768px */
@media (max-width: 768px) {
    .topbar {
        flex-wrap: wrap;
        height: auto;
        min-height: 58px;
        padding: var(--sp12);
        gap: 8px;
    }

    .brand {
        font-size: 0.9rem;
    }

    .brand .dot {
        width: 24px;
        height: 24px;
    }

    .topnav {
        flex-wrap: wrap;
        width: 100%;
        justify-content: center;
        gap: 4px;
    }

    .topnav a {
        flex: 1 1 auto;
        text-align: center;
        font-size: 0.85rem;
        padding: 6px 8px;
    }

    .container {
        padding: var(--sp16);
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar .toolbar-search {
        max-width: 100%;
        width: 100%;
    }

    /* Tables - horizontal scroll */
    .table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 600px;
        font-size: 0.85rem;
    }

    table th,
    table td {
        padding: 8px;
    }

    /* Cards */
    .card {
        padding: var(--sp12);
    }

    /* Buttons */
    button,
    .btn,
    .primary,
    .secondary {
        font-size: 0.9rem;
        padding: 10px 16px;
    }

    /* Form inputs */
    input[type="text"],
    input[type="url"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    input:not([type]),
    select,
    textarea,
    input[type="date"] {
        font-size: 16px; /* Prevents iOS zoom */
        padding: 12px;
    }

    /* Modals */
    .modal-panel {
        width: 95vw;
        max-height: 90vh;
    }

    .modal-content {
        padding: 12px;
    }

    dialog.modal {
        width: 95vw;
        max-width: none;
    }
}

/* Mobile - 640px */
@media (max-width: 640px) {
    :root {
        --sp24: 16px;
        --sp20: 14px;
        --sp16: 12px;
        --sp12: 10px;
    }

    .topbar {
        padding: var(--sp8);
    }

    .brand {
        font-size: 0.85rem;
    }

    .topnav a {
        font-size: 0.8rem;
        padding: 5px 6px;
    }

    .container {
        padding: var(--sp12);
    }

    .toolbar {
        gap: var(--sp8);
        padding: var(--sp8);
    }

    .toolbar-messages {
        flex-direction: column;
        width: 100%;
    }

    .flash {
        width: 100%;
        justify-content: center;
    }

    /* Tables - smaller font */
    table {
        font-size: 0.75rem;
        min-width: 500px;
    }

    table th,
    table td {
        padding: 6px;
    }

    .btn-copy {
        width: 1.5rem;
        height: 1.5rem;
        font-size: 0.9rem;
    }

    /* Buttons - full width on mobile */
    .modal-footer {
        flex-direction: column;
    }

    .modal-footer button {
        width: 100%;
    }

    /* Card grid */
    .card-grid {
        gap: var(--sp12);
    }

    /* Group toggles */
    .group-toggle {
        font-size: 0.85rem;
    }

    .group-toggle .count {
        font-size: 0.7rem;
    }
}

/* Small Mobile - 375px */
@media (max-width: 375px) {
    .topbar {
        padding: 6px;
    }

    .brand {
        font-size: 0.8rem;
        gap: 6px;
    }

    .brand .dot {
        width: 20px;
        height: 20px;
    }

    .topnav {
        gap: 3px;
    }

    .topnav a {
        font-size: 0.75rem;
        padding: 4px 5px;
    }

    .container {
        padding: 8px;
    }

    button,
    .btn,
    .primary,
    .secondary {
        font-size: 0.85rem;
        padding: 8px 12px;
    }

    table {
        font-size: 0.7rem;
    }
}

/* iOS Zoom Prevention - Specific for WebKit */
@media screen and (-webkit-min-device-pixel-ratio:0) { 
    select,
    textarea,
    input {
        font-size: 16px !important;
    }
}
