/* k9s exact replica theme */
:root {
    /* Colors */
    --bg-black: #000000;
    --bg-dark: #0a0a0a;
    --text-white: #ffffff;
    --text-gray: #808080;
    --text-cyan: #00ffff;
    --text-yellow: #ffff00;
    --text-orange: #ff8800;
    --text-red: #ff0000;
    --text-green: #00ff00;
    --text-blue: #0088ff;
    --text-magenta: #ff00ff;
    --border-blue: #0066cc;
    --selected-bg: #003366;
    --highlight-yellow: #ffff00;
    
    /* Font Sizes - Standardized */
    --font-xs: 11px;      /* Extra small - help text, hints */
    --font-sm: 13px;      /* Small - shortcuts, header labels */
    --font-md: 15px;      /* Medium - body text, table cells */
    --font-lg: 17px;      /* Large - table headers, emphasis */
    --font-xl: 20px;      /* Extra large - titles */
}

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

body {
    font-family: 'Courier New', 'Courier', monospace;
    font-size: var(--font-md);
    background-color: var(--bg-black);
    color: var(--text-white);
    overflow: hidden;
    height: 100vh;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Better touch scrolling on mobile */
    -webkit-overflow-scrolling: touch;
    /* Prevent text selection on mobile for better UX */
    -webkit-tap-highlight-color: rgba(0, 255, 255, 0.1);
}

/* Mobile-specific cursor */
body.mobile {
    cursor: default;
    user-select: none;
}

body.mobile input,
body.mobile textarea {
    user-select: text;
}

#terminal {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Shortcuts bars */
#shortcuts-bar, #shortcuts-bar-2, #shortcuts-bar-3 {
    background-color: var(--bg-black);
    padding: 4px 8px;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    font-size: var(--font-sm);
}

#shortcuts-bar-3 {
    justify-content: center;
}

.shortcuts-left, .shortcuts-right, .shortcuts-center {
    display: flex;
    gap: 16px;
}

.shortcut {
    color: var(--text-gray);
}

.shortcut .key {
    color: var(--text-cyan);
}

/* Header */
#header {
    background-color: var(--bg-black);
    padding: 6px 12px;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    font-size: var(--font-sm);
}

.header-left {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.header-line {
    display: flex;
    gap: 8px;
}

.header-line .label {
    color: var(--text-gray);
    min-width: 60px;
}

.header-line .value {
    color: var(--text-yellow);
}

.status-badge {
    color: var(--text-cyan);
    padding: 0 4px;
}

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

#ascii-logo {
    color: var(--text-yellow);
    font-size: var(--font-xs);
    line-height: 1.1;
    margin: 0;
    font-weight: bold;
}

/* Search bar */
#search-bar {
    background-color: var(--bg-black);
    padding: 6px 10px;
    border-bottom: 1px solid #333;
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: var(--font-md);
}

#search-prompt {
    color: var(--text-yellow);
    font-weight: bold;
    font-size: var(--font-md);
}

#search-input {
    flex: 1;
    background-color: transparent;
    border: none;
    outline: none;
    color: var(--text-white);
    font-family: inherit;
    font-size: var(--font-md);
}

/* Main Container */
#main-container {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.view-container {
    display: none;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.view-container.active {
    display: flex;
}

/* Table header bar */
.table-header-bar {
    background-color: var(--bg-black);
    padding: 6px 10px;
    border-bottom: 1px solid var(--border-blue);
    border-top: 1px solid var(--border-blue);
    font-size: var(--font-md);
    width: 100%;
    box-sizing: border-box;
    flex-shrink: 0;
}

/* Resource Table */
.resource-table-container {
    flex: 1;
    overflow: auto;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on mobile */
    width: 100%;
}

#resource-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}

#resource-table thead {
    position: sticky;
    top: 0;
    background-color: var(--bg-black);
    z-index: 1;
}

