/* css/style.css */

:root {
    --font-mono: 'JetBrains Mono', monospace;
}

body.theme-dark {
    --bg-color: #051426;
    --surface-color: rgba(17, 24, 39, 0.95);
    --surface-header: #0d1c2f;
    --border-color: rgba(51, 65, 85, 0.4);
    --text-primary: #d5e3fd;
    --text-muted: #869585;
    --accent-color: #22c55e;
    --accent-secondary: #38bdf8;
    --accent-glow: rgba(34, 197, 94, 0.15);
    --error-color: #ffb4ab;
}

body.theme-light {
    --bg-color: #f3f4f6;
    --surface-color: rgba(255, 255, 255, 0.95);
    --surface-header: #e5e7eb;
    --border-color: rgba(209, 213, 219, 0.8);
    --text-primary: #1f2937;
    --text-muted: #6b7280;
    --accent-color: #059669;
    --accent-secondary: #0284c7;
    --accent-glow: rgba(5, 150, 105, 0.15);
    --error-color: #dc2626;
}

body.theme-peach {
    --bg-color: #fff5eb;
    --surface-color: rgba(255, 247, 237, 0.95);
    --surface-header: #ffedd5;
    --border-color: rgba(253, 186, 116, 0.8);
    --text-primary: #431407;
    --text-muted: #9a3412;
    --accent-color: #ea580c;
    --accent-secondary: #d97706;
    --accent-glow: rgba(234, 88, 12, 0.15);
    --error-color: #b91c1c;
}

/* Fallback for elements using variables before body class loads */
body {
    --bg-color: #051426;
    --surface-color: rgba(17, 24, 39, 0.95);
    --surface-header: #0d1c2f;
    --border-color: rgba(51, 65, 85, 0.4);
    --text-primary: #d5e3fd;
    --text-muted: #869585;
    --accent-color: #22c55e;
    --accent-secondary: #38bdf8;
    --accent-glow: rgba(34, 197, 94, 0.15);
    --error-color: #ffb4ab;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
    position: relative;
    user-select: none;
}

/* Background Gradients/Glows */
.bg-glow-1 {
    position: absolute;
    top: 15%;
    left: 20%;
    width: 40vw;
    height: 40vw;
    background: radial-gradient(circle, rgba(34, 197, 94, 0.05) 0%, rgba(34, 197, 94, 0) 70%);
    pointer-events: none;
    z-index: 0;
}

.bg-glow-2 {
    position: absolute;
    bottom: 15%;
    right: 20%;
    width: 45vw;
    height: 45vw;
    background: radial-gradient(circle, rgba(56, 189, 248, 0.05) 0%, rgba(56, 189, 248, 0) 70%);
    pointer-events: none;
    z-index: 0;
}

/* Header Section */
header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 64px;
    background: rgba(5, 20, 38, 0.9);
    backdrop-filter: blur(10px);
    border-b: 1px solid var(--border-color);
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
}

.header-logo {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent-color);
    letter-spacing: -0.5px;
}

.header-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(17, 32, 51, 0.6);
    border: 1px solid var(--border-color);
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 11px;
    color: var(--text-muted);
}

.header-badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--accent-color);
    box-shadow: 0 0 8px var(--accent-color);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.admin-link-btn {
    color: var(--text-primary);
    text-decoration: none;
    font-size: 13px;
    border: 1px solid var(--border-color);
    padding: 6px 14px;
    border-radius: 4px;
    background: transparent;
    transition: all 0.2s ease;
}

.admin-link-btn:hover {
    border-color: var(--accent-secondary);
    color: var(--accent-secondary);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.2);
}

/* Main Layout */
main {
    position: relative;
    margin-top: 64px;
    height: calc(100vh - 64px);
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    z-index: 10;
}

.terminal-container {
    width: 100%;
    max-width: 1000px;
    flex: 1;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 10px 40px -10px var(--accent-glow);
    margin-bottom: 24px;
    position: relative;
}

/* CRT Scanline Filter */
.crt-effect::before {
    content: " ";
    display: block;
    position: absolute;
    top: 0; left: 0; bottom: 0; right: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.12) 50%), 
                linear-gradient(90deg, rgba(255, 0, 0, 0.02), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.02));
    z-index: 99;
    background-size: 100% 3px, 3px 100%;
    pointer-events: none;
}

