/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background-color: #ffffff;
    color: #24292f;
    line-height: 1.5;
}

#app {
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header styles */
#header {
    background-color: #f6f8fa;
    border-bottom: 1px solid #d1d9e0;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

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

.header-logo {
    height: 32px;
    width: auto;
}

.header-left h1 {
    font-size: 24px;
    font-weight: 600;
    color: #24292f;
}

#repo-input {
    padding: 6px 12px;
    border: 1px solid #d1d9e0;
    border-radius: 6px;
    font-size: 14px;
    width: 300px;
}

#repo-input:focus {
    outline: none;
    border-color: #0969da;
    box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.1);
}

button {
    padding: 6px 16px;
    border: 1px solid #d1d9e0;
    border-radius: 6px;
    background-color: #f6f8fa;
    color: #24292f;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s;
}

button:hover {
    background-color: #f3f4f6;
}

button:active {
    background-color: #e9ecef;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

#user-info {
    font-size: 14px;
    color: #656d76;
}

/* Main container */
#main-container {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Sidebar styles */
#sidebar {
    width: 300px;
    background-color: #f6f8fa;
    border-right: 1px solid #d1d9e0;
    overflow-y: auto;
    flex-shrink: 0;
}

.tree-container {
    padding: 16px;
}

.tree-item {
    padding: 4px 8px;
    cursor: pointer;
    border-radius: 6px;
    margin: 2px 0;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
}

.tree-item:hover {
    background-color: #e9ecef;
}

.tree-item.selected {
    background-color: #dbeafe;
    color: #1e40af;
}

.expand-icon {
    width: 16px;
    font-size: 14px;
    color: #656d76;
    cursor: pointer;
    padding: 2px;
    margin-right: 2px;
}

.item-icon {
    font-size: 14px;
}

.item-name {
    flex: 1;
}

.tree-item.dir {
    font-weight: 500;
}

.tree-children {
    margin-left: 20px;
}

/* Main content area */
#main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    width: 0; /* Force flexbox to calculate proper width */
}

/* Tab styles */
#tab-container {
    border-bottom: 1px solid #d1d9e0;
    background-color: #f6f8fa;
}

.tabs {
    display: flex;
    padding: 0 16px;
}

.tab-button {
    padding: 12px 16px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #656d76;
}

.tab-button.active {
    color: #24292f;
    border-bottom-color: #fd7e14;
}

.tab-button:hover {
    color: #24292f;
    background-color: rgba(0, 0, 0, 0.03);
}

/* Tab content container */
#tab-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
}

/* Tab panels */
.tab-panel {
    display: none;
    flex: 1;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
}

.tab-panel.active {
    display: flex;
}

.controls {
    padding: 12px 16px;
    background-color: #f6f8fa;
    border-bottom: 1px solid #d1d9e0;
    display: flex;
    gap: 16px;
    align-items: center;
}

.controls label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    cursor: pointer;
}

.controls input[type="checkbox"] {
    cursor: pointer;
}

/* Silhouette tab styles */
#code-container {
    flex: 1;
    padding: 16px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    width: 100%;
    min-width: 0;
}

#code-display {
    background-color: #f6f8fa;
    border: 1px solid #d1d9e0;
    border-radius: 6px;
    padding: 16px;
    overflow-x: auto;
    overflow-y: auto;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
    flex: 1;
    min-height: 0;
    min-width: 0;
}

#code-content {
    white-space: pre;
    margin: 0;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    display: block;
    width: max-content;
    min-width: 100%;
}

/* Override Prism.js styling to match our consistent styling */
#code-content[class*="language-"],
#code-content.language-*,
code[class*="language-"],
pre[class*="language-"] {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    text-shadow: none !important;
    text-align: left !important;
    background: none !important;
    color: inherit !important;
    display: block !important;
    width: max-content !important;
    min-width: 100% !important;
    white-space: pre !important;
}

/* Ensure all content inside code-content uses consistent styling */
#code-content * {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
}

/* Black and white mode */
.bw-mode #code-content,
.bw-mode #code-content.language-text {
    color: #000000 !important;
}

