/* File: /Users/liborballaty/LocalProjects/GitHubProjectsDocuments/xLLMArionComply/arioncomply-v1/internal-admin-ui/public/css/admin-styles.css */
/* Description: Styles for ArionComply internal admin dashboard */
/* Author: Libor Ballaty <libor@arionetworks.com> */
/* Created: 2025-10-28 */

/* ============================================================
   CSS VARIABLES — Admin/Platform Identity Palette
   ============================================================ */
:root {
    /* Admin identity palette — navy/slate distinguishes from customer blue/teal */
    --admin-primary: #2a5298;
    --admin-primary-dark: #1e3c72;
    --admin-accent: #3b82f6;
    --success-green: #10b981;
    --warning-amber: #f59e0b;
    --danger-red: #ef4444;
    --info-blue: #0ea5e9;

    /* Backgrounds */
    --bg-white: #ffffff;
    --bg-light: #f8fafc;
    --bg-gray: #f1f5f9;

    /* Text */
    --text-dark: #1e293b;
    --text-gray: #64748b;
    --text-light: #94a3b8;

    /* Borders & Shadows */
    --border-light: #e2e8f0;
    --shadow-card: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.05);
    --shadow-hover: 0 4px 12px rgba(0,0,0,0.12);

    /* Radius */
    --border-radius: 8px;
    --border-radius-sm: 6px;
    --border-radius-lg: 12px;
}

/* Header Badge/Pill Styling - Consistent for all indicators */
.header-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    transition: all 0.2s ease;
}

.header-badge:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Database Indicator */
.db-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid;
    transition: all 0.2s ease;
    min-width: 200px;
}

.db-indicator.db-local {
    background: rgba(40, 167, 69, 0.2);
    color: #d4ffd9;
    border-color: rgba(40, 167, 69, 0.5);
}

.db-indicator.db-staging {
    background: rgba(255, 193, 7, 0.2);
    color: #fff9e6;
    border-color: rgba(255, 193, 7, 0.5);
}

.db-indicator.db-production {
    background: rgba(220, 53, 69, 0.2);
    color: #ffd9dd;
    border-color: rgba(220, 53, 69, 0.5);
}

.db-indicator.db-unknown {
    background: rgba(108, 117, 125, 0.2);
    color: #e9ecef;
    border-color: rgba(108, 117, 125, 0.5);
}

.db-info {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.db-first-line {
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.db-label {
    font-size: 11px;
    opacity: 0.65;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#db-env-name {
    font-weight: 600;
    font-size: 13px;
}

#db-url-short {
    font-size: 10px;
    opacity: 0.75;
    font-weight: 400;
}

/* Mode Indicator */
.mode-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    cursor: help;
}

/* Version Indicator */
.version-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    background: rgba(103, 126, 234, 0.25);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(103, 126, 234, 0.4);
    color: #e8eaf6;
    cursor: help;
    transition: all 0.2s ease;
}

.version-indicator:hover {
    background: rgba(103, 126, 234, 0.35);
    border-color: rgba(103, 126, 234, 0.6);
    transform: translateY(-1px);
}

.version-icon {
    font-size: 16px;
    line-height: 1;
}

/* User Info Badge */
.user-info {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
}

.user-info::before {
    content: "👤";
    font-size: 14px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.5;
    margin: 0;
    padding: 0;
}

/* Header */
.header {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    padding: 1rem 2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.header-content {
    display: flex;
    align-items: center;
    gap: 2rem;
    max-width: 1800px;
    margin: 0 auto;
}

.header h1 {
    font-size: 1.5rem;
    margin-right: auto;
}

/* State Indicators Group - positioned left of center */
.header-state-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-right: auto;
}

/* User Actions - positioned far right */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
}

/* Sidebar Toggle Button */
.sidebar-toggle {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    padding: 8px;
    margin-right: 1rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.3);
}

