/* =========================================================
   XERION — COMPONENTS
========================================================== */


/* =========================================================
   BUTTON ICON
========================================================== */

.button-icon {
    width: 38px;
    height: 38px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 0;

    border: 1px solid var(--border);
    border-radius: var(--radius-small);

    background: var(--white);
    color: var(--text-soft);

    cursor: pointer;

    transition:
        background var(--transition),
        border-color var(--transition),
        color var(--transition),
        box-shadow var(--transition);
}

.button-icon:hover {
    border-color: var(--border-strong);
    background: var(--surface-soft);
    color: var(--text);
}

.button-icon svg {
    width: 18px;
    height: 18px;
}


/* =========================================================
   ICON BUTTON — GHOST
========================================================== */

.icon-button {
    width: 34px;
    height: 34px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 0;

    border: 1px solid transparent;
    border-radius: var(--radius-small);

    background: transparent;
    color: var(--muted);

    cursor: pointer;

    transition:
        background var(--transition),
        border-color var(--transition),
        color var(--transition);
}

.icon-button:hover {
    border-color: var(--border);
    background: var(--surface-soft);
    color: var(--text);
}

.icon-button svg {
    width: 17px;
    height: 17px;
}


/* =========================================================
   BUTTON GROUP
========================================================== */

.button-group {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}


/* =========================================================
   CARDS
========================================================== */

.component-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);

    background: var(--white);

    box-shadow: var(--shadow-xs);

    overflow: hidden;
}

.component-card-header {
    min-height: 58px;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;

    padding: 0 18px;

    border-bottom: 1px solid var(--border);
}

.component-card-header h3 {
    color: var(--text);

    font-size: 14px;
    font-weight: 650;
}

.component-card-body {
    padding: 18px;
}

.component-card-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;

    padding: 14px 18px;

    border-top: 1px solid var(--border);

    background: var(--surface-soft);
}


/* =========================================================
   PANEL
========================================================== */

.panel {
    border: 1px solid var(--border);
    border-radius: var(--radius);

    background: var(--white);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;

    padding: 18px 20px;

    border-bottom: 1px solid var(--border);
}

.panel-title {
    color: var(--text);

    font-size: 15px;
    font-weight: 650;
}

.panel-description {
    margin-top: 3px;

    color: var(--muted);

    font-size: 12px;
    line-height: 1.5;
}

.panel-body {
    padding: 20px;
}


/* =========================================================
   SEARCH FIELD
========================================================== */

.search-field {
    position: relative;

    width: 100%;
    max-width: 360px;
}

.search-field svg {
    position: absolute;
    top: 50%;
    left: 12px;

    width: 17px;
    height: 17px;

    color: var(--muted);

    transform: translateY(-50%);

    pointer-events: none;
}

.search-field input {
    width: 100%;
    height: 40px;

    padding: 0 12px 0 38px;

    border-radius: var(--radius-small);

    font-size: 13px;
}


/* =========================================================
   DROPDOWN
========================================================== */

.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 7px);
    right: 0;

    min-width: 190px;

    padding: 6px;

    border: 1px solid var(--border);
    border-radius: var(--radius);

    background: var(--white);

    box-shadow: var(--shadow);

    z-index: 500;
}

.dropdown-menu.is-hidden {
    display: none;
}

.dropdown-item {
    width: 100%;
    min-height: 36px;

    display: flex;
    align-items: center;
    gap: 9px;

    padding: 0 10px;

    border-radius: var(--radius-small);

    background: transparent;
    color: var(--text-soft);

    font-size: 12px;
    font-weight: 500;

    text-align: left;

    cursor: pointer;

    transition:
        background var(--transition),
        color var(--transition);
}

.dropdown-item:hover {
    background: var(--surface-soft);
    color: var(--text);
}

.dropdown-item.is-danger {
    color: var(--danger);
}

.dropdown-item.is-danger:hover {
    background: var(--danger-light);
}

.dropdown-divider {
    height: 1px;

    margin: 6px 4px;

    background: var(--border);
}


/* =========================================================
   MODAL
========================================================== */

.modal-overlay {
    position: fixed;
    inset: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 24px;

    background: rgba(15, 23, 42, 0.28);

    opacity: 0;
    visibility: hidden;

    pointer-events: none;

    transition:
        opacity var(--transition),
        visibility var(--transition);

    z-index: 1000;
}

.modal-overlay.is-visible {
    opacity: 1;
    visibility: visible;

    pointer-events: auto;
}

.modal {
    position: relative;

    width: min(100%, 520px);
    max-height: calc(100vh - 48px);

    overflow-y: auto;

    border: 1px solid var(--border);
    border-radius: var(--radius-large);

    background: var(--white);

    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.14);

    transform: translateY(6px) scale(0.99);

    transition: transform var(--transition);
}

.modal-overlay.is-visible .modal {
    transform: translateY(0) scale(1);
}