.bw-mode #code-content *,
.bw-mode #code-content.language-text * {
    color: #000000 !important;
    background-color: transparent !important;
}

/* Ensure language-text always renders as plain black text */
#code-content.language-text {
    color: #000000 !important;
}

#code-content.language-text * {
    color: #000000 !important;
    background-color: transparent !important;
}

/* Silhouette (BAM) mode */
.bam-mode .char {
    color: inherit;
}

.bam-mode .char:not(.whitespace) {
    color: transparent;
}

.bam-mode .char:not(.whitespace)::before {
    content: "█";
    color: inherit;
}

/* Lexicon tab styles */
#lexicon-container {
    flex: 1;
    overflow: hidden;
    position: relative;
}

#cards-canvas {
    width: 100%;
    height: 100%;
    padding: 16px;
    overflow: auto;
    position: relative;
    background-color: #ffffff;
}

.token-card {
    position: absolute;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #d1d9e0;
    cursor: move;
    user-select: none;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.2s;
}

.token-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.token-card.dragging {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    transform: rotate(5deg);
}

.token-card.class {
    background-color: #dbeafe;
    border-color: #93c5fd;
    color: #1e40af;
}

.token-card.function {
    background-color: #dcfce7;
    border-color: #86efac;
    color: #166534;
}

/* Utility styles */
.loading {
    padding: 20px;
    text-align: center;
    color: #656d76;
    font-style: italic;
}

.error {
    padding: 16px;
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    color: #dc2626;
    margin: 16px;
    display: none;
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    min-width: 300px;
    max-width: 600px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.error.show {
    display: block;
}

.error.success {
    background-color: #f0f9ff;
    border-color: #93c5fd;
    color: #1e40af;
}

.error.info {
    background-color: #fffbeb;
    border-color: #fbbf24;
    color: #92400e;
}

/* Responsive design */
@media (max-width: 768px) {
    #main-container {
        flex-direction: column;
    }
    
    #sidebar {
        width: 100%;
        max-height: 200px;
    }
    
    #main {
        width: 100% !important;
        min-width: auto !important;
    }
    
    .header-left {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }
    
    #repo-input {
        width: 100%;
        max-width: 250px;
    }
}

/* Deployment Info */
#deployment-info {
    position: fixed;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.8);
    color: #ccc;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-family: monospace;
    z-index: 1000;
    max-width: 300px;
    text-align: right;
    line-height: 1.2;
}

/* About tab styles */
#about-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.about-content {
    max-width: 800px;
    margin: 0 auto;
    line-height: 1.6;
}

.about-content h2 {
    font-size: 28px;
    font-weight: 600;
    color: #24292f;
    margin-bottom: 24px;
    text-align: center;
}

.about-content h3 {
    font-size: 20px;
    font-weight: 600;
    color: #24292f;
    margin: 32px 0 16px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid #d1d9e0;
}

.about-content h4 {
    font-size: 16px;
    font-weight: 600;
    color: #24292f;
    margin: 24px 0 12px 0;
}

.about-content p {
    margin-bottom: 16px;
    color: #24292f;
}

.about-content ul, .about-content ol {
    margin-bottom: 16px;
    padding-left: 24px;
}

.about-content li {
    margin-bottom: 8px;
    color: #24292f;
}

.about-content strong {
    font-weight: 600;
    color: #24292f;
}

.about-section {
    margin-bottom: 32px;
}

.about-section:last-child {
    margin-bottom: 16px;
}

/* Footer styles */
#footer {
    background-color: #f6f8fa;
    border-top: 1px solid #d1d9e0;
    padding: 12px 16px;
    text-align: center;
    flex-shrink: 0;
}

.footer-content {
    font-size: 12px;
    color: #656d76;
}

.footer-content span {
    margin-right: 16px;
}

.footer-content span:last-child {
    margin-right: 0;
}

.footer-content a {
    color: #0969da;
    text-decoration: none;
}

.footer-content a:hover {
    text-decoration: underline;
}