/* ==========================================================================
   SIBLE DESIGN SYSTEM — themes.css
   Consolidated component styles (replaces components/ directory).
   Sections: Badges, Buttons, Cards, Editor, Inputs, Modals, Nav, Tables, Toasts
   ========================================================================== */


/* ==========================================================================
   1. BADGES & STATUS DOTS
   ========================================================================== */

/* --- Group Badge --- */
.group-badge {
    background: #f5f5f5;
    color: #444444;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    display: inline-block;
}

[data-theme='dark'] .group-badge {
    background: #313244;
    color: #cdd6f4;
}

/* --- Status Dots --- */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--ds-gray-200);
    display: inline-block;
}

.status-dot.success,
.status-dot.online {
    background-color: var(--sible-success);
    box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.2);
}

.status-dot.failed,
.status-dot.offline {
    background-color: var(--sible-error);
}

.status-dot.running {
    background-color: #0070f3;
    animation: pulse 1.5s infinite;
}

[data-theme='dark'] .status-dot {
    background-color: var(--pico-muted-color);
}

[data-theme='dark'] .status-dot.running {
    background-color: var(--pico-primary-hover);
}

/* --- Badge System --- */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
    min-width: 70px;
    height: 24px;
    gap: 6px;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.badge i,
.badge svg {
    width: 12px;
    height: 12px;
}

.badge-success,
.status-success-badge {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--status-success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-error,
.badge-failed,
.status-failed-badge {
    background-color: rgba(238, 0, 0, 0.1);
    color: var(--status-error);
    border: 1px solid rgba(238, 0, 0, 0.2);
}

.badge-warning {
    background-color: rgba(245, 166, 35, 0.1);
    color: var(--status-warning);
    border: 1px solid rgba(245, 166, 35, 0.2);
}

.badge-secondary {
    background-color: var(--ds-gray-alpha-400);
    color: var(--text-muted);
    border: 1px solid var(--border-subtle);
}

.status-btn {
    border: none;
    cursor: pointer;
    background: transparent;
    padding: 0;
    display: inline-flex;
    text-decoration: none;
}

.status-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

[data-theme='dark'] .status-btn:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

[data-theme='dark'] .badge-success,
[data-theme='dark'] .status-success-badge {
    background-color: rgba(166, 227, 161, 0.1);
    border-color: rgba(166, 227, 161, 0.2);
}

[data-theme='dark'] .badge-error,
[data-theme='dark'] .badge-failed,
[data-theme='dark'] .status-failed-badge {
    background-color: rgba(243, 139, 168, 0.1);
    border-color: rgba(243, 139, 168, 0.2);
}

[data-theme='dark'] .badge-warning {
    background-color: rgba(250, 179, 135, 0.1);
    border-color: rgba(250, 179, 135, 0.2);
}


/* ==========================================================================
   2. BUTTONS
   ========================================================================== */

button {
    font-weight: 500;
    font-size: 0.875rem;
    padding: 0 12px;
    height: 32px;
    border-radius: 6px;
    transition: all 0.15s ease;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: none !important;
    outline: none !important;
    letter-spacing: -0.02em;
}

button:focus,
button:active,
[role="group"] button:focus,
[role="group"] button:active,
[role="group"] :focus,
.nav-item:focus,
.nav-item:active,
.playbook-item:focus,
.playbook-item:active,
a:focus,
a:active {
    box-shadow: none !important;
    outline: none !important;
}

button.primary:focus {
    background: #000;
    border-color: #000;
}

[role="group"] button.primary:active,
button.primary:active {
    background: #444 !important;
    border-color: #444 !important;
}

[role="group"] button.secondary:active,
button.secondary:active {
    background: var(--ds-gray-200) !important;
    border-color: var(--ds-gray-200) !important;
}

/* Primary Button (Black Solid) */
button.primary,
button[type="submit"],
.btn-new {
    background: #000000;
    color: #ffffff;
    border: 1px solid #000000;
}

button.primary:hover,
button[type="submit"]:hover,
.btn-new:hover {
    background: #333;
    border-color: #333;
    color: #fff;
    transform: translateY(-1px);
}

/* Aggressive fix for all button icons */
button.primary svg,
button.primary [data-lucide],
button.primary .lucide,
button.primary i {
    stroke: currentColor !important;
    color: inherit !important;
}

[data-theme='dark'] button.primary {
    color: #000000 !important;
}

[data-theme='dark'] button.primary svg,
[data-theme='dark'] button.primary [data-lucide],
[data-theme='dark'] button.primary .lucide {
    stroke: #000000 !important;
    stroke-width: 2.5px !important;
}

[data-theme='dark'] button.primary svg *,
[data-theme='dark'] button.primary [data-lucide] *,
[data-theme='dark'] button.primary .lucide * {
    stroke: #000000 !important;
}

/* Secondary Button (White with Border) */
button.secondary,
button.outline {
    background: #ffffff;
    border: 1px solid #eaeaea;
    color: #000000;
}

button.secondary:hover,
button.outline:hover {
    background: #fafafa;
    border-color: #000;
    color: #000;
}

/* Danger Button */
button.danger {
    background: #ffffff;
    border: 1px solid #eaeaea;
    color: var(--sible-error);
}

button.danger:hover {
    background: #fff5f5;
    border-color: var(--sible-error);
}

/* Icon Button (Square) */
button.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid #eaeaea;
    background: #ffffff;
    color: var(--ds-gray-1000);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

button.btn-icon:hover {
    background: #fafafa;
    border-color: #000;
    color: #000;
}

/* Specific trigger highlight */
.terminal-trigger:hover i,
.terminal-trigger:active i {
    stroke: #000 !important;
    stroke-width: 2.5px;
}

/* --- Dark Theme: Buttons --- */
[data-theme='dark'] button.primary {
    background: var(--pico-primary);
    border-color: var(--pico-primary);
    color: var(--pico-primary-inverse);
}

[data-theme='dark'] button.primary:hover {
    background: var(--pico-primary-hover);
    border-color: var(--pico-primary-hover);
}

[data-theme='dark'] button.secondary {
    background: transparent;
    border: 1px solid var(--pico-border-color);
    color: var(--pico-primary);
}

[data-theme='dark'] button.secondary:hover {
    background: rgba(180, 190, 254, 0.1);
    border-color: var(--pico-primary-hover);
}


/* ==========================================================================
   3. CARDS
   ========================================================================== */

.card,
.server-card {
    background: var(--surface-primary);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    box-shadow: none;
    margin: 0;
    overflow: hidden;
}


/* ==========================================================================
   4. EDITOR & TERMINAL
   ========================================================================== */

/* --- Ansible Log Styling (Geist) --- */
#terminal-container {
    padding: 16px;
    font-family: 'Geist Mono', 'SF Mono', 'Menlo', monospace;
    font-size: 13px;
    color: var(--ds-gray-1000);
    background-color: #ffffff;
    overflow-y: auto;
    height: 100%;
    box-shadow: none;
    border-radius: 0;
}

