:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a25;
    --bg-glass: rgba(18, 18, 26, 0.8);
    --text-primary: #e8e8f0;
    --text-secondary: #a0a0b0;
    --text-muted: #606070;
    --accent-primary: #00d4aa;
    --accent-secondary: #7c3aed;
    --error: #ef4444;
    --success: #22c55e;
    --font-main: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

/* Login Screen */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

.login-box {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 3rem;
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-box h1 {
    font-family: var(--font-mono);
    font-size: 2rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    text-align: left;
    margin-bottom: 1rem;
}

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

.input-group input {
    background: var(--bg-tertiary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    transition: all 0.3s;
}

.input-group input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(0, 212, 170, 0.1);
}

.input-group input[readonly] {
    background: rgba(255, 255, 255, 0.05);
    cursor: not-allowed;
}

.login-btn {
    width: 100%;
    background: var(--accent-primary);
    color: var(--bg-primary);
    border: none;
    border-radius: 8px;
    padding: 0.875rem;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 0.5rem;
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 212, 170, 0.3);
}

.setup-message {
    background: rgba(0, 212, 170, 0.1);
    border: 1px solid rgba(0, 212, 170, 0.2);
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 1rem;
    color: var(--accent-primary);
    font-size: 0.875rem;
}

.setup-message.hidden {
    display: none;
}

.error {
    color: var(--error);
    font-size: 0.875rem;
    margin-top: 1rem;
}

/* Admin Panel Layout */
.admin-panel {
    display: flex;
    min-height: 100vh;
}

.hidden {
    display: none !important;
}

/* Sidebar */
.sidebar {
    width: 240px;
    background: var(--bg-secondary);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-mono);
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 2rem;
}

.sidebar-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-brand .logo {
    margin-bottom: 0;
}

.admin-label {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.prompt {
    color: var(--accent-primary);
}

.nav-links {
    list-style: none;
    flex: 1;
}

.nav-links li {
    margin-bottom: 0.5rem;
}

.nav-links a {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.3s;
    font-family: var(--font-mono);
    font-size: 0.9rem;
}

.nav-links a:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.nav-links a.active {
    background: rgba(0, 212, 170, 0.1);
    color: var(--accent-primary);
}

/* Terminal Link Styling */
.terminal-link {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    color: var(--accent-secondary) !important;
}

.terminal-link:hover {
    background: rgba(124, 58, 237, 0.1) !important;
    color: #a78bfa !important;
}

.terminal-link svg {
    flex-shrink: 0;
}

.logout-btn {
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--error);
    padding: 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-family: var(--font-mono);
    width: 100%;
    margin-top: 0.5rem;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.1);
}

.user-info {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
    position: sticky;
    bottom: 0;
    background: var(--bg-secondary);
    padding-bottom: 0.5rem;
}

.user-info span {
    display: block;
    color: var(--accent-primary);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

/* Main Content */
.content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

.tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.tab-header h2 {
    font-size: 1.75rem;
    font-weight: 600;
}

.actions {
    display: flex;
    gap: 1rem;
}

/* Buttons */
.btn-primary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--accent-primary);
    color: var(--bg-primary);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 212, 170, 0.3);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-add {
    background: transparent;
    border: 2px dashed rgba(0, 212, 170, 0.3);
    color: var(--accent-primary);
    padding: 1rem;
    border-radius: 8px;
    cursor: pointer;
    width: 100%;
    transition: all 0.3s;
    font-family: var(--font-mono);
}

.btn-add:hover {
    background: rgba(0, 212, 170, 0.1);
    border-style: solid;
}

