/* ========================================
   Shared Dark Theme – evademo_web
   Based on Evalanche API Explorer design
   (Tailwind gray palette)
   ======================================== */

:root {
    /* Background colors */
    --color-bg-base: #111827;
    --color-bg-surface: #1f2937;
    --color-bg-elevated: #374151;
    --color-bg-hover: #4b5563;

    /* Text colors */
    --color-text-primary: #f3f4f6;
    --color-text-secondary: #d1d5db;
    --color-text-muted: #9ca3af;
    --color-text-faint: #6b7280;

    /* Accent colors */
    --color-accent: #3b82f6;
    --color-accent-light: #60a5fa;
    --color-accent-dark: #2563eb;
    --color-accent-hover: #1d4ed8;

    /* Status colors */
    --color-success: #22c55e;
    --color-success-light: #4ade80;
    --color-error: #ef4444;
    --color-error-light: #f87171;
    --color-warning: #f59e0b;

    /* Borders & shadows */
    --color-border: #374151;
    --color-border-light: #4b5563;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.4);

    /* Misc */
    --transition-fast: all 0.15s ease;
    --transition: all 0.2s ease;
    --transition-slow: all 0.3s ease;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
}

/* Reset */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Base */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--color-bg-base);
    color: var(--color-text-primary);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--color-text-primary);
    line-height: 1.3;
}

h1 {
    font-size: 1.875rem;
    font-weight: 700;
}

h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

a {
    color: var(--color-accent-light);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Cards */
.card {
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: var(--transition);
}

.card:hover {
    border-color: var(--color-border-light);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    color: white;
    font-family: inherit;
}

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

.btn-primary {
    background: var(--color-accent-dark);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--color-accent-hover);
}

.btn-success {
    background: var(--color-success);
    color: white;
}

.btn-success:hover:not(:disabled) {
    filter: brightness(1.1);
}

.btn-secondary {
    background: var(--color-bg-elevated);
    color: var(--color-text-primary);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--color-bg-hover);
}

/* Tool navigation buttons (Home / Admin Tools) */
.tool-nav-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    background: var(--color-bg-elevated);
    color: var(--color-text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.2;
    text-decoration: none;
    transition: var(--transition);
}

.tool-nav-button,
.tool-nav-button:link,
.tool-nav-button:visited,
.tool-nav-button:hover,
.tool-nav-button:active {
    color: var(--color-text-primary);
    text-decoration: none;
}

.tool-nav-button:hover {
    background: var(--color-bg-hover);
}

.tool-nav-button:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* Form Inputs */
input[type="text"],
input[type="number"],
input[type="password"],
input[type="email"],
input[type="url"],
input[type="date"],
textarea,
select {
    width: 100%;
    padding: 10px 14px;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
    color: var(--color-text-primary);
    font-size: 0.875rem;
    transition: var(--transition-fast);
    font-family: inherit;
}

input[type="date"] {
    color-scheme: dark;
}

input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.88);
    opacity: 0.9;
    cursor: pointer;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--color-accent);
}

input::placeholder,
textarea::placeholder {
    color: var(--color-text-faint);
}

/* Range Inputs */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: var(--color-bg-elevated);
    border-radius: 3px;
    outline: none;
    border: none;
    padding: 0;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--color-accent);
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition-fast);
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--color-accent-light);
    transform: scale(1.15);
}

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

th,
td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

th {
    background: rgba(59, 130, 246, 0.1);
    color: var(--color-accent-light);
    font-weight: 600;
    font-size: 0.875rem;
}

tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* Tags / Badges */
.tag {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    margin: 2px;
}

/* Status */
.status-success {
    color: var(--color-success-light);
}

.status-error {
    color: var(--color-error-light);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 14px 24px;
    background: var(--color-bg-surface);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    transform: translateX(150%);
    transition: var(--transition-slow);
}

.toast.show {
    transform: translateX(0);
}

.toast.success {
    background: var(--color-success);
    border-color: var(--color-success);
    color: white;
}

.toast.error {
    background: var(--color-error);
    border-color: var(--color-error);
    color: white;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-content {
    width: 100%;
    max-width: 480px;
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--color-border);
}

.modal-footer .btn {
    flex: 1;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-bg-base);
}

::-webkit-scrollbar-thumb {
    background: var(--color-bg-elevated);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-bg-hover);
}

/* Utilities */
.hidden {
    display: none !important;
}

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

.text-accent {
    color: var(--color-accent-light);
}

/* Autocomplete Dropdown */
.ac-wrap {
    position: relative;
}

.ac-dropdown {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    z-index: 500;
    max-height: 240px;
    overflow-y: auto;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border-light);
    border-top: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    box-shadow: var(--shadow-md);
}

.ac-dropdown.ac-open {
    display: block;
}

.ac-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 14px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.1s;
    border-bottom: 1px solid var(--color-border);
}

.ac-item:last-child {
    border-bottom: none;
}

.ac-item:hover,
.ac-item.ac-highlight {
    background: var(--color-bg-hover);
}

.ac-item-name {
    color: var(--color-text-primary);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ac-item-id {
    color: var(--color-text-faint);
    font-size: 0.75rem;
    font-family: monospace;
    margin-left: 12px;
    flex-shrink: 0;
}

.ac-item.ac-empty,
.ac-item.ac-loading {
    color: var(--color-text-faint);
    cursor: default;
    justify-content: center;
}

.ac-item.ac-loading {
    gap: 8px;
}

.ac-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--color-bg-hover);
    border-top-color: var(--color-accent-light);
    border-radius: 50%;
    animation: ac-spin 0.6s linear infinite;
}

@keyframes ac-spin {
    to { transform: rotate(360deg); }
}

/* API User Badge */
.api-user-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: 20px;
    font-size: 0.82rem;
    color: var(--color-text-secondary);
    white-space: nowrap;
}

.api-user-badge .fa-user {
    color: var(--color-accent-light);
    font-size: 0.78rem;
}

.api-user-name {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.api-status-icons {
    display: inline-flex;
    gap: 4px;
    font-size: 0.78rem;
    margin-left: 4px;
}

/* API Status Card (index.php) */
.api-status-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.api-status-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    padding: 8px 14px;
    background: var(--color-bg-elevated);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
}

.api-status-item .status-label {
    font-weight: 600;
    color: var(--color-text-secondary);
}

.api-status-item .status-ok {
    color: var(--color-success-light);
}

.api-status-item .status-fail {
    color: var(--color-error-light);
}

.api-status-item .status-pending {
    color: var(--color-text-faint);
}