/* Log Levels */
.log-meta {
    color: #000000;
    font-weight: 600;
    margin-top: 0.5rem;
    margin-bottom: 0.25rem;
    border-bottom: 1px solid var(--ds-gray-200);
    padding-bottom: 2px;
}

.log-success {
    color: #10B981;
}

.log-changed {
    color: #F59E0B;
}

.log-error {
    color: #EE0000;
    font-weight: 500;
}

.log-debug {
    color: #666666;
}

/* SSH Terminal Container */
#ssh-terminal-container {
    background: #ffffff !important;
}

/* --- Dark Theme: Editor & Terminal --- */
[data-theme='dark'] #terminal-container {
    background: #181825 !important;
    color: var(--pico-color);
    border: none;
}

[data-theme='dark'] .log-meta {
    color: var(--pico-primary);
    border-bottom: 1px solid var(--pico-border-color);
}

[data-theme='dark'] .log-success {
    color: var(--status-success);
}

[data-theme='dark'] .log-changed {
    color: var(--status-changed);
}

[data-theme='dark'] .log-error {
    color: var(--status-error);
}

[data-theme='dark'] .log-debug {
    color: var(--pico-muted-color);
}

[data-theme='dark'] #ssh-terminal-container {
    background: #181825 !important;
}


/* ==========================================================================
   5. INPUTS
   ========================================================================== */

/* --- Base Inputs --- */
input,
select,
textarea {
    background: var(--ds-background-200) !important;
    border: 1px solid #eaeaea !important;
    color: #000000 !important;
    border-radius: 6px !important;
    box-shadow: none !important;
    transition: all 0.15s ease;
}

input[type="file"] {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
}

/* Force Light Grey on Autofill */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus,
select:-webkit-autofill,
select:-webkit-autofill:hover,
select:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0px 1000px var(--ds-background-200) inset !important;
    -webkit-text-fill-color: var(--ds-gray-1000) !important;
    transition: background-color 5000s ease-in-out 0s;
}

