/* Phoenix Echo Dashboard Theme */
:root {
    /* Colors - CRITICAL: NO PINK */
    --bg-primary: #0a0a0a;
    --bg-secondary: #111111;
    --bg-card: #161616;
    --accent-dark: #cc0000;
    --accent-bright: #ff1a1a;
    --gold: #d4a017;
    --text-primary: #e0e0e0;
    --text-muted: #606060;
    --border: #222222;
    --status-online: #00cc66;
    --status-error: #ff1a1a;
    --status-warning: #ffaa00;
    --status-info: #0099ff;
    
    /* Layout */
    --sidebar-width: 240px;
    --sidebar-collapsed: 56px;
    --header-height: 60px;
    
    /* Fonts */
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', Monaco, Consolas, 'Courier New', monospace;
    
    /* Borders & Radius */
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 14px;
    
    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.5);
    --glow-red: 0 0 20px rgba(255, 26, 26, 0.3);
    --glow-gold: 0 0 20px rgba(212, 160, 23, 0.3);
}

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

html, body {
    height: 100%;
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
}

#app {
    display: grid;
    grid-template-areas:
        "header header"
        "sidebar main";
    grid-template-rows: var(--header-height) 1fr;
    grid-template-columns: var(--sidebar-width) 1fr;
    height: 100vh;
    transition: grid-template-columns 0.3s ease;
}

#app.sidebar-collapsed {
    grid-template-columns: var(--sidebar-collapsed) 1fr;
}

/* Header */
.header {
    grid-area: header;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    z-index: 100;
}

.sidebar-toggle {
    background: none;
    border: none;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    transition: color 0.2s;
}

.sidebar-toggle:hover {
    color: var(--accent-bright);
}

.hamburger {
    display: block;
    width: 20px;
    height: 2px;
    background: currentColor;
    position: relative;
}

.hamburger::before,
.hamburger::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 2px;
    background: currentColor;
    left: 0;
    transition: transform 0.2s;
}

.hamburger::before {
    top: -6px;
}

.hamburger::after {
    bottom: -6px;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 18px;
}

.brand-icon {
    font-size: 24px;
}

.brand-name {
    background: linear-gradient(135deg, var(--accent-bright), var(--gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-status {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.health-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    transition: border-color 0.2s;
}

.health-badge:hover {
    border-color: var(--accent-dark);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: pulse 2s infinite;
}

.health-badge.online .status-dot {
    background: var(--status-online);
}

.health-badge.error .status-dot {
    background: var(--status-error);
}

.health-badge.warning .status-dot {
    background: var(--status-warning);
}

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

.icon-btn {
    background: none;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.icon-btn:hover {
    background: var(--bg-card);
    color: var(--accent-bright);
}

/* Sidebar */
.sidebar {
    grid-area: sidebar;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 0;
    transition: width 0.3s ease;
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

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

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

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.nav-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 0 16px 8px 16px;
    font-weight: 600;
    transition: opacity 0.3s;
}

#app.sidebar-collapsed .nav-section-title {
    opacity: 0;
    height: 0;
    padding: 0;
    overflow: hidden;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.2s;
    position: relative;
}

.nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    background: var(--accent-bright);
    transition: height 0.2s;
    border-radius: 0 2px 2px 0;
}

.nav-item:hover {
    background: var(--bg-card);
    color: var(--accent-bright);
}

.nav-item:hover::before {
    height: 20px;
}

.nav-item.active {
    background: var(--bg-card);
    color: var(--accent-bright);
}

.nav-item.active::before {
    height: 100%;
}

.nav-icon {
    font-size: 20px;
    min-width: 24px;
    text-align: center;
}

.nav-label {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    transition: opacity 0.3s;
}

#app.sidebar-collapsed .nav-label {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

#app.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 10px;
}

/* Main Content */
.main-content {
    grid-area: main;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px;
    background: var(--bg-primary);
}

.main-content::-webkit-scrollbar {
    width: 8px;
}

.main-content::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

.main-content::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.main-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Page Container */
#page-container {
    max-width: 1400px;
    margin: 0 auto;
}

/* Common Components */

/* Page Header */
.page-header {
    margin-bottom: 32px;
}

.page-title {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--text-primary), var(--text-muted));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.page-subtitle {
    font-size: 15px;
    color: var(--text-muted);
}

/* Cards */
.card {
    /* background: var(--bg-card); */
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
    transition: all 0.2s;
}

