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

:root {
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --color-bg: #000000;
    --color-surface: rgba(255, 255, 255, 0.03);
    --color-surface-hover: rgba(255, 255, 255, 0.06);
    --color-border: rgba(255, 255, 255, 0.08);
    --color-text: #ffffff;
    --color-text-secondary: rgba(255, 255, 255, 0.5);
    --color-text-tertiary: rgba(255, 255, 255, 0.3);
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-text: linear-gradient(135deg, #667eea 0%, #f093fb 50%, #f5576c 100%);
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    font-weight: 300;
    min-height: 100vh;
}

/* ========== Background ========== */
.bg-gradient {
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at 50% 0%, rgba(102, 126, 234, 0.15) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

.bg-grid {
    position: fixed;
    inset: 0;
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
    z-index: -1;
}

/* ========== Header ========== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--color-border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 400;
}

.nav-links {
    display: flex;
    gap: 1rem;
}

.btn-ghost {
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text);
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition-fast);
    font-family: inherit;
}

.btn-ghost:hover {
    background: var(--color-surface);
    border-color: rgba(255, 255, 255, 0.2);
}

/* ========== Main Container ========== */
.main-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* ========== Hero Section ========== */
.hero-section {
    text-align: center;
    padding: 8rem 2rem 3rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 2rem;
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    margin-bottom: 1.5rem;
}

.badge .dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.hero-title {
    font-size: clamp(2.5rem, 8vw, 4rem);
    font-weight: 200;
    line-height: 1.1;
    margin-bottom: 1rem;
    letter-spacing: -0.03em;
}

.gradient-text {
    background: var(--gradient-text);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-desc {
    font-size: 1.1rem;
    color: var(--color-text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

/* ========== Dashboard Section ========== */
.dashboard-section {
    padding: 2rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.panel-full {
    grid-column: 1 / -1;
}

/* ========== Panel ========== */
.panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 1rem;
    padding: 1.5rem;
}

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

.panel-header h3 {
    font-size: 1rem;
    font-weight: 400;
}

/* ========== Table ========== */
.table-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.data-table th,
.data-table td {
    padding: 0.75rem 0.5rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.data-table th {
    font-weight: 400;
    color: var(--color-text-secondary);
    white-space: nowrap;
}

.data-table td {
    color: var(--color-text);
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.empty-cell {
    text-align: center;
    color: var(--color-text-secondary);
    padding: 2rem !important;
}

/* ========== Buttons ========== */
.btn-primary, .btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 9999px;
    font-size: 0.9rem;
    font-weight: 400;
    cursor: pointer;
    transition: var(--transition-normal);
    border: none;
    font-family: inherit;
}

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

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 20px rgba(255, 255, 255, 0.2);
}

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

.btn-secondary {
    background: transparent;
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.btn-primary.btn-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

.btn-full {
    width: 100%;
}

/* ========== Form Elements ========== */
.form-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.form-row .input-group {
    flex: 1;
    min-width: 150px;
}

.input-group {
    margin-bottom: 1rem;
}

.input-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    margin-bottom: 0.5rem;
}

.input-group input,
.input-group select,
.input-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    color: var(--color-text);
    font-family: inherit;
    font-size: 0.9rem;
    transition: var(--transition-fast);
}

.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus {
    outline: none;
    border-color: rgba(102, 126, 234, 0.5);
}

.input-group input::placeholder {
    color: var(--color-text-tertiary);
}

/* ========== Icon Button ========== */
.icon-btn {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
}

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

.icon-btn.danger:hover {
    color: #ff6b6b;
    border-color: rgba(255, 107, 107, 0.3);
}

/* ========== Badge ========== */
.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 0.25rem;
    font-size: 0.75rem;
    color: var(--color-text-secondary);
}

.badge-success {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.3);
    color: #22c55e;
}

.badge-danger {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

.required {
    color: #ef4444;
}

/* ========== Test Panel ========== */
.test-panel .test-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.test-result {
    margin-top: 1rem;
    border-top: 1px solid var(--color-border);
    padding-top: 1rem;
}

.result-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    color: var(--color-text-secondary);
}

.latency {
    color: var(--color-text-tertiary);
}

.result-content {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    padding: 1rem;
    max-height: 200px;
    overflow-y: auto;
}

.result-content code {
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.8rem;
    line-height: 1.5;
    white-space: pre-wrap;
}

/* ========== Docs Panel ========== */
.docs-panel .docs-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.doc-item {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--color-border);
}

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

.doc-title {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    margin-bottom: 0.5rem;
}

.endpoint {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.method {
    padding: 0.2rem 0.4rem;
    background: #22c55e;
    color: #000;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 0.25rem;
}

.endpoint code {
    font-size: 0.85rem;
}

.code-snippet {
    padding: 0.5rem 0.75rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 0.5rem;
}

.code-snippet code {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
}

.code-block pre {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    padding: 0.75rem;
    overflow-x: auto;
}

.code-block code {
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.75rem;
    line-height: 1.5;
}

/* ========== Footer ========== */
.footer {
    padding: 2rem;
    text-align: center;
    border-top: 1px solid var(--color-border);
}

.copyright {
    font-size: 0.8rem;
    color: var(--color-text-tertiary);
}

/* ========== Modal ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition-normal);
}

.modal-overlay:not(.hidden) {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 1.5rem;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.95);
    transition: var(--transition-normal);
}

.modal.modal-sm {
    max-width: 360px;
}

.modal.modal-lg {
    max-width: 800px;
}

.modal-overlay:not(.hidden) .modal {
    transform: scale(1);
}

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

.modal-header h3 {
    font-weight: 400;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--color-text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    transition: var(--transition-fast);
}

.close-btn:hover {
    color: var(--color-text);
}

.modal-body {
    padding: 1.5rem;
}

/* ========== Modal Tabs ========== */
.modal-tabs-header {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
}

.tab-btn {
    padding: 0.5rem 1rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 0.5rem;
    color: var(--color-text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition-fast);
    font-family: inherit;
}

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

.tab-btn.active {
    color: var(--color-text);
    background: var(--color-surface);
    border-color: var(--color-border);
}

.admin-body {
    max-height: 60vh;
    overflow-y: auto;
}

.admin-body .panel-header {
    margin-bottom: 1rem;
}

.admin-body .panel-header h4 {
    font-weight: 400;
    font-size: 0.9rem;
}

.url-code {
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    word-break: break-all;
}

.key-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    margin-bottom: 0.75rem;
}

.key-box code {
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.85rem;
    word-break: break-all;
}

.warning {
    font-size: 0.85rem;
    color: #ff9f43;
    margin-bottom: 1rem;
}

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

/* ========== Toast ========== */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 0.75rem 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    font-size: 0.9rem;
    z-index: 200;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

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

/* ========== Responsive ========== */
@media (max-width: 900px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .header {
        padding: 1rem;
    }
    
    .hero-section {
        padding: 6rem 1rem 2rem;
    }
    
    .dashboard-section {
        padding: 1rem;
    }
    
    .panel {
        padding: 1rem;
    }
    
    .form-row {
        flex-direction: column;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .toast {
        left: 1rem;
        right: 1rem;
    }
}
