/* style.css - Premium Mobile-First stylesheet for KodeWeb Lite */

@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500&family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --bg-primary: #0b0114;       /* Deep violet editor background */
    --bg-secondary: #140523;     /* Dark violet panels and headers */
    --bg-active: #260b3c;        /* Selected items, active tabs */
    --bg-hover: #320f4e;         /* Hover state */
    --bg-input: #1d0c2c;         /* Text inputs, select */
    
    --border-color: rgba(255, 255, 255, 0.1);     /* Glass borders */
    --border-input: rgba(255, 255, 255, 0.15);     /* Input borders */
    
    --text-primary: #f0f0f0;     /* Main text */
    --text-muted: #a0a0a0;       /* Muted labels */
    --text-active: #ffffff;      /* Active high-contrast text */
    
    --accent: #bd00ff;           /* Neon Purple accent */
    --accent-hover: #d040ff;
    --accent-success: #00ff88;   /* Success neon green */
    --accent-error: #ff0055;     /* Error neon red */
    
    --header-height: 52px;
    --tabs-height: 40px;
    --font-ui: 'Outfit', sans-serif;
    --font-mono: 'Fira Code', monospace;
}

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

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 14px;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

/* Custom scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--bg-active);
}

/* Top Header */
.top-header {
    height: var(--header-height);
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    flex-shrink: 0;
    z-index: 100;
}

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

.hamburger-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.hamburger-btn:active {
    background-color: var(--bg-hover);
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-section img {
    height: 24px;
    width: 24px;
}

.app-title {
    font-weight: 700;
    font-size: 16px;
    color: var(--text-active);
    letter-spacing: 0.5px;
}

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

.header-action-btn {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 6px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.header-action-btn:active {
    background-color: var(--bg-hover);
    border-color: var(--accent);
}

/* Tab Bar */
.tabs-bar {
    height: var(--tabs-height);
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    scrollbar-width: none; /* Hide scrollbar for Firefox */
    flex-shrink: 0;
}

.tabs-bar::-webkit-scrollbar {
    display: none; /* Hide scrollbar for Chrome/Safari */
}

.tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 16px;
    height: 100%;
    border-right: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s;
    background-color: rgba(0,0,0,0.15);
}

.tab.active {
    background-color: var(--bg-primary);
    color: var(--text-active);
    border-bottom: 2px solid var(--accent);
    font-weight: 600;
}

.tab .tab-close {
    font-size: 10px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.tab .tab-close:hover {
    background-color: var(--accent-error);
    color: white;
}

/* Main Workspace View Container */
.workspace-views {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.workspace-view {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
}

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

/* Editor View */
#editor {
    flex: 1;
    width: 100%;
    height: 100%;
}

.no-file-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
}

.no-file-placeholder img {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.8;
}

.no-file-placeholder h3 {
    margin-bottom: 8px;
    font-weight: 600;
}

.no-file-placeholder p {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 20px;
}

.shortcut-tips {
    width: 100%;
    max-width: 280px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 16px;
    text-align: left;
}

.shortcut-tips h4 {
    font-size: 11px;
    color: var(--accent);
    text-transform: uppercase;
    text-align: center;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.shortcut-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    padding: 4px 0;
}

.shortcut-row span {
    color: var(--text-muted);
}

.shortcut-row kbd {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 10px;
}

/* Drawer Sidebar overlay */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.sidebar-overlay.visible {
    opacity: 1;
    visibility: visible;
}

/* Sidebar Drawer */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 280px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    z-index: 999;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar.open {
    transform: translateX(0);
}

.sidebar-header {
    height: var(--header-height);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    flex-shrink: 0;
}

.sidebar-header .title {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-active);
    letter-spacing: 0.5px;
}

.sidebar-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
}

.sidebar-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Accordion sections */
.accordion-section {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    background-color: rgba(0,0,0,0.1);
    flex-shrink: 0;
}

.accordion-header {
    background-color: var(--bg-input);
    padding: 12px;
    font-weight: 600;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid var(--border-color);
}

.accordion-header .arrow {
    font-size: 10px;
    transition: transform 0.2s;
}

.accordion-section.collapsed .accordion-header {
    border-bottom: none;
}

.accordion-section.collapsed .accordion-header .arrow {
    transform: rotate(-90deg);
}

.accordion-content {
    padding: 8px;
    max-height: 2000px;
    overflow-y: visible;
    transition: max-height 0.3s ease-in-out;
}

.accordion-section.collapsed .accordion-content {
    max-height: 0;
    padding: 0 8px;
    overflow: hidden;
}

/* File explorer tree styles */
.file-tree-node {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s;
    color: var(--text-primary);
}

.file-tree-node:hover {
    background-color: var(--bg-hover);
}

.file-tree-node.directory {
    font-weight: 500;
    color: var(--text-active);
}

.file-tree-children {
    padding-left: 14px;
    border-left: 1px dashed rgba(255,255,255,0.08);
}

.file-tree-children.hidden {
    display: none;
}

/* Sidebar action items */
.sidebar-action-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-btn {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
}

.sidebar-btn:active {
    background-color: var(--bg-hover);
    border-color: var(--accent);
}

.sidebar-btn.btn-accent {
    background-color: var(--accent);
    border-color: var(--accent);
    color: white;
}

