/**
 * Admin Panel Styles
 * Settings categories, toggle switches, and form controls
 */

/* ===================================================================
   Panel Layout
   =================================================================== */

.admin-panel {
    max-width: 900px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

.admin-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.admin-panel-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary, #e2e8f0);
}

.admin-panel-header h2 i {
    margin-right: 0.5rem;
    color: var(--color-primary, #6366f1);
}

.admin-panel-actions {
    display: flex;
    gap: 0.5rem;
}

/* ===================================================================
   Buttons
   =================================================================== */

.admin-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s ease, opacity 0.15s ease;
}

.admin-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.admin-btn-primary {
    background: var(--color-primary, #6366f1);
    color: #fff;
}

.admin-btn-primary:hover:not(:disabled) {
    background: var(--color-primary-hover, #4f46e5);
}

.admin-btn-secondary {
    background: var(--bg-tertiary, #334155);
    color: var(--text-primary, #e2e8f0);
}

.admin-btn-secondary:hover:not(:disabled) {
    background: var(--bg-hover, #475569);
}

/* ===================================================================
   Status banner
   =================================================================== */

.admin-status {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.admin-status i {
    font-size: 1rem;
}

.admin-status-success {
    background: rgba(34, 197, 94, 0.12);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.25);
}

.admin-status-error {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.25);
}

/* ===================================================================
   Categories
   =================================================================== */

.admin-categories {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.admin-category {
    background: var(--bg-secondary, #1e293b);
    border: 1px solid var(--border, #334155);
    border-radius: 12px;
    overflow: hidden;
    transition: border-color 0.15s ease;
}

.admin-category:hover {
    border-color: var(--border-hover, #475569);
}

.admin-category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.1s ease;
}

.admin-category-header:hover {
    background: var(--bg-hover, rgba(255, 255, 255, 0.03));
}

.admin-category-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-primary, #e2e8f0);
}

.admin-category-title i {
    color: var(--color-primary, #6366f1);
    width: 20px;
    text-align: center;
}

.admin-category-count {
    font-weight: 400;
    font-size: 0.75rem;
    color: var(--text-tertiary, #64748b);
    margin-left: 0.25rem;
}

.admin-category-arrow {
    color: var(--text-tertiary, #64748b);
    font-size: 0.75rem;
    transition: transform 0.2s ease;
}

.admin-category-body {
    border-top: 1px solid var(--border, #334155);
    padding: 0.5rem 0;
}

/* ===================================================================
   Setting rows
   =================================================================== */

.admin-setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    gap: 1rem;
    transition: background-color 0.1s ease;
}

.admin-setting-row:hover {
    background: var(--bg-hover, rgba(255, 255, 255, 0.02));
}

.admin-setting-info {
    flex: 1;
    min-width: 0;
}

.admin-setting-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary, #e2e8f0);
    margin-bottom: 0.125rem;
    cursor: pointer;
}

.admin-setting-desc {
    display: block;
    font-size: 0.75rem;
    color: var(--text-tertiary, #64748b);
    line-height: 1.4;
}

.admin-setting-control {
    flex-shrink: 0;
    min-width: 140px;
    display: flex;
    justify-content: flex-end;
}

/* ===================================================================
   Toggle switch
   =================================================================== */

.admin-toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    cursor: pointer;
}

.admin-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.admin-toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-tertiary, #334155);
    border-radius: 12px;
    transition: background-color 0.2s ease;
}

.admin-toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s ease;
}

.admin-toggle input:checked + .admin-toggle-slider {
    background: var(--color-primary, #6366f1);
}

.admin-toggle input:checked + .admin-toggle-slider::before {
    transform: translateX(20px);
}

.admin-toggle input:focus-visible + .admin-toggle-slider {
    outline: 2px solid var(--color-primary, #6366f1);
    outline-offset: 2px;
}

/* ===================================================================
   Text / number inputs
   =================================================================== */

.admin-input {
    width: 140px;
    padding: 0.375rem 0.625rem;
    background: var(--bg-primary, #0f172a);
    color: var(--text-primary, #e2e8f0);
    border: 1px solid var(--border, #334155);
    border-radius: 6px;
    font-size: 0.8125rem;
    font-family: inherit;
    transition: border-color 0.15s ease;
}

.admin-input:focus {
    outline: none;
    border-color: var(--color-primary, #6366f1);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.admin-input[type="number"] {
    width: 100px;
}

/* ===================================================================
   Loading / error states
   =================================================================== */

.admin-loading,
.admin-error {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary, #94a3b8);
    font-size: 0.9375rem;
}

.admin-loading i,
.admin-error i {
    margin-right: 0.5rem;
}

.admin-error {
    color: #ef4444;
}

/* ===================================================================
   Responsive
   =================================================================== */

@media (max-width: 640px) {
    .admin-panel {
        padding: 1rem 0.5rem;
    }

    .admin-panel-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .admin-setting-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .admin-setting-control {
        width: 100%;
        justify-content: flex-start;
    }

    .admin-input {
        width: 100%;
    }

    .admin-input[type="number"] {
        width: 100%;
    }
}

/* ===================================================================
   Admin Shell Panel
   =================================================================== */

.admin-shell-badge {
    display: inline-block;
    padding: 1px 7px;
    background: rgba(168, 85, 247, 0.18);
    color: var(--color-primary, #a855f7);
    border: 1px solid rgba(168, 85, 247, 0.35);
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    margin-left: 0.5rem;
    vertical-align: middle;
    text-transform: uppercase;
}

.admin-shell-panel {
    background: #0a0a14;
    border-radius: 8px;
    overflow: hidden;
    font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Courier New', monospace;
    font-size: 0.8rem;
    border: 1px solid rgba(168, 85, 247, 0.2);
}

/* Toolbar */
.admin-shell-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.875rem;
    background: #12122a;
    border-bottom: 1px solid rgba(168, 85, 247, 0.15);
}

.admin-shell-toolbar-label {
    color: #a78bca;
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.admin-shell-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.admin-shell-tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 3px 8px;
    background: rgba(168, 85, 247, 0.08);
    border: 1px solid rgba(168, 85, 247, 0.2);
    border-radius: 5px;
    color: #a78bca;
    font-size: 0.7rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    font-family: inherit;
}

.admin-shell-tool-btn:hover {
    background: rgba(168, 85, 247, 0.18);
    color: #c4b5fd;
}

.admin-shell-autoscroll-label {
    cursor: pointer;
    user-select: none;
}

/* Log output area */
.admin-shell-log {
    height: 200px;
    overflow-y: auto;
    padding: 0.625rem 0.875rem;
    background: #0a0a14;
    scrollbar-width: thin;
    scrollbar-color: rgba(168, 85, 247, 0.25) transparent;
}

.admin-shell-log::-webkit-scrollbar { width: 5px; }
.admin-shell-log::-webkit-scrollbar-thumb { background: rgba(168, 85, 247, 0.25); border-radius: 3px; }

.admin-shell-log-entry {
    display: flex;
    gap: 0.5rem;
    padding: 1px 0;
    line-height: 1.5;
    font-size: 0.75rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.shell-log-ts {
    color: #4a5568;
    flex-shrink: 0;
    font-size: 0.7rem;
}

.shell-log-level {
    flex-shrink: 0;
    font-weight: 600;
}

.shell-log-msg {
    color: #c4b5fd;
    flex: 1;
    min-width: 0;
}

.shell-log-info .shell-log-level  { color: #60a5fa; }
.shell-log-warn .shell-log-level  { color: #fbbf24; }
.shell-log-error .shell-log-level { color: #f87171; }
.shell-log-error .shell-log-msg   { color: #f87171; }
.shell-log-cmd .shell-log-level   { color: #a3e635; }
.shell-log-cmd .shell-log-msg     { color: #d9f99d; }

.admin-shell-log-placeholder,
.admin-shell-log-empty {
    color: #4a5568;
    font-size: 0.75rem;
    padding: 0.25rem 0;
}

.admin-shell-log-error {
    color: #f87171;
    font-size: 0.75rem;
    padding: 0.25rem 0;
}

/* Section divider */
.admin-shell-divider {
    padding: 0.375rem 0.875rem;
    background: #0d0d1f;
    border-top: 1px solid rgba(168, 85, 247, 0.12);
    border-bottom: 1px solid rgba(168, 85, 247, 0.12);
    color: #6366f1;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

/* Command output area */
.admin-shell-output {
    max-height: 220px;
    overflow-y: auto;
    padding: 0.5rem 0.875rem;
    background: #0a0a14;
    scrollbar-width: thin;
    scrollbar-color: rgba(168, 85, 247, 0.2) transparent;
}

.admin-shell-output::-webkit-scrollbar { width: 5px; }
.admin-shell-output::-webkit-scrollbar-thumb { background: rgba(168, 85, 247, 0.2); border-radius: 3px; }

.admin-shell-out-line {
    font-size: 0.8rem;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
    color: #c4b5fd;
}

.shell-out-cmd    { color: #a3e635; font-weight: 600; }
.shell-out-stdout { color: #e2e8f0; }
.shell-out-error  { color: #f87171; }

/* Command input row */
.admin-shell-input-row {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.875rem;
    background: #12122a;
    border-top: 1px solid rgba(168, 85, 247, 0.15);
}

.admin-shell-prompt {
    color: #a3e635;
    font-weight: 700;
    font-size: 0.875rem;
    flex-shrink: 0;
    user-select: none;
}

.admin-shell-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #e2e8f0;
    font-size: 0.8rem;
    font-family: inherit;
    caret-color: #a855f7;
    min-width: 0;
}

.admin-shell-input::placeholder {
    color: #4a5568;
}

.admin-shell-input:disabled {
    opacity: 0.5;
}

.admin-shell-run-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 4px 10px;
    background: rgba(168, 85, 247, 0.2);
    border: 1px solid rgba(168, 85, 247, 0.35);
    border-radius: 6px;
    color: #c4b5fd;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}

.admin-shell-run-btn:hover:not(:disabled) {
    background: rgba(168, 85, 247, 0.35);
    color: #fff;
}

.admin-shell-run-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