.modal-close {
    position: absolute;
    top: 13px;
    right: 13px;

    width: 32px;
    height: 32px;

    display: flex;
    align-items: center;
    justify-content: center;

    border: 1px solid transparent;
    border-radius: var(--radius-small);

    background: transparent;
    color: var(--muted);

    font-size: 21px;
    font-weight: 300;
    line-height: 1;

    cursor: pointer;

    transition:
        background var(--transition),
        border-color var(--transition),
        color var(--transition);
}

.modal-close:hover {
    border-color: var(--border);
    background: var(--surface-soft);
    color: var(--text);
}


/* =========================================================
   MODAL CONTENT
========================================================== */

.modal-content {
    padding: 28px;
}

.modal-title {
    margin-bottom: 7px;

    color: var(--black);

    font-size: 20px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.025em;
}

.modal-description {
    color: var(--muted);

    font-size: 13px;
    line-height: 1.55;
}

.modal-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;

    margin-top: 24px;
}


/* =========================================================
   TABS
========================================================== */

.tabs {
    display: flex;
    align-items: center;
    gap: 3px;

    padding: 4px;

    border: 1px solid var(--border);
    border-radius: var(--radius-small);

    background: var(--surface-soft);
}

.tab {
    min-height: 34px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 0 12px;

    border-radius: 7px;

    background: transparent;
    color: var(--muted);

    font-size: 12px;
    font-weight: 600;

    cursor: pointer;

    transition:
        background var(--transition),
        color var(--transition),
        box-shadow var(--transition);
}

.tab:hover {
    color: var(--text);
}

.tab.is-active {
    background: var(--white);
    color: var(--text);

    box-shadow: var(--shadow-xs);
}


/* =========================================================
   TOGGLE
========================================================== */

.toggle {
    position: relative;

    width: 40px;
    height: 22px;

    display: inline-block;

    flex-shrink: 0;
}

.toggle input {
    position: absolute;

    width: 1px;
    height: 1px;

    opacity: 0;
}

.toggle span {
    position: absolute;
    inset: 0;

    border: 1px solid var(--border-strong);
    border-radius: 999px;

    background: #e8edf3;

    cursor: pointer;

    transition:
        background var(--transition),
        border-color var(--transition);
}

.toggle span::after {
    content: "";

    position: absolute;
    top: 2px;
    left: 2px;

    width: 16px;
    height: 16px;

    border-radius: 50%;

    background: var(--white);

    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.16);

    transition: transform var(--transition);
}

.toggle input:checked + span {
    border-color: var(--blue);
    background: var(--blue);
}

.toggle input:checked + span::after {
    transform: translateX(18px);
}


/* =========================================================
   CHECKBOX
========================================================== */

.checkbox {
    position: relative;

    display: inline-flex;
    align-items: center;
    gap: 8px;

    color: var(--text-soft);

    font-size: 13px;

    cursor: pointer;
}

.checkbox input {
    width: 16px;
    height: 16px;

    margin: 0;

    accent-color: var(--blue);

    cursor: pointer;
}


/* =========================================================
   RADIO
========================================================== */

.radio {
    display: inline-flex;
    align-items: center;
    gap: 8px;

    color: var(--text-soft);

    font-size: 13px;

    cursor: pointer;
}

.radio input {
    width: 16px;
    height: 16px;

    margin: 0;

    accent-color: var(--blue);

    cursor: pointer;
}


/* =========================================================
   AVATAR
========================================================== */

.avatar {
    width: 36px;
    height: 36px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    flex-shrink: 0;

    border: 1px solid var(--border);
    border-radius: 50%;

    background: var(--blue-light);
    color: var(--blue);

    font-size: 12px;
    font-weight: 700;
}

.avatar-small {
    width: 30px;
    height: 30px;

    font-size: 10px;
}

.avatar-large {
    width: 48px;
    height: 48px;

    font-size: 15px;
}


/* =========================================================
   ICON CONTAINER
========================================================== */

.icon-container {
    width: 40px;
    height: 40px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    flex-shrink: 0;

    border: 1px solid var(--border);
    border-radius: var(--radius-small);

    background: var(--surface-soft);
    color: var(--blue);
}

.icon-container svg {
    width: 19px;
    height: 19px;
}


/* =========================================================
   LIST
========================================================== */

.list {
    display: flex;
    flex-direction: column;
}

.list-item {
    min-height: 58px;

    display: flex;
    align-items: center;
    gap: 13px;

    padding: 10px 14px;

    border-bottom: 1px solid var(--border);
}

.list-item:last-child {
    border-bottom: 0;
}

.list-item-content {
    min-width: 0;
    flex: 1;
}

.list-item-title {
    overflow: hidden;

    color: var(--text);

    font-size: 13px;
    font-weight: 600;

    white-space: nowrap;
    text-overflow: ellipsis;
}

.list-item-description {
    margin-top: 2px;

    overflow: hidden;

    color: var(--muted);

    font-size: 11px;

    white-space: nowrap;
    text-overflow: ellipsis;
}


/* =========================================================
   EMPTY STATE COMPONENT
========================================================== */