.hamburger-icon {
    font-size: 1.5rem;
    color: white;
    display: block;
    line-height: 1;
}

/* Data Access Mode Indicator */
/* Container */
.container {
    display: flex;
    max-width: 1800px;
    margin: 0 auto;
    min-height: calc(100vh - 70px);
}

/* Sidebar */
.sidebar {
    width: 250px;
    background: white;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05);
    padding: 2rem 0;
    transition: all 0.3s ease;
    position: relative;
}

/* Collapsed sidebar state */
body.sidebar-collapsed .sidebar {
    width: 0;
    padding: 0;
    overflow: hidden;
    box-shadow: none;
}

body.sidebar-collapsed .main-content {
    margin-left: 0;
}

.nav-title {
    padding: 0 1.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #999;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.nav-link,
.nav-link-external {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: #555;
    text-decoration: none;
    transition: all 0.2s;
    font-size: 0.95rem;
}

.nav-link:hover,
.nav-link-external:hover {
    background: #f5f7fa;
    color: #2a5298;
}

.nav-link.active {
    background: #e8f0fe;
    color: #2a5298;
    border-left: 3px solid #2a5298;
    font-weight: 600;
}

.nav-link .icon,
.nav-link-external .icon {
    font-size: 1.2rem;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem;
}

/* Alert */
.alert {
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    font-weight: 500;
}

.alert.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

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

.page-header h2 {
    font-size: 1.75rem;
    color: #1e3c72;
}

/* Search and Filter Bar */
.filter-bar {
    background: var(--bg-white);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-card);
    margin-bottom: 1.5rem;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    min-width: 250px;
}

.search-box input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.95rem;
}

.search-box input:focus {
    outline: none;
    border-color: #2a5298;
}

/* Buttons - Consistent Pill Style */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary {
    background: rgba(42, 82, 152, 0.9);
    color: white;
    border: 1px solid rgba(42, 82, 152, 1);
}

.btn-primary:hover {
    background: rgba(30, 60, 114, 1);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(42, 82, 152, 0.3);
}

.btn-secondary {
    background: #6c757d;
    color: white;
    border: 1px solid #6c757d;
}

.btn-secondary:hover {
    background: #5a6268;
    border-color: #545b62;
}

/* Header-specific secondary button styling (transparent on dark background) */
.header .btn-secondary {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.header .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.4);
}

.btn-success {
    background: rgba(40, 167, 69, 0.9);
    color: white;
    border: 1px solid rgba(40, 167, 69, 1);
}

.btn-success:hover {
    background: rgba(33, 136, 56, 1);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
}

.btn-danger {
    background: rgba(220, 53, 69, 0.9);
    color: white;
    border: 1px solid rgba(220, 53, 69, 1);
}

.btn-danger:hover {
    background: rgba(200, 35, 51, 1);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.3);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 12px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Table */
.table-container {
    background: var(--bg-white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

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

.table thead {
    background: #f8f9fa;
}

.table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: #555;
    border-bottom: 2px solid #dee2e6;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table td {
    padding: 1rem;
    border-bottom: 1px solid #dee2e6;
}

.table tbody tr:hover {
    background: #f8f9fa;
}

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

.table-actions button {
    padding: 0.375rem 0.75rem;
    font-size: 0.85rem;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: white;
    border-top: 1px solid #dee2e6;
}

.pagination-info {
    color: #666;
    font-size: 0.9rem;
}

.pagination-controls {
    display: flex;
    gap: 0.5rem;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal {
    background: white;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.25rem;
    color: #1e3c72;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #999;
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid #dee2e6;
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* Form */
.form-group {
    margin-bottom: 1.5rem;
}

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #2a5298;
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-group .help-text {
    font-size: 0.85rem;
    color: #666;
    margin-top: 0.25rem;
}

/* Loading */
.loading {
    text-align: center;
    padding: 3rem;
    color: #666;
}

.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #2a5298;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: #666;
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: #333;
}

.empty-state p {
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
}

/* Badge */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
}

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

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

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

.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

.badge-secondary {
    background: #e2e3e5;
    color: #383d41;
}

/* Code/JSON Display */
.json-display {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 1rem;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    max-height: 300px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Filter Panel */
.filter-panel {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    box-shadow: var(--shadow-card);
}

.filter-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e1e4e8;
    background: #f6f8fa;
    border-radius: 8px 8px 0 0;
}

.filter-panel-header h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #24292e;
}

