/* StDB-Scout Web GUI - CSS */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-100);
    color: var(--gray-900);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navigation */
.navbar {
    background: var(--gray-900);
    color: white;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 2rem;
}

.nav-brand a {
    color: white;
    text-decoration: none;
    font-weight: bold;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-logo {
    width: 28px;
    height: 28px;
    border-radius: 4px;
}

.nav-links {
    display: flex;
    gap: 1rem;
    flex: 1;
}

.nav-links a {
    color: var(--gray-300);
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
}

.nav-links a:hover,
.nav-links a.active {
    color: white;
    background: rgba(255,255,255,0.1);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-left: auto;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--gray-300);
}

/* Dropdown Menu */
.nav-dropdown {
    position: relative;
}

.nav-dropdown-toggle {
    color: var(--gray-300);
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
}

.nav-dropdown-toggle:hover,
.nav-dropdown-toggle.active {
    color: white;
    background: rgba(255,255,255,0.1);
}

.nav-dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 0.25rem;
    background: white;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 160px;
    z-index: 1000;
    overflow: hidden;
}

.nav-dropdown:hover .nav-dropdown-menu {
    display: block;
}

.nav-dropdown-menu a {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--gray-700);
    text-decoration: none;
    transition: background 0.15s;
}

.nav-dropdown-menu a:hover {
    background: var(--gray-100);
    color: var(--primary);
}

/* Container */
.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 2rem;
    flex: 1;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.75rem;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--gray-200);
    color: var(--gray-700);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    font-size: 0.875rem;
    transition: background 0.2s;
}

.btn:hover {
    background: var(--gray-300);
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-warning {
    background: var(--warning);
    color: white;
}

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

.btn-small,
.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.btn-block {
    display: block;
    width: 100%;
}

/* Cards */
.card {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.card h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--gray-200);
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.table th {
    font-weight: 600;
    color: var(--gray-500);
    font-size: 0.875rem;
}

.table tbody tr:hover {
    background: var(--gray-50);
}

.actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--gray-200);
}