#resource-table th {
    text-align: left;
    padding: 8px 12px;
    color: var(--text-cyan);
    font-weight: bold;
    border-bottom: 1px solid var(--border-blue);
    white-space: nowrap;
    font-size: var(--font-lg);
}

.sortable {
    cursor: pointer;
    user-select: none;
}

.sort-arrow {
    color: var(--text-cyan);
    margin-left: 2px;
}

#resource-table tbody tr {
    cursor: pointer;
    transition: background-color 0.05s;
}

#resource-table tbody tr:hover {
    background-color: #001a33;
}

/* Touch devices - use :active instead of :hover */
@media (hover: none) and (pointer: coarse) {
    #resource-table tbody tr:active {
        background-color: #001a33;
    }
}

#resource-table tbody tr.selected {
    background-color: var(--selected-bg);
}

#resource-table tbody tr.highlighted {
    background-color: #1a1a00;
}

#resource-table td {
    padding: 6px 12px;
    border-bottom: 1px solid #1a1a1a;
    white-space: nowrap;
    font-size: var(--font-md);
    color: var(--text-white);
}

#resource-table td:first-child {
    color: var(--text-yellow);
}

#resource-table td.status-indicator {
    text-align: center;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
}

.status-running {
    color: var(--text-green);
}

.status-completed {
    color: var(--text-cyan);
}

.status-error {
    color: var(--text-red);
}

.status-pending {
    color: var(--text-orange);
}

.status-terminating {
    color: var(--text-gray);
}

/* Detail View */
#detail-view {
    overflow: hidden;
    padding: 0;
    background-color: var(--bg-black);
    display: flex;
    flex-direction: column;
}

.view-header {
    background-color: var(--bg-black);
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-blue);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-hint {
    color: var(--text-gray);
    font-size: var(--font-sm);
}

/* Two-column layout */
.detail-columns {
    display: flex;
    flex: 1;
    overflow: hidden;
    gap: 1px;
    background-color: var(--border-blue);
}

.detail-column {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: var(--bg-black);
}

.yaml-column {
    flex: 1;
    border-right: 1px solid var(--border-blue);
}

.preview-column {
    flex: 2;
}

.column-header {
    background-color: #1a1a1a;
    padding: 6px 12px;
    border-bottom: 1px solid var(--border-blue);
    color: var(--text-cyan);
    font-weight: bold;
    font-size: var(--font-sm);
    text-align: center;
}

/* Xterm-style viewport */
.xterm-viewport {
    background-color: rgb(0, 0, 0);
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    padding: 16px;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

#yaml-content {
    margin: 0;
    font-family: 'Courier New', monospace;
    font-size: var(--font-md);
    line-height: 1.6;
    color: var(--text-white);
    white-space: pre-wrap;
    word-wrap: break-word;
}

#preview-content {
    font-family: 'Courier New', monospace;
    font-size: var(--font-md);
    line-height: 1.6;
    color: var(--text-white);
}

/* Preview content styling */
.preview-section {
    margin-bottom: 24px;
}

.preview-section h2 {
    color: var(--text-cyan);
    font-size: var(--font-lg);
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border-blue);
    padding-bottom: 4px;
}

.preview-section h3 {
    color: var(--text-yellow);
    font-size: var(--font-md);
    margin: 12px 0 6px 0;
}

.preview-label {
    color: var(--text-gray);
    display: inline-block;
    min-width: 150px;
}

.preview-value {
    color: var(--text-white);
}

.preview-list {
    margin: 8px 0;
    padding-left: 0;
    list-style: none;
}

.preview-list li {
    padding: 4px 0 4px 16px;
    position: relative;
}

.preview-list li:before {
    content: "▸";
    position: absolute;
    left: 0;
    color: var(--text-cyan);
}

.preview-badge {
    display: inline-block;
    padding: 2px 8px;
    margin: 2px 4px 2px 0;
    border-radius: 3px;
    font-size: var(--font-sm);
    background-color: #1a1a1a;
    border: 1px solid var(--border-blue);
}