.btn-icon {
    font-family: var(--font-mono);
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Editor Grid */
.editor-grid {
    display: grid;
    gap: 1.5rem;
}

.form-section {
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 1.5rem;
}

.form-section h3 {
    font-size: 1.1rem;
    margin-bottom: 1.25rem;
    color: var(--accent-primary);
    font-family: var(--font-mono);
}

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

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

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    transition: all 0.3s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(0, 212, 170, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
    font-family: var(--font-main);
}

/* Tag Input */
.tag-input {
    background: var(--bg-tertiary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 0.5rem;
}

.tag-input input {
    background: transparent;
    border: none;
    padding: 0.5rem;
    color: var(--text-primary);
    width: 100%;
    outline: none;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.tag {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(0, 212, 170, 0.1);
    color: var(--accent-primary);
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.875rem;
}

.tag button {
    background: none;
    border: none;
    color: var(--accent-primary);
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0;
}

.help-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    font-style: italic;
}

.alternate-titles {
    min-height: auto;
}

/* Dynamic Items */
.dynamic-item {
    background: var(--bg-tertiary);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    position: relative;
}

.dynamic-item .remove-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(239, 68, 68, 0.1);
    border: none;
    color: var(--error);
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.dynamic-item .remove-btn:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* Preview */
.preview-container {
    background: var(--bg-secondary);
    border-radius: 12px;
    overflow: hidden;
    height: calc(100vh - 200px);
}

.preview-container iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Version History */
.version-list {
    max-height: 300px;
    overflow-y: auto;
}

.version-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

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

.version-date {
    font-family: var(--font-mono);
    color: var(--text-secondary);
    font-size: 0.875rem;
}

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

.version-actions button {
    background: var(--bg-tertiary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    padding: 0.4rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.3s;
}

.version-actions button:hover {
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

/* Notification */
.notification {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s;
    z-index: 1000;
}

.notification.show {
    transform: translateY(0);
    opacity: 1;
}

.notification.success {
    background: var(--success);
}

.notification.error {
    background: var(--error);
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--bg-tertiary);
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

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

.modal-header h3 {
    margin: 0;
    color: var(--accent-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
    overflow: auto;
}

.modal-body pre {
    background: var(--bg-primary);
    border: 1px solid var(--bg-tertiary);
    border-radius: 8px;
    padding: 1rem;
    margin: 0;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 60vh;
    overflow: auto;
}

/* Responsive */
@media (max-width: 768px) {
    .admin-panel {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        padding: 0.75rem 1rem;
        position: relative;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        min-height: auto;
    }
    
    .logo {
        margin-bottom: 0;
        font-size: 1.1rem;
    }
    
    .nav-links {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background: var(--bg-secondary);
        flex-direction: column;
        justify-content: flex-start;
        align-items: stretch;
        gap: 0.5rem;
        z-index: 1000;
        margin: 0;
        padding: 4rem 1.5rem 2rem 1.5rem;
        overflow-y: auto;
    }
    
    .nav-links.active {
        display: flex;
    }
    
    .nav-links li {
        margin: 0;
        width: 100%;
    }
    
    .nav-links a {
        font-size: 1rem;
        padding: 0.875rem 1rem;
        text-align: left;
    }
    
    /* Fixed mobile user section */
    .user-info {
        display: none;
    }
    
    .user-info.mobile-visible {
        display: flex;
        flex-direction: column;
        margin-top: auto;
        padding-top: 1.5rem;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        width: 100%;
        gap: 0.75rem;
    }
    
    .user-info.mobile-visible span {
        text-align: left;
        margin-bottom: 0;
        font-size: 0.9rem;
    }
    
    .user-info.mobile-visible .logout-btn {
        margin-top: 0;
        width: 100%;
    }
    
    /* Show user info in header on mobile */
    .sidebar-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
    }
    
    .mobile-user-preview {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        margin-left: auto;
        margin-right: 1rem;
    }
    
    .mobile-user-preview span {
        color: var(--accent-primary);
        font-family: var(--font-mono);
        font-size: 0.8rem;
    }
    
    .mobile-user-preview .logout-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
        width: auto;
        margin-top: 0;
    }
    
    .content {
        padding: 1rem;
    }
    
    /* Hide desktop brand on mobile */
    .sidebar-brand {
        display: none;
    }
    
    /* Tab header adjustments */
    .tab-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .actions {
        width: 100%;
    }
    
    .btn-primary, .btn-secondary {
        flex: 1;
        justify-content: center;
    }
    
    /* Hamburger Menu Button */
    .menu-toggle {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        width: 24px;
        height: 18px;
        cursor: pointer;
        z-index: 1001;
        padding: 0;
        background: none;
        border: none;
    }
    
    .menu-toggle span {
        display: block;
        width: 100%;
        height: 2px;
        background: var(--text-primary);
        border-radius: 2px;
        transition: all 0.3s;
    }
    
    .menu-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(5.5px, 5.5px);
    }
    
    .menu-toggle.active span:nth-child(2) {
        opacity: 0;
    }
    
    .menu-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(5.5px, -5.5px);
    }
    
    /* Close button for mobile menu */
    .mobile-menu-close {
        position: absolute;
        top: 1rem;
        right: 1rem;
        background: none;
        border: none;
        color: var(--text-primary);
        font-size: 1.75rem;
        cursor: pointer;
        z-index: 1002;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 8px;
    }
    
    .mobile-menu-close:hover {
        background: rgba(255, 255, 255, 0.1);
    }
}

@media (min-width: 769px) {
    .menu-toggle {
        display: none;
    }
    
    .mobile-menu-close {
        display: none;
    }
    
    .user-info.mobile-visible {
        display: none;
    }
    
    /* Hide mobile user preview on desktop */
    .mobile-user-preview {
        display: none;
    }
    
    /* Hide sidebar header on desktop */
    .sidebar-header {
        display: none;
    }
    
    /* Sidebar sticks to viewport on desktop */
    .sidebar {
        height: 100vh;
        position: sticky;
        top: 0;
        overflow-y: auto;
    }
    
    /* Scrollbar styling for sidebar */
    .sidebar::-webkit-scrollbar {
        width: 4px;
    }
    
    .sidebar::-webkit-scrollbar-track {
        background: transparent;
    }
    
    .sidebar::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.1);
        border-radius: 2px;
    }
}