.badge-pending { background: #fef3c7; color: #92400e; }
.badge-running { background: #dbeafe; color: #1e40af; }
.badge-success, .badge-completed { background: #dcfce7; color: #166534; }
.badge-error, .badge-failed { background: #fee2e2; color: #991b1b; }
.badge-warning, .badge-cancelled { background: #fed7aa; color: #9a3412; }

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"] {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 1rem;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.form-inline {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.form-inline .form-group {
    margin-bottom: 0;
}

.inline-form {
    display: inline;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.options-group {
    background: var(--gray-50);
    padding: 1rem;
    border-radius: 4px;
    margin-top: 1rem;
}

.options-group .options-header {
    font-weight: 500;
    margin-bottom: 0.75rem;
    display: block;
}

.options-group .checkbox-label {
    margin-bottom: 0.5rem;
}

.inline-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.inline-option input[type="number"] {
    border: 1px solid var(--gray-200);
    border-radius: 4px;
}

/* Login */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 100px);
}

.login-box {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-box h1 {
    margin-bottom: 0.5rem;
}

.login-box .subtitle {
    color: var(--gray-500);
    margin-bottom: 2rem;
}

.login-form {
    text-align: left;
}

/* Upload */
.upload-container {
    max-width: 600px;
}

.dropzone {
    border: 2px dashed var(--gray-300);
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.dropzone:hover,
.dropzone.dragover {
    border-color: var(--primary);
    background: var(--gray-50);
}

.dropzone input[type="file"] {
    display: none;
}

.dropzone-text p {
    margin: 0.5rem 0;
}

.dropzone-preview {
    display: flex;
    align-items: center;
    gap: 1rem;
    justify-content: center;
}

.file-icon {
    font-size: 2rem;
}

.file-name {
    font-weight: 500;
}

.file-size {
    color: var(--gray-500);
}

/* Storage */
.storage-bar,
.storage-bar-large {
    background: var(--gray-200);
    border-radius: 9999px;
    overflow: hidden;
    height: 8px;
}

.storage-bar-large {
    height: 24px;
    margin-bottom: 1rem;
}

.storage-used {
    background: var(--primary);
    height: 100%;
    transition: width 0.3s;
}

.storage-used.warning {
    background: var(--warning);
}

.storage-used.over-quota {
    background: var(--danger);
}

.storage-info {
    margin: 1.5rem 0;
    padding: 1rem;
    background: var(--gray-50);
    border-radius: 6px;
}

.storage-stats {
    display: flex;
    gap: 2rem;
    margin-bottom: 1rem;
}

.stat {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: bold;
}

.stat-label {
    color: var(--gray-500);
    font-size: 0.875rem;
}

/* Terminal */
.terminal {
    background: #1e1e1e;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.terminal-header {
    background: #333;
    padding: 0.5rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #999;
    font-size: 0.875rem;
}

.terminal-body {
    padding: 1rem;
    max-height: 500px;
    overflow-y: auto;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 0.875rem;
    color: #e0e0e0;
}

.terminal-line {
    margin: 0.25rem 0;
    white-space: pre-wrap;
    word-break: break-all;
}

.terminal-line.error {
    color: #ff6b6b;
}

/* Results */
.heatmap-preview {
    text-align: center;
    margin: 1rem 0;
}

.heatmap-preview img {
    max-width: 100%;
    max-height: 500px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.info-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.5rem 1rem;
}

.info-list dt {
    font-weight: 500;
    color: var(--gray-500);
}

.log-content {
    background: var(--gray-100);
    padding: 1rem;
    border-radius: 4px;
    overflow-x: auto;
    font-family: monospace;
    font-size: 0.875rem;
    max-height: 300px;
    overflow-y: auto;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
}

/* Flash Messages */
.flash-messages {
    margin-bottom: 1rem;
}

.flash {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

.flash-error {
    background: #fee2e2;
    color: #991b1b;
}

.flash-success {
    background: #dcfce7;
    color: #166534;
}

/* Utilities */
.text-muted {
    color: var(--gray-500);
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--gray-500);
}

.page-actions {
    margin-top: 2rem;
}

/* Error Page */
.error-page {
    text-align: center;
    padding: 4rem;
}

.error-page h1 {
    font-size: 4rem;
    color: var(--gray-300);
}

.error-page p {
    margin: 1rem 0 2rem;
    color: var(--gray-500);
}

/* Footer */
.footer {
    text-align: center;
    padding: 1rem;
    color: var(--gray-500);
    font-size: 0.875rem;
    margin-top: auto;
}

/* Responsive */
@media (max-width: 768px) {
    .navbar {
        flex-wrap: wrap;
        gap: 1rem;
    }

    .nav-links {
        order: 3;
        width: 100%;
        flex-wrap: wrap;
    }

    .page-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .storage-stats {
        flex-direction: column;
        gap: 1rem;
    }

    .actions {
        flex-direction: column;
    }
}

/* ============================================================================
   Tools Page
   ============================================================================ */

.tools-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.tool-section {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.tool-section h2 {
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
}

.tool-section > p {
    color: var(--gray-500);
    margin-bottom: 1.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.format-info {
    background: var(--gray-50);
    padding: 1rem;
    border-radius: 4px;
    font-size: 0.875rem;
}

.format-info code {
    background: var(--gray-200);
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    font-family: monospace;
}

.db-status {
    margin-top: 1rem;
}

.status-table {
    margin-bottom: 1.5rem;
}

.status-table td {
    padding: 0.25rem 1rem 0.25rem 0;
}

.status-table code {
    background: var(--gray-100);
    padding: 0.125rem 0.5rem;
    border-radius: 3px;
    font-size: 0.875rem;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table th,
.data-table td {
    padding: 0.5rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.data-table th {
    background: var(--gray-50);
    font-weight: 600;
}

.data-table tbody tr:hover {
    background: var(--gray-50);
}

.file-item {
    padding: 0.5rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* Tools Navigation */
.tools-nav {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--gray-200);
    padding-bottom: 0.5rem;
}

.tools-nav-item {
    padding: 0.5rem 1rem;
    text-decoration: none;
    color: var(--gray-500);
    border-radius: 4px 4px 0 0;
    transition: all 0.2s;
}

.tools-nav-item:hover {
    color: var(--gray-700);
    background: var(--gray-100);
}

.tools-nav-item.active {
    color: var(--primary);
    font-weight: 600;
    border-bottom: 2px solid var(--primary);
    margin-bottom: -2px;
}

/* Filter Bar */
.filter-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.filter-bar input,
.filter-bar select {
    padding: 0.5rem;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    font-size: 0.875rem;
}

.filter-bar input {
    min-width: 180px;
}

/* Table Container */
.table-container {
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid var(--gray-200);
    border-radius: 4px;
}

.data-table thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

/* Status Badges */
.status-ok {
    color: var(--success);
    font-weight: 600;
}

.status-partial {
    color: var(--warning);
    font-weight: 600;
}

.status-missing {
    color: var(--danger);
    font-weight: 600;
}

/* Editable Cells */
.editable-cell {
    cursor: pointer;
    font-family: monospace;
}

.editable-cell:hover {
    background: #e8f4ff;
}

.table-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
}

/* ============================================================================
   Tooltips (CSS-only)
   ============================================================================ */

[data-tip] {
    position: relative;
}

[data-tip]::before,
[data-tip]::after {
    position: absolute;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    pointer-events: none;
    z-index: 1000;
}

/* Tooltip text box */
[data-tip]::before {
    content: attr(data-tip);
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem 0.75rem;
    background: var(--gray-900);
    color: white;
    font-size: 0.8rem;
    font-weight: normal;
    line-height: 1.4;
    white-space: nowrap;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    max-width: 280px;
    white-space: normal;
    text-align: center;
}

/* Tooltip arrow */
[data-tip]::after {
    content: '';
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--gray-900);
}

/* Show on hover */
[data-tip]:hover::before,
[data-tip]:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Tooltip position: bottom */
[data-tip-pos="bottom"]::before {
    bottom: auto;
    top: calc(100% + 8px);
}

[data-tip-pos="bottom"]::after {
    bottom: auto;
    top: calc(100% + 2px);
    border-top-color: transparent;
    border-bottom-color: var(--gray-900);
}

/* Tooltip position: left */
[data-tip-pos="left"]::before {
    bottom: auto;
    top: 50%;
    left: auto;
    right: calc(100% + 8px);
    transform: translateY(-50%);
}

[data-tip-pos="left"]::after {
    bottom: auto;
    top: 50%;
    left: auto;
    right: calc(100% + 2px);
    transform: translateY(-50%);
    border-top-color: transparent;
    border-right-color: transparent;
    border-left-color: var(--gray-900);
}

/* Tooltip position: right */
[data-tip-pos="right"]::before {
    bottom: auto;
    top: 50%;
    left: calc(100% + 8px);
    transform: translateY(-50%);
}

[data-tip-pos="right"]::after {
    bottom: auto;
    top: 50%;
    left: calc(100% + 2px);
    transform: translateY(-50%);
    border-top-color: transparent;
    border-left-color: transparent;
    border-right-color: var(--gray-900);
}