.component-empty {
    min-height: 260px;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    padding: 36px;

    text-align: center;
}

.component-empty-icon {
    width: 48px;
    height: 48px;

    display: flex;
    align-items: center;
    justify-content: center;

    margin-bottom: 15px;

    border: 1px solid var(--border);
    border-radius: var(--radius);

    background: var(--surface-soft);
    color: var(--muted);
}

.component-empty-icon svg {
    width: 21px;
    height: 21px;
}

.component-empty h3 {
    margin-bottom: 5px;

    color: var(--text);

    font-size: 15px;
    font-weight: 650;
}

.component-empty p {
    max-width: 380px;

    color: var(--muted);

    font-size: 12px;
    line-height: 1.55;
}

.component-empty .button {
    margin-top: 18px;
}


/* =========================================================
   ALERT
========================================================== */

.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;

    padding: 12px 14px;

    border: 1px solid var(--border);
    border-radius: var(--radius-small);

    background: var(--surface-soft);
    color: var(--text-soft);

    font-size: 12px;
    line-height: 1.5;
}

.alert-icon {
    width: 18px;
    height: 18px;

    display: flex;
    align-items: center;
    justify-content: center;

    flex-shrink: 0;
}

.alert-info {
    border-color: #d8e2f4;
    background: var(--blue-light);
    color: var(--blue);
}

.alert-success {
    border-color: #d5eee3;
    background: var(--success-light);
    color: var(--success);
}

.alert-warning {
    border-color: #f1dfb5;
    background: var(--warning-light);
    color: var(--warning);
}

.alert-danger {
    border-color: #efd1d1;
    background: var(--danger-light);
    color: var(--danger);
}


/* =========================================================
   PROGRESS
========================================================== */

.progress {
    width: 100%;
    height: 6px;

    overflow: hidden;

    border-radius: 999px;

    background: #e8edf3;
}

.progress-bar {
    width: 0;
    height: 100%;

    border-radius: inherit;

    background: var(--blue);

    transition: width 300ms ease;
}


/* =========================================================
   STATUS LABEL
========================================================== */

.status-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;

    color: var(--muted);

    font-size: 11px;
    font-weight: 600;
}

.status-label.is-online {
    color: var(--success);
}

.status-label.is-warning {
    color: var(--warning);
}

.status-label.is-error {
    color: var(--danger);
}


/* =========================================================
   CHIP
========================================================== */

.chip {
    min-height: 28px;

    display: inline-flex;
    align-items: center;
    gap: 6px;

    padding: 0 9px;

    border: 1px solid var(--border);
    border-radius: 999px;

    background: var(--surface-soft);
    color: var(--text-soft);

    font-size: 11px;
    font-weight: 600;
}

.chip button {
    width: 15px;
    height: 15px;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 0;

    border-radius: 50%;

    background: transparent;
    color: var(--muted);

    cursor: pointer;
}

.chip button:hover {
    color: var(--text);
}


/* =========================================================
   TOOLBAR
========================================================== */

.toolbar {
    min-height: 48px;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;

    margin-bottom: 20px;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}


/* =========================================================
   DIVIDER LABEL
========================================================== */

.divider-label {
    display: flex;
    align-items: center;
    gap: 12px;

    color: var(--muted);

    font-size: 11px;
    font-weight: 600;
}

.divider-label::before,
.divider-label::after {
    content: "";

    flex: 1;

    height: 1px;

    background: var(--border);
}


/* =========================================================
   SETTINGS ROW
========================================================== */

.setting-row {
    min-height: 68px;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;

    padding: 14px 0;

    border-bottom: 1px solid var(--border);
}

.setting-row:last-child {
    border-bottom: 0;
}

.setting-row > div:first-child {
    min-width: 0;
    flex: 1;
}

.setting-row strong {
    display: block;

    color: var(--text);

    font-size: 13px;
    font-weight: 600;
}

.setting-row span {
    display: block;

    margin-top: 3px;

    color: var(--muted);

    font-size: 11px;
    line-height: 1.45;
}


/* =========================================================
   TOOLTIP
========================================================== */

.tooltip {
    position: absolute;

    padding: 6px 8px;

    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 6px;

    background: var(--black);
    color: var(--white);

    font-size: 11px;
    font-weight: 500;
    line-height: 1.2;

    white-space: nowrap;

    box-shadow: var(--shadow-small);

    z-index: 1200;
}


/* =========================================================
   RESPONSIVE
========================================================== */

@media (max-width: 640px) {

    .modal-overlay {
        align-items: flex-end;

        padding: 12px;
    }

    .modal {
        max-height: calc(100vh - 24px);

        border-radius: var(--radius-large);
    }

    .modal-content {
        padding: 24px 20px;
    }

    .toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .toolbar-left,
    .toolbar-right {
        width: 100%;
    }

    .toolbar-right {
        justify-content: flex-end;
    }

    .search-field {
        max-width: none;
    }

    .setting-row {
        align-items: flex-start;
    }
}