/* GRID Navigation Prototype - Dark Theme */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #0a0a0a;
    color: #e0e0e0;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.container {
    max-width: 900px;
    width: 100%;
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    color: #888;
}

.breadcrumb-home {
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.breadcrumb-home:hover {
    background: #222;
}

#breadcrumb-trail span {
    margin-left: 4px;
}

.breadcrumb-item {
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.breadcrumb-item:hover {
    background: #222;
}

.breadcrumb-separator {
    color: #444;
    cursor: default;
}

/* Search bar */
.search-bar {
    margin-bottom: 20px;
}

#search-input {
    width: 100%;
    padding: 12px 16px;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 8px;
    color: #e0e0e0;
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
}

#search-input:focus {
    border-color: #555;
}

/* Grid */
.grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.tile {
    background: #1a1a1a;
    border: 2px solid #2a2a2a;
    border-radius: 12px;
    padding: 24px;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
}

.tile:hover {
    background: #252525;
    border-color: #3a3a3a;
    transform: translateY(-2px);
}

.tile.selected {
    border-color: #4a90e2;
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.3);
}

.tile.empty {
    background: #0f0f0f;
    border-color: #1a1a1a;
    opacity: 0.5;
    cursor: default;
}

.tile.empty:hover {
    background: #0f0f0f;
    transform: none;
}

.tile-slot {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 12px;
    color: #555;
    font-weight: 600;
}

.tile-type {
    font-size: 11px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.tile-label {
    font-size: 18px;
    font-weight: 500;
    color: #e0e0e0;
    flex-grow: 1;
    display: flex;
    align-items: center;
}

/* Type-specific colors */
.tile[data-type="deck"] {
    border-left: 3px solid #4a90e2;
}

.tile[data-type="link"] {
    border-left: 3px solid #50c878;
}

.tile[data-type="action"] {
    border-left: 3px solid #ff6b6b;
}

.tile[data-type="media"] {
    border-left: 3px solid #9b59b6;
}

.tile[data-type="file_pick"],
.tile[data-type="file_handle"] {
    border-left: 3px solid #6c5ce7;
}

.tile[data-type="dir_pick"],
.tile[data-type="dir_handle"] {
    border-left: 3px solid #00b894;
}

.tile[data-type="save_file"] {
    border-left: 3px solid #e17055;
}

.tile[data-type="deeplink"] {
    border-left: 3px solid #fdcb6e;
}

.tile[data-type="download"] {
    border-left: 3px solid #74b9ff;
}

.tile[data-type="nav"] {
    border-left: 3px solid #f39c12;
    font-weight: 600;
}

/* Mode indicator */
.mode-indicator {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 12px 16px;
    background: #1a1a1a;
    border-radius: 8px;
    border: 1px solid #2a2a2a;
}

#mode-text {
    font-weight: 600;
    color: #4a90e2;
}

.mode-indicator.edit-mode #mode-text {
    color: #ff6b6b;
}

.hint {
    font-size: 12px;
    color: #666;
}

kbd {
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    padding: 2px 6px;
    font-family: monospace;
    font-size: 11px;
}

/* Edit Panel */
.edit-panel {
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
    display: none;
}

.edit-panel.visible {
    display: block;
}

.edit-panel h3 {
    margin-bottom: 16px;
    color: #ff6b6b;
}

.edit-content label {
    display: block;
    margin-bottom: 12px;
    color: #aaa;
}

.edit-content input {
    display: block;
    width: 100%;
    margin-top: 8px;
    padding: 8px 12px;
    background: #0f0f0f;
    border: 1px solid #333;
    border-radius: 6px;
    color: #e0e0e0;
    font-size: 14px;
}

.edit-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.edit-actions button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
}

#save-btn {
    background: #4a90e2;
    color: white;
}

#save-btn:hover {
    background: #357abd;
}

#cancel-btn {
    background: #333;
    color: #e0e0e0;
}

#cancel-btn:hover {
    background: #444;
}

.edit-note {
    font-size: 12px;
    color: #666;
    margin-top: 12px;
}

.edit-note code {
    background: #0f0f0f;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
}

/* Permissions panel */
.permissions-panel {
    background: #131313;
    border: 1px solid #2a2a2a;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
    display: none;
}

.permissions-panel.visible,
.permissions-panel.has-items {
    display: block;
}

.permissions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.permissions-header h3 {
    color: #9aa0ff;
    font-size: 16px;
}

#forget-permissions {
    background: #2a2a2a;
    color: #e0e0e0;
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 12px;
}

#forget-permissions:hover {
    background: #333;
}

.permissions-note {
    font-size: 12px;
    color: #777;
    margin-bottom: 12px;
}

.permissions-section {
    margin-bottom: 12px;
}

.permissions-section h4 {
    font-size: 12px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #666;
    margin-bottom: 6px;
}

.permissions-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.permissions-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #1b1b1b;
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 12px;
    color: #bbb;
}

.permission-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #1b1b1b;
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 12px;
    color: #bbb;
}

.permission-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 200px;
}

.permission-remove {
    background: transparent;
    border: none;
    color: #888;
    font-size: 16px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.permission-remove:hover {
    color: #ff6b6b;
}

.permission-empty {
    font-size: 12px;
    color: #555;
    font-style: italic;
    padding: 4px 0;
}

.permissions-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.perm-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 999px;
    border: 1px solid #333;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.perm-granted {
    color: #00b894;
    border-color: rgba(0, 184, 148, 0.4);
}

.perm-prompt {
    color: #fdcb6e;
    border-color: rgba(253, 203, 110, 0.4);
}