/* Mobile user info in nav menu */
.mobile-user-info-item {
    list-style: none;
    margin-top: auto;
    padding-top: 1rem;
}

@media (min-width: 769px) {
    .mobile-user-info-item {
        display: none;
    }
}

/* ============================================================================
   API Tokens Section
   ============================================================================ */

.tokens-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    max-width: 1200px;
}

@media (max-width: 1024px) {
    .tokens-grid {
        grid-template-columns: 1fr;
    }
}

.new-token-display {
    margin-top: 1.5rem;
    padding: 1rem;
    background: rgba(92, 124, 250, 0.1);
    border: 1px solid var(--accent);
    border-radius: 4px;
}

.new-token-display h4 {
    margin: 0 0 0.5rem 0;
    color: var(--accent);
}

.new-token-display .warning {
    color: var(--accent);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

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

.token-value code {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    padding: 0.75rem;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    word-break: break-all;
    color: var(--accent);
}

.tokens-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.token-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 4px;
}

.token-item.revoked {
    opacity: 0.5;
}

.token-item.expired {
    border-color: var(--accent);
    opacity: 0.7;
}

.token-info {
    flex: 1;
}

.token-name {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.token-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.token-meta span {
    margin-right: 1rem;
}

.token-meta .label {
    color: var(--text-secondary);
}

.token-meta .value {
    color: var(--text-primary);
}

.token-status {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.token-status.active {
    background: rgba(74, 222, 128, 0.1);
    color: #4ade80;
}

.token-status.revoked {
    background: rgba(248, 113, 113, 0.1);
    color: #f87171;
}

.token-status.expired {
    background: rgba(251, 191, 36, 0.1);
    color: #fbbf24;
}

.revoke-token-btn {
    padding: 0.5rem 1rem;
    background: rgba(248, 113, 113, 0.1);
    color: #f87171;
    border: 1px solid rgba(248, 113, 113, 0.3);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.revoke-token-btn:hover {
    background: rgba(248, 113, 113, 0.2);
}

.no-tokens {
    color: var(--text-secondary);
    font-style: italic;
}