.card:hover {
    border-color: var(--accent-dark);
    box-shadow: var(--glow-red);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-actions {
    display: flex;
    gap: 8px;
}

/* Grid */
.grid {
    display: grid;
    gap: 24px;
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.grid-4 {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-family: var(--font-sans);
}

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

.btn-primary:hover {
    background: var(--accent-bright);
    box-shadow: var(--glow-red);
}

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

.btn-secondary:hover {
    border-color: var(--accent-dark);
    color: var(--accent-bright);
}

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

.btn-ghost:hover {
    background: var(--bg-card);
    color: var(--accent-bright);
}

.btn-small {
    padding: 6px 12px;
    font-size: 13px;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.badge-online {
    background: rgba(0, 204, 102, 0.15);
    color: var(--status-online);
    border: 1px solid rgba(0, 204, 102, 0.3);
}

.badge-error {
    background: rgba(255, 26, 26, 0.15);
    color: var(--status-error);
    border: 1px solid rgba(255, 26, 26, 0.3);
}

.badge-warning {
    background: rgba(255, 170, 0, 0.15);
    color: var(--status-warning);
    border: 1px solid rgba(255, 170, 0, 0.3);
}

.badge-info {
    background: rgba(0, 153, 255, 0.15);
    color: var(--status-info);
    border: 1px solid rgba(0, 153, 255, 0.3);
}

.badge-gold {
    background: rgba(212, 160, 23, 0.15);
    color: var(--gold);
    border: 1px solid rgba(212, 160, 23, 0.3);
}

/* Stats */
.stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-value.accent {
    color: var(--accent-bright);
}

.stat-value.gold {
    color: var(--gold);
}

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

.table th {
    text-align: left;
    padding: 12px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

.table td {
    padding: 16px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.table tr:hover td {
    background: rgba(255, 26, 26, 0.05);
}

.table code {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--gold);
    background: rgba(212, 160, 23, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font-sans);
    transition: border-color 0.2s;
}

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

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

/* Code Blocks */
pre {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
}

pre code {
    color: var(--text-primary);
}

/* Alerts */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    border-left: 4px solid;
}

.alert-info {
    background: rgba(0, 153, 255, 0.1);
    border-left-color: var(--status-info);
    color: var(--status-info);
}

.alert-warning {
    background: rgba(255, 170, 0, 0.1);
    border-left-color: var(--status-warning);
    color: var(--status-warning);
}

.alert-error {
    background: rgba(255, 26, 26, 0.1);
    border-left-color: var(--status-error);
    color: var(--status-error);
}

.alert-success {
    background: rgba(0, 204, 102, 0.1);
    border-left-color: var(--status-online);
    color: var(--status-online);
}

/* Loading */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
    color: var(--text-muted);
    font-size: 15px;
}

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent-bright);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Empty State */
.empty-state {
    text-align: center;
    padding: 64px 24px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.empty-state-text {
    font-size: 14px;
}

/* Chat Interface */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--header-height) - 48px);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-message {
    display: flex;
    gap: 12px;
    max-width: 80%;
}

.chat-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.message-content {
    background: var(--bg-secondary);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.chat-message.user .message-content {
    background: var(--accent-dark);
    border-color: var(--accent-bright);
}

.message-text {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
}

.message-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.chat-input-container {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 12px;
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font-sans);
    resize: none;
    max-height: 120px;
}

.chat-input:focus {
    outline: none;
    border-color: var(--accent-dark);
}

.chat-send-btn {
    padding: 12px 24px;
    background: var(--accent-dark);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-send-btn:hover:not(:disabled) {
    background: var(--accent-bright);
    box-shadow: var(--glow-red);
}

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

/* Responsive */
@media (max-width: 768px) {
    #app {
        grid-template-areas:
            "header"
            "main";
        grid-template-columns: 1fr;
        grid-template-rows: var(--header-height) 1fr;
    }
    
    .sidebar {
        position: fixed;
        left: -100%;
        top: var(--header-height);
        bottom: 0;
        width: var(--sidebar-width);
        z-index: 99;
        transition: left 0.3s ease;
    }
    
    #app.sidebar-open .sidebar {
        left: 0;
    }
    
    .main-content {
        padding: 16px;
    }
    
    .page-title {
        font-size: 24px;
    }
    
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }
    
    .chat-message {
        max-width: 90%;
    }
}

/* Utility Classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent-bright); }
.text-gold { color: var(--gold); }
.text-mono { font-family: var(--font-mono); }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.gap-3 { gap: 24px; }

.hidden { display: none !important; }

/* ===== PHOENIX VISUAL UPGRADE - Browser Echo ===== */