/* Terminal Header */
.terminal-header {
    height: 40px;
    background: var(--surface-header);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    flex-shrink: 0;
}

.terminal-dots {
    display: flex;
    gap: 6px;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}
.dot-red { background-color: #ff5f56; }
.dot-yellow { background-color: #ffbd2e; }
.dot-green { background-color: #27c93f; }

.terminal-title {
    font-size: 12px;
    color: var(--text-muted);
    opacity: 0.8;
}

/* Terminal Area (Output + Inputs) */
.terminal-body {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    position: relative;
    scroll-behavior: smooth;
}

.terminal-output {
    white-space: pre-wrap;
    word-break: break-all;
}

.output-row {
    margin-bottom: 12px;
}

.output-row.command {
    color: var(--accent-secondary);
}

.output-row.error {
    color: var(--error-color);
}

/* Command Prompt Line */
.prompt-line {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 8px;
    position: relative;
}

.prompt-prefix {
    color: var(--accent-secondary);
    white-space: nowrap;
}

.prompt-input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.prompt-input {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: var(--accent-color);
    font-family: var(--font-mono);
    font-size: 14px;
    caret-color: transparent; /* custom cursor */
    z-index: 10;
}

.prompt-ghost {
    position: absolute;
    left: 0;
    top: 0;
    color: var(--text-muted);
    opacity: 0.35;
    pointer-events: none;
    z-index: 5;
    white-space: pre;
}

.blinking-cursor {
    display: inline-block;
    width: 8px;
    height: 15px;
    background-color: var(--text-primary);
    animation: blink 0.9s infinite;
    position: absolute;
    z-index: 6;
}

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

/* Stats Footer */
.stats-container {
    width: 100%;
    max-width: 1000px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.stat-card {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    padding: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.3s ease;
}

.stat-card:hover {
    border-color: var(--accent-color);
    box-shadow: 0 0 15px rgba(34, 197, 94, 0.1);
}

.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.stat-icon.pub { background: rgba(34, 197, 94, 0.1); color: var(--accent-color); }
.stat-icon.cit { background: rgba(56, 189, 248, 0.1); color: var(--accent-secondary); }
.stat-icon.hnd { background: rgba(168, 85, 247, 0.1); color: #a855f7; }

.stat-info p:first-child {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-info p:last-child {
    font-size: 20px;
    font-weight: 700;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: #051426;
}
::-webkit-scrollbar-thumb {
    background: #1c2b3e;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #273649;
}

/* Matrix Digital Rain Easter Egg */
#matrix-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 150;
    display: none;
}

/* Overlay Detail Panel */
.detail-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 20, 38, 0.85);
    backdrop-filter: blur(8px);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.detail-content {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 100%;
    max-width: 600px;
    box-shadow: 0 0 25px var(--accent-glow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.detail-header h3 {
    color: var(--accent-secondary);
    font-size: 16px;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 14px;
}

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

.detail-body {
    padding: 24px;
    max-height: 70vh;
    overflow-y: auto;
}

.detail-row {
    margin-bottom: 16px;
}

.detail-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 4px;
}

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

.detail-link {
    display: inline-block;
    margin-top: 12px;
    color: var(--accent-color);
    text-decoration: none;
    border: 1px solid var(--accent-color);
    padding: 6px 14px;
    border-radius: 4px;
}

.detail-link:hover {
    background: rgba(34, 197, 94, 0.1);
}

.book-cover {
    max-width: 150px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    margin-bottom: 12px;
    display: block;
}

/* Sticky Header inside Terminal body when viewing items */
.sticky-terminal-prompt {
    position: sticky;
    top: 0;
    background: var(--surface-color);
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 16px;
    z-index: 20;
}

/* Responsiveness */
@media (max-width: 768px) {
    body {
        font-size: 13px;
    }
    
    header {
        padding: 0 16px;
    }

    main {
        padding: 16px;
    }

    .stats-container {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .terminal-body {
        padding: 16px;
    }
    
    .detail-content {
        max-width: 100%;
    }
}