.filter-panel-body {
    padding: 1.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    max-height: 400px;
    overflow-y: auto;
}

.filter-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-item label {
    font-weight: 500;
    font-size: 0.9rem;
    color: #24292e;
}

.filter-item input,
.filter-item select {
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 0.9rem;
}

.filter-item input:focus,
.filter-item select:focus {
    outline: none;
    border-color: #2a5298;
    box-shadow: 0 0 0 3px rgba(42, 82, 152, 0.1);
}

.filter-daterange {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.filter-daterange input {
    width: 100%;
}

.filter-presets {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.filter-preset-btn {
    padding: 0.25rem 0.75rem;
    background: #f6f8fa;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-preset-btn:hover {
    background: #e1e4e8;
}

.filter-preset-btn.active {
    background: #2a5298;
    color: white;
    border-color: #2a5298;
}

.filter-panel-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid #e1e4e8;
    background: #f6f8fa;
    border-radius: 0 0 8px 8px;
}

.filter-badge {
    display: inline-block;
    background: #dc3545;
    color: white;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 0.5rem;
}

.btn-text {
    background: none;
    border: none;
    color: #586069;
    cursor: pointer;
    font-size: 1.25rem;
    padding: 0.25rem 0.5rem;
    transition: color 0.2s;
}

.btn-text:hover {
    color: #24292e;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
    }

    .filter-bar {
        flex-direction: column;
    }

    .search-box {
        width: 100%;
    }

    .table-container {
        overflow-x: auto;
    }

    .filter-panel-body {
        grid-template-columns: 1fr;
    }
}

/* ==========================================
   JSON Editor Styling
   ========================================== */

/* JSON Editor Modal */
.json-editor-modal {
    display: flex;
    flex-direction: column;
}

.json-editor-modal .modal-body {
    max-height: 70vh;
    overflow-y: auto;
}

/* JSON validation status */
#jsonValidationStatus {
    font-weight: 500;
    transition: color 0.2s;
}

/* JSONB field in forms */
.form-group textarea[readonly] {
    cursor: not-allowed;
}

.badge {
    display: inline-block;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* JSONB cells in tables */
.jsonb-cell {
    display: flex;
    align-items: start;
    gap: 8px;
    max-width: 500px;
}

.jsonb-preview {
    flex: 1;
    background: #f8f9fa;
    padding: 4px 8px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: #495057;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.jsonb-cell.expanded .jsonb-preview {
    white-space: pre-wrap;
    overflow: visible;
    background: #fff;
    border: 1px solid #dee2e6;
    padding: 8px;
    max-height: 300px;
    overflow-y: auto;
}

/* Icon buttons */
.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    font-size: 16px;
    opacity: 0.7;
    transition: opacity 0.2s, transform 0.1s;
}

.btn-icon:hover {
    opacity: 1;
    transform: scale(1.1);
}

.btn-icon:active {
    transform: scale(0.95);
}

/* Small buttons */
.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* JSON editor textarea focus */
#jsonEditorTextarea:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
    border-color: #007bff;
}

/* Responsive adjustments for JSON editor */
@media (max-width: 768px) {
    .json-editor-modal {
        max-width: 95% !important;
        margin: 20px;
    }

    #jsonEditorTextarea {
        font-size: 11px !important;
        height: 300px !important;
    }

    .jsonb-cell {
        max-width: 300px;
    }
}