/* Full-page background logo */
.main-content {
  position: relative;
}

.main-content::before {
  content: '';
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-40%, -50%);
  width: 70vh;
  height: 70vh;
  background: url('/assets/icons/phoenix-logo-new.png') center/contain no-repeat;
  opacity: 0.07;
  z-index: 0;
  pointer-events: none;
}

/* Glassmorphism - Apple Glass Key Effect on all cards */
.card,
.chat-container,
.chat-message .message-content {
  background: rgba(22, 22, 22, 0.05) !important;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2);
}

.card:hover {
  border-color: rgba(212, 160, 23, 0.4) !important;
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.5),
    0 0 30px rgba(212, 160, 23, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* Gold accent enhancements */
.page-title {
  background: linear-gradient(135deg, #ff1a1a, #d4a017, #ff1a1a) !important;
  -webkit-background-clip: text !important;
  background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
}

.nav-item.active::before,
.nav-item:hover::before {
  background: linear-gradient(180deg, var(--accent-bright), var(--gold)) !important;
}

.nav-item.active {
  background: rgba(212, 160, 23, 0.08) !important;
}

.chat-send-btn {
  background: linear-gradient(135deg, #cc0000, #d4a017) !important;
  border: 1px solid rgba(212, 160, 23, 0.3) !important;
}

.chat-send-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #ff1a1a, #e8b020) !important;
  box-shadow: 0 0 20px rgba(212, 160, 23, 0.4) !important;
}

/* Gold border accents on header */
.header {
  border-bottom: 1px solid rgba(212, 160, 23, 0.2) !important;
  background: rgba(17, 17, 17, 0.8) !important;
  backdrop-filter: blur(20px);
}

/* Sidebar glass effect */
.sidebar {
  background: rgba(17, 17, 17, 0.7) !important;
  backdrop-filter: blur(20px) saturate(180%);
  border-right: 1px solid rgba(212, 160, 23, 0.15) !important;
}

/* Chat user messages gold accent */
.chat-message.user .message-content {
  background: linear-gradient(135deg, rgba(204, 0, 0, 0.8), rgba(180, 30, 0, 0.8)) !important;
  border: 1px solid rgba(212, 160, 23, 0.3) !important;
}

/* Phoenix logo as chat avatar for assistant */
.chat-message.assistant .message-avatar,
.chat-message .message-avatar:first-child {
  background: transparent !important;
  background-image: url('/assets/icons/phoenix-logo-new.png');
  background-size: cover;
  background-position: center;
  font-size: 0 !important;
  border: 2px solid var(--gold);
  box-shadow: 0 0 10px rgba(212, 160, 23, 0.3);
}

/* Typing indicator avatar too */
.typing-indicator .message-avatar {
  background: transparent !important;
  background-image: url('/assets/icons/phoenix-logo-new.png') !important;
  background-size: cover !important;
  font-size: 0 !important;
}

/* Glass effect on health badge */
.health-badge {
  background: rgba(22, 22, 22, 0.05) !important;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(212, 160, 23, 0.2) !important;
}

/* Gold scrollbar */
.main-content::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(212, 160, 23, 0.3) !important;
}

.main-content::-webkit-scrollbar-thumb:hover,
.chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(212, 160, 23, 0.5) !important;
}

/* Page container z-index to sit above background */
#page-container {
  position: relative;
  z-index: 1;
}

/* Chat container glass enhancement */
.chat-container {
  border: 1px solid rgba(212, 160, 23, 0.15) !important;
}

.chat-input-container {
  border-top: 1px solid rgba(212, 160, 23, 0.15) !important;
  background: rgba(10, 10, 10, 0.5);
  backdrop-filter: blur(20px);
}

.chat-input {
  background: rgba(17, 17, 17, 0.6) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  backdrop-filter: blur(10px);
}

.chat-input:focus {
  border-color: rgba(212, 160, 23, 0.4) !important;
  box-shadow: 0 0 10px rgba(212, 160, 23, 0.1);
}

/* ===== END PHOENIX VISUAL UPGRADE ===== */

/* ── DOC TABS ── */
.doc-tab {
    padding: 8px 16px;
    font-size: 13px;
    font-family: inherit;
    color: #999;
    background: transparent;
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
}
.doc-tab:hover {
    color: #e0e0e0;
    border-color: rgba(212, 160, 23, 0.3);
    background: #111;
}
.doc-tab.active {
    color: #d4a017;
    border-color: #d4a017;
    background: rgba(212, 160, 23, 0.08);
}