.sidebar-btn.btn-accent:active {
    background-color: var(--accent-hover);
}

/* Database Explorer View */
.db-view-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 12px;
    overflow-y: auto;
}

.panel-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 6px;
}

.db-selector-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.db-select {
    flex: 1;
    min-width: 120px;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 10px;
    border-radius: 6px;
    outline: none;
    font-size: 13px;
}

.sql-runner-area {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.sql-textarea {
    width: 100%;
    height: 80px;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 10px;
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 13px;
    outline: none;
    resize: none;
}

.db-results-container {
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: rgba(0,0,0,0.2);
    overflow: auto;
    max-height: 300px;
}

.db-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.db-table th {
    background-color: var(--bg-input);
    color: var(--text-active);
    font-weight: 600;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    white-space: nowrap;
}

.db-table td {
    padding: 6px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    white-space: nowrap;
}

.db-table tr:hover {
    background-color: var(--bg-hover);
}

.db-status-bar {
    font-size: 12px;
    color: var(--text-muted);
    padding: 6px 0;
}

/* Terminal View */
.terminal-view-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #05000a;
    padding: 8px;
    overflow: hidden;
}

.terminal-output {
    flex: 1;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.4;
    padding: 8px;
    white-space: pre-wrap;
    word-break: break-all;
}

.terminal-prompt-line {
    display: flex;
    align-items: center;
    border-top: 1px solid var(--border-color);
    padding-top: 8px;
    position: relative;
}

.terminal-path {
    color: var(--accent-success);
    font-family: var(--font-mono);
    font-size: 12px;
    margin-right: 6px;
    white-space: nowrap;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.terminal-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 12px;
    outline: none;
}

/* Autocomplete suggestion dropdown */
.autocomplete-dropdown {
    position: absolute;
    bottom: 32px;
    left: 10px;
    right: 10px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    max-height: 120px;
    overflow-y: auto;
    z-index: 10;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.5);
    display: none;
}

.autocomplete-item {
    padding: 8px 12px;
    font-size: 12px;
    font-family: var(--font-mono);
    cursor: pointer;
}

.autocomplete-item:hover, .autocomplete-item.selected {
    background-color: var(--accent);
    color: white;
}

/* Toast System */
#toast-container {
    position: fixed;
    top: 12px;
    right: 12px;
    left: 12px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--accent);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 13px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: space-between;
    pointer-events: auto;
    animation: slideInDown 0.3s ease-out;
}

.toast.toast-error {
    border-left-color: var(--accent-error);
}

.toast.toast-success {
    border-left-color: var(--accent-success);
}

@keyframes slideInDown {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    backdrop-filter: blur(4px);
}

.modal-overlay.open {
    display: flex;
}

.modal-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.6);
    display: flex;
    flex-direction: column;
    max-height: 80vh;
    overflow: hidden;
}

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

.modal-card-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.modal-card-body {
    padding: 16px;
    overflow-y: auto;
}

.modal-card-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    background-color: rgba(0,0,0,0.1);
}

.form-input {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid var(--border-input);
    border-radius: 6px;
    padding: 10px 12px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
}

.form-input:focus {
    border-color: var(--accent);
}

.btn {
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn:active {
    background-color: var(--bg-hover);
}

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

.btn-primary:active {
    background-color: var(--accent-hover);
}

.btn-danger {
    background-color: var(--accent-error);
    border-color: var(--accent-error);
    color: white;
}

/* User Settings Area in Sidebar */
.user-settings-box {
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.user-name-tag {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-active);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Responsiveness Adaptations */
@media (min-width: 768px) {
    /* Larger tablets or landscape */
    .sidebar {
        width: 320px;
    }
}

@media (max-width: 767px) and (orientation: portrait) {
    /* Full width sidebar on cellphones in portrait */
    .sidebar {
        width: 100%;
    }
    .sidebar-logo-brand {
        display: flex !important;
        align-items: center;
        gap: 6px;
    }
    .sidebar-logo-separator {
        display: inline !important;
    }
}

@media (orientation: landscape) and (max-height: 480px) {
    /* For cellphones in landscape */
    .top-header {
        height: 40px;
    }
    :root {
        --header-height: 40px;
    }
    .install-card, .login-card {
        padding: 16px;
    }
    .install-card h2, .login-card h2 {
        margin-bottom: 8px;
    }
    .checkbox-group {
        margin: 8px 0;
    }
    .sql-textarea {
        height: 60px;
    }
}

.hidden {
    display: none !important;
}

.sidebar-logo-brand,
.sidebar-logo-separator {
    display: none;
}

/* Modal Accordions */
.modal-acc-section {
    display: flex;
    flex-direction: column;
}
.modal-acc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    cursor: pointer;
    background-color: transparent;
    transition: background-color 0.2s;
    font-size: 13px;
}
.modal-acc-header:hover {
    background-color: var(--bg-hover);
}
.modal-acc-content {
    max-height: 0;
    padding: 0 15px;
    overflow: hidden;
    background-color: rgba(0,0,0,0.1);
    transition: max-height 0.3s ease-in-out, padding 0.3s ease-in-out;
}
.modal-acc-content.acc-open {
    max-height: 1000px;
    padding: 15px;
}