input[type="file"]::file-selector-button {
    background: #000000;
    color: #ffffff;
    border: 1px solid #000000;
    padding: 0 12px;
    height: 32px;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    margin-right: 12px;
    cursor: pointer;
    transition: background 0.15s ease;
    vertical-align: middle;
}

input[type="file"]::file-selector-button:hover {
    background: #333;
    border-color: #333;
}

input:focus,
select:focus,
textarea:focus {
    border-color: #000 !important;
    box-shadow: none !important;
    outline: none !important;
}

/* --- Geist Custom Select --- */
.geist-select-container {
    position: relative;
    width: 100%;
}

.geist-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 32px;
    padding: 0 8px 0 12px;
    background: #ffffff;
    border: 1px solid #eaeaea;
    border-radius: 6px;
    font-size: 13px;
    color: #000;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.geist-select-trigger:hover {
    border-color: #888;
}

.geist-select-trigger:focus,
.geist-select-trigger[aria-expanded="true"] {
    border-color: #000000;
    outline: none;
}

.geist-select-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    width: 100%;
    min-width: 220px;
    background: #ffffff;
    border: 1px solid #eaeaea;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 50;
    max-height: 300px;
    overflow-y: auto;
    padding: 4px;
    display: none;
}

.geist-select-header {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #888;
    padding: 8px 12px 4px;
    font-weight: 500;
    pointer-events: none;
}

.geist-select-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    font-size: 13px;
    color: #000;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.15s;
}

.geist-select-option:hover {
    background: #fafafa;
}

.geist-select-option.selected {
    font-weight: 500;
    background: #fafafa;
}

.geist-select-option .check-icon {
    margin-left: auto;
    opacity: 0;
    stroke: #000;
}

.geist-select-option.selected .check-icon {
    opacity: 1;
}

/* --- Dark Theme: Inputs --- */
[data-theme='dark'] input,
[data-theme='dark'] select,
[data-theme='dark'] textarea {
    background: var(--pico-form-element-background-color) !important;
    border: 1px solid var(--pico-form-element-border-color) !important;
    color: var(--pico-color) !important;
}

[data-theme='dark'] input:focus,
[data-theme='dark'] select:focus,
[data-theme='dark'] textarea:focus {
    border-color: var(--pico-primary) !important;
}

[data-theme='dark'] input:-webkit-autofill,
[data-theme='dark'] textarea:-webkit-autofill,
[data-theme='dark'] select:-webkit-autofill {
    -webkit-box-shadow: 0 0 0px 1000px var(--pico-form-element-background-color) inset !important;
    -webkit-text-fill-color: var(--pico-color) !important;
}

input[type="file"],
[data-theme='dark'] input[type="file"] {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

[data-theme='dark'] input[type="file"]::file-selector-button {
    background: var(--pico-primary);
    border: 1px solid var(--pico-primary);
    color: var(--pico-primary-inverse);
}

[data-theme='dark'] input[type="file"]::file-selector-button:hover {
    background: var(--pico-primary-hover);
    border-color: var(--pico-primary-hover);
}


/* ==========================================================================
   6. MODALS
   ========================================================================== */

.sible-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Force flex display when shown by Alpine */
.sible-modal-backdrop:not([style*="display: none"]) {
    display: flex !important;
}

/* Use display: contents to let the article be centered by the backdrop's flexbox */
.sible-modal-backdrop dialog {
    display: contents !important;
    position: static !important;
}

/* Ensure the modal content is properly styled as the flex child */
.sible-modal-backdrop article.modal-content {
    position: relative !important;
    margin: 0 !important;
    width: auto !important;
    min-width: 500px;
    max-width: 90vw;
    z-index: 10000;
}

/* SSH Modal specific centering wrapper */
.ssh-modal-wrapper {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

article.modal-content {
    background: var(--surface-primary);
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border-subtle);
    overflow: hidden;
    animation: modalScaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}


/* ==========================================================================
   7. NAVIGATION
   ========================================================================== */

/* --- Sidebar Folder - Force Black on Open/Focus --- */
details>summary {
    list-style: none;
    outline: none;
    cursor: pointer;
    color: var(--ds-gray-600);
    transition: color 0.15s ease;
    font-weight: 500;
    font-size: 0.9rem;
    padding: 6px 0;
    user-select: none;
}

details[open]>summary,
details>summary:focus,
details>summary:active,
details>summary:hover,
.folder-title:hover {
    color: var(--ds-gray-1000) !important;
    outline: none !important;
}

details>summary::-webkit-details-marker {
    display: none;
}

/* --- Nav Items (Vertical List) --- */
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    color: #666666;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 2px;
    border-left: 2px solid transparent;
    transition: all 0.15s ease;
    border-radius: 0;
}