.preview-status-running {
    color: var(--text-green);
}

.preview-status-completed {
    color: var(--text-cyan);
}

.preview-description {
    color: var(--text-white);
    line-height: 1.8;
    margin: 12px 0;
    white-space: pre-wrap;
}

/* ASCII art preview box */
.preview-box {
    border: 1px solid var(--border-blue);
    padding: 12px;
    margin: 12px 0;
    background-color: #0a0a0a;
}

.preview-box-title {
    color: var(--text-yellow);
    font-weight: bold;
    margin-bottom: 8px;
}

/* Responsive - stack columns on small screens */
@media (max-width: 1024px) {
    .detail-columns {
        flex-direction: column;
    }
    
    .yaml-column {
        flex: 1;
        border-right: none;
        border-bottom: 1px solid var(--border-blue);
        max-height: 30vh;
    }
    
    .preview-column {
        flex: 2;
        max-height: 70vh;
    }
}

/* YAML syntax highlighting */
.yaml-key {
    color: var(--text-cyan);
}

.yaml-string {
    color: var(--text-yellow);
}

.yaml-number {
    color: var(--text-magenta);
}

.yaml-boolean {
    color: var(--text-orange);
}

.yaml-null {
    color: var(--text-gray);
}

.yaml-comment {
    color: var(--text-green);
    font-style: italic;
}

/* Help View */
#help-view {
    overflow-y: auto;
}

#help-content {
    padding: 16px;
}

.help-section {
    margin-bottom: 24px;
}

.help-section h3 {
    color: var(--text-cyan);
    margin-bottom: 8px;
    font-size: var(--font-lg);
}

.help-section table {
    width: 100%;
    border-collapse: collapse;
}

.help-section td {
    padding: 6px 16px 6px 0;
    color: var(--text-white);
    border: none;
    font-size: var(--font-md);
}

.help-section td:first-child {
    color: var(--text-yellow);
    font-weight: bold;
    min-width: 140px;
    font-size: var(--font-md);
}

.help-section td:last-child {
    color: var(--text-gray);
    font-size: var(--font-sm);
}

/* Footer */
#footer {
    background-color: var(--bg-black);
    padding: 6px 10px;
    border-top: 1px solid #333;
    font-size: var(--font-sm);
}

#resource-context {
    color: var(--text-yellow);
    font-size: var(--font-sm);
}

/* Command Input */
#command-input {
    position: absolute;
    bottom: 40px;
    left: 10px;
    right: 10px;
    background-color: #001a33;
    border: 1px solid var(--border-blue);
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 100;
    font-size: var(--font-md);
}

#command-input.hidden {
    display: none;
}

#command-input .prompt {
    color: var(--text-cyan);
    font-weight: bold;
    font-size: var(--font-md);
}

#command-field {
    flex: 1;
    background-color: transparent;
    border: none;
    outline: none;
    color: var(--text-white);
    font-family: inherit;
    font-size: var(--font-md);
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-black);
}

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Selection highlighting */
::selection {
    background-color: var(--selected-bg);
    color: var(--text-white);
}

/* Loading animation */
@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.loading::after {
    content: '█';
    animation: blink 1s infinite;
}

/* Responsive */
/* ============================================
   RESPONSIVE DESIGN - MOBILE FRIENDLY
   ============================================ */

/* Large tablets and small laptops (1024px - 1200px) */
@media (max-width: 1200px) {
    :root {
        --font-xs: 10px;
        --font-sm: 12px;
        --font-md: 13px;
        --font-lg: 15px;
        --font-xl: 18px;
    }
    
    #resource-table th,
    #resource-table td {
        padding: 4px 8px;
    }
    
    #shortcuts-bar,
    #shortcuts-bar-2,
    #shortcuts-bar-3 {
        gap: 8px;
    }
}