.perm-denied {
    color: #ff7675;
    border-color: rgba(255, 118, 117, 0.4);
}

.perm-button {
    background: #2d2d2d;
    color: #e0e0e0;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 11px;
    cursor: pointer;
}

.perm-button:hover {
    background: #3a3a3a;
}

/* Overlay (Teleport mode) */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.overlay.visible {
    display: flex;
}

.overlay-content {
    background: #1a1a1a;
    border: 1px solid #3a3a3a;
    border-radius: 12px;
    padding: 30px;
    max-width: 600px;
    width: 90%;
    position: relative;
    max-height: 80vh;
    overflow-y: auto;
}

.overlay-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: #888;
    font-size: 32px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
}

.overlay-close:hover {
    background: #2a2a2a;
    color: #e0e0e0;
}

#overlay-body {
    color: #e0e0e0;
}

#overlay-body h2 {
    margin-bottom: 12px;
}

#overlay-body p {
    margin-bottom: 8px;
    color: #aaa;
}

#overlay-body pre {
    background: #0f0f0f;
    border: 1px solid #2a2a2a;
    padding: 12px;
    border-radius: 6px;
    white-space: pre-wrap;
    word-break: break-word;
    color: #cfcfcf;
}

.overlay-actions {
    margin-top: 16px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.overlay-button {
    background: #4a90e2;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}

.overlay-button.secondary {
    background: #2d2d2d;
    color: #e0e0e0;
}

.overlay-disclaimer {
    font-size: 12px;
    color: #888;
    margin-top: 12px;
}

.preview-image {
    max-width: 100%;
    border-radius: 8px;
    border: 1px solid #2a2a2a;
}

#overlay-body a {
    color: #4a90e2;
    text-decoration: none;
}

#overlay-body a:hover {
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
    .grid {
        gap: 12px;
    }
    
    .tile {
        padding: 16px;
        min-height: 100px;
    }
    
    .tile-label {
        font-size: 16px;
    }
}

/* ============================================================================
   MARKDOWN RENDERING STYLES
   ============================================================================ */

.markdown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #2a2a2a;
}

.markdown-header h2 {
    margin: 0;
    color: #e0e0e0;
}

.md-raw-toggle {
    background: #2a2a2a;
    color: #aaa;
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.md-raw-toggle:hover {
    background: #3a3a3a;
    color: #e0e0e0;
}

.markdown-content {
    max-height: 70vh;
    overflow-y: auto;
    padding: 10px;
    line-height: 1.6;
    color: #cfcfcf;
}

.markdown-raw {
    max-height: 70vh;
    overflow-y: auto;
    background: #0f0f0f;
    border: 1px solid #2a2a2a;
    padding: 15px;
    border-radius: 6px;
    white-space: pre-wrap;
    word-break: break-word;
    color: #cfcfcf;
    font-size: 13px;
}

/* Markdown content styling */
.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
    color: #e0e0e0;
    margin-top: 24px;
    margin-bottom: 12px;
    font-weight: 600;
}

.markdown-content h1 {
    font-size: 2em;
    border-bottom: 2px solid #2a2a2a;
    padding-bottom: 8px;
}

.markdown-content h2 {
    font-size: 1.5em;
    border-bottom: 1px solid #2a2a2a;
    padding-bottom: 6px;
}

.markdown-content h3 {
    font-size: 1.25em;
}

.markdown-content p {
    margin-bottom: 12px;
    color: #cfcfcf;
}

.markdown-content a {
    color: #4a90e2;
    text-decoration: none;
    transition: color 0.2s;
}

.markdown-content a:hover {
    color: #6ab0ff;
    text-decoration: underline;
}

.markdown-content code {
    background: #1a1a1a;
    color: #e06c75;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.9em;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
}

.markdown-content pre {
    background: #0f0f0f;
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    padding: 12px;
    overflow-x: auto;
    margin: 12px 0;
}

.markdown-content pre code {
    background: transparent;
    color: #cfcfcf;
    padding: 0;
    border-radius: 0;
}

.markdown-content blockquote {
    border-left: 4px solid #4a90e2;
    margin: 12px 0;
    padding: 8px 16px;
    background: #1a1a1a;
    color: #aaa;
}

.markdown-content ul,
.markdown-content ol {
    margin-left: 24px;
    margin-bottom: 12px;
}

.markdown-content li {
    margin-bottom: 6px;
}

.markdown-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 12px 0;
}

.markdown-content table th,
.markdown-content table td {
    border: 1px solid #2a2a2a;
    padding: 8px 12px;
    text-align: left;
}

.markdown-content table th {
    background: #1a1a1a;
    font-weight: 600;
}

.markdown-content table tr:nth-child(even) {
    background: #0f0f0f;
}

.markdown-content hr {
    border: none;
    border-top: 2px solid #2a2a2a;
    margin: 24px 0;
}

.markdown-content img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 12px 0;
}

/* Scrollbar styling for markdown content */
.markdown-content::-webkit-scrollbar,
.markdown-raw::-webkit-scrollbar {
    width: 8px;
}

.markdown-content::-webkit-scrollbar-track,
.markdown-raw::-webkit-scrollbar-track {
    background: #1a1a1a;
    border-radius: 4px;
}

.markdown-content::-webkit-scrollbar-thumb,
.markdown-raw::-webkit-scrollbar-thumb {
    background: #3a3a3a;
    border-radius: 4px;
}

.markdown-content::-webkit-scrollbar-thumb:hover,
.markdown-raw::-webkit-scrollbar-thumb:hover {
    background: #4a4a4a;
}