.nav-item:hover {
    color: #000000;
    background: #fafafa;
}

.nav-item.active {
    color: #000000;
    border-left-color: #000000;
    background: transparent;
}

.nav-item i {
    width: 16px;
    height: 16px;
    stroke-width: 2px;
}

.sidebar-btn-container {
    margin-bottom: 8px;
}

/* --- Sidebar Folder --- */
.sidebar-folder summary {
    list-style: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--ds-gray-600);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: color 0.15s, background 0.15s;
}

.sidebar-folder summary:hover,
.sidebar-folder[open]>summary {
    color: var(--ds-gray-1000);
    background: rgba(0, 0, 0, 0.03);
}

.sidebar-folder summary::-webkit-details-marker {
    display: none;
}

/* --- Playbook Items --- */
.playbook-item {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    margin-bottom: 2px;
    border-radius: 6px;
    font-size: 0.875rem;
    color: var(--ds-gray-600);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
    gap: 8px;
}

.playbook-item:hover {
    color: var(--ds-gray-1000);
    background: rgba(0, 0, 0, 0.03);
}

.playbook-item.active {
    background: #ffffff;
    color: #000000;
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    border: 1px solid #eaeaea;
}

/* --- Dark Theme: Navigation --- */
[data-theme='dark'] .nav-item {
    color: var(--pico-muted-color);
}

[data-theme='dark'] .nav-item:hover,
[data-theme='dark'] .nav-item.active {
    color: var(--pico-color);
    background: rgba(0, 0, 0, 0.1);
}

[data-theme='dark'] .nav-item.active {
    border-left-color: var(--pico-primary);
}

[data-theme='dark'] details>summary,
[data-theme='dark'] .sidebar-folder[open]>summary {
    color: var(--pico-color) !important;
    background: rgba(0, 0, 0, 0.1);
}

[data-theme='dark'] .playbook-item {
    color: var(--pico-muted-color);
}

[data-theme='dark'] .playbook-item:hover,
[data-theme='dark'] .playbook-item.active {
    color: var(--pico-color);
    background: rgba(0, 0, 0, 0.1);
    border: 1px solid var(--pico-border-color);
}

[data-theme='dark'] .playbook-item.active {
    box-shadow: 0 0 0 2px var(--pico-primary);
}


/* ==========================================================================
   8. TABLES
   ========================================================================== */

/* --- Base Table --- */
table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    color: var(--ds-gray-600);
    font-weight: 500;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 16px;
    border-bottom: 1px solid var(--ds-gray-200);
}

td {
    padding: 12px 16px;
    border-bottom: 1px solid #fafafa;
    color: var(--ds-gray-1000);
    font-size: 0.875rem;
}

tr:last-child td {
    border-bottom: none;
}

tr.hover:hover td {
    background: #fafafa;
}

/* --- Dark Theme: Tables --- */
[data-theme='dark'] th {
    color: var(--pico-muted-color);
    border-bottom: 1px solid var(--pico-border-color);
}

[data-theme='dark'] td {
    border-bottom: 1px solid var(--pico-border-color);
    color: var(--pico-color);
}

[data-theme='dark'] tr:last-child td {
    border-bottom: none;
}

[data-theme='dark'] tr.hover:hover td {
    background: rgba(0, 0, 0, 0.1);
}

/* --- Playbook Row & Quick Actions --- */
.playbook-row {
    cursor: pointer;
    transition: background-color 0.2s;
}

.playbook-row:hover {
    background-color: var(--surface-secondary) !important;
}

.playbook-row:hover .quick-actions {
    opacity: 1 !important;
}

.action-btn {
    background: transparent;
    border: none;
    padding: 6px;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.action-btn:hover {
    background: var(--surface-primary);
    color: var(--text-primary);
}

.action-btn i {
    width: 14px;
    height: 14px;
}

/* Status Text Links */
.status-text-failed:hover {
    color: var(--sible-error) !important;
}


/* ==========================================================================
   9. TOASTS
   ========================================================================== */

#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    background: #fff;
    border: 1px solid #eaeaea;
    color: #000;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    animation: slideIn 0.3s ease;
}

/* --- Dark Theme: Toasts --- */
[data-theme='dark'] .toast {
    background: #181825;
    border: 1px solid var(--pico-border-color);
    color: var(--pico-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}


/* ==========================================================================
   10. ANIMATIONS
   ========================================================================== */

.spin {
    animation: rotate 2s linear infinite;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}