/* Tablets (768px - 1024px) */
@media (max-width: 1024px) {
    :root {
        --font-xs: 9px;
        --font-sm: 11px;
        --font-md: 12px;
        --font-lg: 14px;
        --font-xl: 16px;
    }
    
    /* Header - reduce items */
    #header {
        padding: 8px 12px;
    }
    
    #header .header-line {
        margin: 2px 0;
    }
    
    /* Hide less important columns in table */
    #resource-table th:nth-child(6),  /* CLIENTS */
    #resource-table td:nth-child(6),
    #resource-table th:nth-child(7),  /* TECH */
    #resource-table td:nth-child(7),
    #resource-table th:nth-child(8),  /* EXP */
    #resource-table td:nth-child(8),
    #resource-table th:nth-child(9)   /* TEAM */
    #resource-table td:nth-child(9) {
        display: none;
    }
    
    /* Shortcuts - reduce spacing */
    #shortcuts-bar,
    #shortcuts-bar-2,
    #shortcuts-bar-3 {
        padding: 4px 8px;
        gap: 6px;
    }
    
    .shortcut {
        font-size: var(--font-xs);
    }
}

/* Mobile devices (480px - 768px) */
@media (max-width: 768px) {
    :root {
        --font-xs: 9px;
        --font-sm: 10px;
        --font-md: 11px;
        --font-lg: 13px;
        --font-xl: 15px;
    }
    
    /* Hide ASCII logo on mobile */
    #ascii-logo {
        display: none;
    }
    
    /* Header - show only important info */
    #header {
        flex-direction: column;
        padding: 6px 10px;
        gap: 4px;
    }
    
    .header-left,
    .header-right {
        width: 100%;
        gap: 2px;
    }
    
    /* Hide less important header items */
    #header .header-line:nth-child(n+4) {
        display: none;
    }
    
    /* Keep only: Company, Partners, Availability */
    #header .header-right .header-line:not(:first-child) {
        display: none;
    }
    
    /* Shortcuts - hide all except essential help */
    #shortcuts-bar,
    #shortcuts-bar-2 {
        display: none;
    }
    
    #shortcuts-bar-3 {
        padding: 4px 8px;
        justify-content: center;
    }
    
    /* Search bar */
    #search-bar {
        padding: 6px 10px;
    }
    
    #search-input {
        padding: 6px 10px;
        font-size: var(--font-md);
        min-height: 44px; /* Touch-friendly */
    }
    
    /* Table - Convert to card layout */
    #resource-table {
        display: block;
        border: none;
    }
    
    #resource-table thead {
        display: none; /* Hide table headers on mobile */
    }
    
    #resource-table tbody {
        display: block;
    }
    
    #resource-table tr {
        display: block;
        margin-bottom: 12px;
        padding: 12px;
        border: 1px solid var(--border-blue);
        border-radius: 4px;
        background-color: var(--bg-dark);
    }
    
    #resource-table tr.selected {
        background-color: var(--selected-bg);
        border-color: var(--text-cyan);
    }
    
    #resource-table td {
        display: block;
        padding: 4px 0;
        border: none;
        text-align: left !important;
    }
    
    /* Card layout - show only important fields */
    #resource-table td:nth-child(1)::before { content: ""; }
    #resource-table td:nth-child(2)::before { content: "Name: "; color: var(--text-gray); }
    #resource-table td:nth-child(3)::before { content: "Type: "; color: var(--text-gray); }
    #resource-table td:nth-child(5)::before { content: "Status: "; color: var(--text-gray); }
    
    /* Hide columns: READY, CLIENTS, TECH, EXP, TEAM, AGE */
    #resource-table td:nth-child(4),  /* READY (1/1) */
    #resource-table td:nth-child(6),  /* CLIENTS */
    #resource-table td:nth-child(7),  /* TECH */
    #resource-table td:nth-child(8),  /* EXP */
    #resource-table td:nth-child(9),  /* TEAM */
    #resource-table td:nth-child(8) { /* AGE */
        display: none;
    }
    
    /* Namespace badge style for mobile */
    #resource-table td:first-child {
        display: inline-block;
        padding: 2px 8px;
        margin-bottom: 6px;
        background-color: var(--text-yellow);
        color: var(--bg-black);
        border-radius: 3px;
        font-weight: bold;
        font-size: var(--font-xs);
    }
    
    /* Name - larger on mobile */
    #resource-table td:nth-child(2) {
        font-size: var(--font-lg);
        font-weight: bold;
        margin-bottom: 4px;
    }
    
    /* Detail view - hide YAML on mobile, show only preview */
    .yaml-column {
        display: none !important;
    }
    
    .preview-column {
        flex: 1;
        width: 100%;
        padding: 12px;
    }
    
    #detail-view-content {
        flex-direction: column;
    }
    
    /* Preview styling for mobile */
    .preview-section {
        margin-bottom: 16px;
    }
    
    .preview-section h2 {
        font-size: var(--font-xl);
        margin-bottom: 8px;
    }
    
    .preview-section h3 {
        font-size: var(--font-lg);
        margin-bottom: 6px;
    }
    
    .preview-badge {
        font-size: var(--font-xs);
        padding: 3px 6px;
        margin: 2px 4px 2px 0;
    }
    
    .preview-box {
        padding: 8px;
        margin: 8px 0;
    }
    
    /* Footer */
    #footer {
        padding: 4px 10px;
        font-size: var(--font-xs);
    }
}

/* Small mobile devices (360px - 480px) */
@media (max-width: 480px) {
    :root {
        --font-xs: 8px;
        --font-sm: 9px;
        --font-md: 10px;
        --font-lg: 12px;
        --font-xl: 14px;
    }
    
    /* Ultra-compact header */
    #header {
        padding: 4px 8px;
    }
    
    #header .header-line {
        margin: 1px 0;
    }
    
    .status-badge {
        font-size: var(--font-xs);
        padding: 1px 4px;
    }
    
    /* Search */
    #search-bar {
        padding: 4px 8px;
    }
    
    /* Card layout - more compact */
    #resource-table tr {
        margin-bottom: 8px;
        padding: 8px;
    }
    
    #resource-table td:nth-child(2) {
        font-size: var(--font-md);
    }
    
    /* Preview - more compact */
    .preview-column {
        padding: 8px;
    }
    
    .preview-section {
        margin-bottom: 12px;
    }
    
    .preview-badge {
        font-size: 8px;
        padding: 2px 4px;
    }
    
    /* Footer */
    #footer {
        padding: 3px 8px;
    }
    
    /* Shortcuts bar - even more compact */
    #shortcuts-bar-3 {
        padding: 3px 6px;
    }
}

/* Extra small mobile (< 360px) */
@media (max-width: 360px) {
    :root {
        --font-xs: 8px;
        --font-sm: 9px;
        --font-md: 10px;
        --font-lg: 11px;
        --font-xl: 13px;
    }
    
    #header .header-line:nth-child(3),
    #header .header-line:nth-child(4) {
        display: none;
    }
    
    /* Keep only Company and Version */
    #header .header-left .header-line:not(:first-child) {
        display: none;
    }
}

/* Custom table cell colors based on content */
td.namespace-cell {
    color: var(--text-yellow);
}

td.name-cell {
    color: var(--text-white);
}

td.type-cell {
    color: var(--text-cyan);
}

td.status-ready {
    color: var(--text-green);
}

td.status-error {
    color: var(--text-red);
}

td.status-pending {
    color: var(--text-orange);
}

/* Highlight search matches */
.search-match {
    background-color: var(--highlight-yellow);
    color: var(--bg-black);
    padding: 0 2px;
}

/* New vertical header info */
.header-info-col {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    margin-right: 16px;
    gap: 2px;
}

.header-info-col .header-line {
    justify-content: flex-end;
}
