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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: 
        linear-gradient(135deg, rgba(102, 126, 234, 0.85) 0%, rgba(118, 75, 162, 0.85) 100%),
        url('images/chameleon-3d.jpg') center center/cover no-repeat fixed;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

.header-links {
    margin: 15px 0;
}

.github-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    text-decoration: none;
    padding: 10px 20px;
    border-radius: 25px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.github-link:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.client-side-notice {
    background: rgba(255, 255, 255, 0.15);
    padding: 10px 20px;
    border-radius: 20px;
    margin-top: 15px;
    font-size: 0.9rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.main-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    overflow: hidden;
}

.tabs {
    display: flex;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.tab {
    flex: 1;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    border: none;
    background: none;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.tab.active {
    background: white;
    color: #667eea;
    border-bottom: 3px solid #667eea;
}

.tab:hover:not(.active) {
    background: #e9ecef;
}

.tab-content {
    display: none;
    padding: 30px;
}

.tab-content.active {
    display: block;
}

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #495057;
}

select, textarea, input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

select:focus, textarea:focus, input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

textarea {
    resize: vertical;
    min-height: 120px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

/* Live Formula Execution Styles */
.formula-input-container {
    position: relative;
}

.formula-status {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 15;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.95);
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border: 1px solid #e9ecef;
}

.status-icon {
    font-size: 0.7rem;
}

.status-indicator.ready .status-icon {
    color: #6c757d;
}

.status-indicator.validating .status-icon {
    color: #ffc107;
    animation: pulse 1.5s infinite;
}

.status-indicator.executing .status-icon {
    color: #17a2b8;
    animation: spin 1s linear infinite;
}

.status-indicator.success .status-icon {
    color: #28a745;
}

.status-indicator.error .status-icon {
    color: #dc3545;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.formula-error {
    margin-top: 8px;
    padding: 12px;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
    color: #721c24;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.formula-error.hidden {
    display: none;
}

.formula-error strong {
    display: block;
    margin-bottom: 4px;
    color: #dc3545;
}

.btn-outline {
    background: transparent;
    color: #667eea;
    border: 2px solid #667eea;
}

.btn-outline:hover {
    background: #667eea;
    color: white;
}

.btn-outline.live-off {
    color: #6c757d;
    border-color: #6c757d;
}

.btn-outline.live-off:hover {
    background: #6c757d;
    color: white;
}

.button-group {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #5a67d8;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #5a6268;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.results {
    margin-top: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.results.error {
    background: #f8d7da;
    border-left-color: #dc3545;
    color: #721c24;
}

.results.success {
    background: #d4edda;
    border-left-color: #28a745;
    color: #155724;
}

.sql-output {
    background: #2d3748;
    color: #e2e8f0;
    padding: 20px;
    border-radius: 8px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9rem;
    overflow-x: auto;
    margin: 15px 0;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    font-size: 0.9rem;
}

.data-table th,
.data-table td {
    border: 1px solid #dee2e6;
    padding: 12px;
    text-align: left;
}

.data-table th {
    background: #f8f9fa;
    font-weight: 600;
    position: sticky;
    top: 0;
}

.data-table tr:nth-child(even) {
    background: #f8f9fa;
}

.example-card {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 15px;
    margin: 10px 0;
    cursor: pointer;
    transition: all 0.3s ease;
}

.example-card:hover {
    background: #e9ecef;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.example-card h4 {
    color: #667eea;
    margin-bottom: 8px;
    text-transform: capitalize;
}

.example-code {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    background: white;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid #dee2e6;
    font-size: 0.85rem;
    color: #495057;
}

.schema-section {
    margin: 20px 0;
}

.schema-section h4 {
    color: #495057;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.columns-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    margin: 10px 0;
}

.column-item {
    background: #f8f9fa;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
}

.column-name {
    font-weight: 600;
    color: #495057;
}

.column-type {
    color: #6c757d;
    font-size: 0.8rem;
    margin-left: 8px;
}

.column-comment {
    color: #6c757d;
    font-size: 0.8rem;
    font-style: italic;
    margin-top: 4px;
}

.column-default {
    color: #28a745;
    font-size: 0.8rem;
    font-weight: 500;
    margin-top: 4px;
}

.schema-display {
    padding: 20px 0;
}

.schema-display h3 {
    color: #495057;
    margin-bottom: 20px;
    font-size: 1.3rem;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 10px;
}

.relationships-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.relationship-item {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 6px;
    border-left: 4px solid #667eea;
}

.relationship-item strong {
    color: #495057;
    font-size: 0.95rem;
}

.relationship-detail {
    color: #6c757d;
    font-size: 0.85rem;
    margin-top: 4px;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #6c757d;
}

.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

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

.metadata {
    display: flex;
    gap: 20px;
    margin: 15px 0;
    font-size: 0.9rem;
    color: #6c757d;
}

.metadata-item {
    background: #e9ecef;
    padding: 8px 12px;
    border-radius: 20px;
}

/* Report Builder Styles */
.formula-row {
    display: grid;
    grid-template-columns: 200px 1fr 40px;
    gap: 10px;
    margin-bottom: 10px;
    align-items: start;
}

.formula-name {
    padding: 8px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
}

.formula-input {
    padding: 8px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    resize: vertical;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

.formula-input.error {
    border-color: #dc3545;
    background: #fff5f5;
}

.formula-input.success {
    border-color: #28a745;
    background: #f8fff8;
}

.btn-remove {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    height: 32px;
}

.btn-remove:hover {
    background: #c82333;
}

/* Error tooltip */
.error-tooltip {
    position: absolute;
    background: #dc3545;
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    z-index: 1000;
    max-width: 300px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.error-tooltip::before {
    content: '';
    position: absolute;
    top: -4px;
    left: 10px;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-bottom: 4px solid #dc3545;
}

/* Recent formulas */
.recent-item {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 12px;
    margin: 8px 0;
    cursor: pointer;
    transition: all 0.2s ease;
}

.recent-item:hover {
    background: #e9ecef;
    transform: translateY(-1px);
}

.recent-formula {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9rem;
    color: #495057;
    margin: 4px 0;
}

.recent-meta {
    font-size: 0.8rem;
    color: #6c757d;
    display: flex;
    justify-content: space-between;
}

/* Clickable relationships */
.relationship-link {
    color: #007bff;
    cursor: pointer;
    text-decoration: underline;
}

.relationship-link:hover {
    color: #0056b3;
}

.relationship-badge {
    display: inline-block;
    padding: 4px 8px;
    margin: 2px;
    background: #e7f3ff;
    border: 1px solid #b8daff;
    border-radius: 12px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.relationship-badge:hover {
    background: #cce7ff;
    transform: translateY(-1px);
}

.relationship-badge.reverse {
    background: #fff3cd;
    border-color: #ffeaa7;
}

.relationship-badge.reverse:hover {
    background: #ffe8a1;
}

/* Clickable table names in schema viewer */
.clickable-table {
    color: #667eea;
    cursor: pointer;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.2s ease;
    text-decoration: none;
    border: 1px solid transparent;
}

.clickable-table:hover {
    background: #f0f4ff;
    border-color: #667eea;
    color: #5a67d8;
    text-decoration: underline;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.15);
}

.clickable-table:active {
    transform: translateY(0px);
    box-shadow: 0 1px 2px rgba(102, 126, 234, 0.2);
}

/* Database tab styles */
.current-db-info {
    padding: 15px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    background: #f8f9fa;
    margin-bottom: 15px;
}

.current-db-info.connected {
    border-color: #28a745;
    background: #d4edda;
}

.current-db-info.error {
    border-color: #dc3545;
    background: #f8d7da;
}

.db-status {
    font-weight: 600;
    margin-bottom: 5px;
}

.db-type {
    font-size: 0.9rem;
    color: #495057;
}

.db-connection {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.8rem;
    color: #6c757d;
    word-break: break-all;
}

/* Examples styling */
.examples-container {
    padding: 20px 0;
}

.examples-header {
    text-align: center;
    margin-bottom: 30px;
}

.examples-header h3 {
    color: #495057;
    margin-bottom: 10px;
}

.examples-stats {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 10px;
}

.stat-item {
    background: #e9ecef;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    color: #495057;
}

.examples-section {
    margin-bottom: 30px;
}

.examples-section h4 {
    color: #495057;
    margin-bottom: 15px;
    font-size: 1.1rem;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 5px;
}

.examples-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 15px;
    margin: 15px 0;
}

.example-card {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.example-card:hover {
    background: #fff;
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.15);
}

.example-card.highlighted {
    border-color: #667eea;
    background: #f0f4ff;
}

.example-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.example-title {
    color: #495057;
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    flex: 1;
}

.example-table {
    background: #667eea;
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    margin-left: 10px;
}

.example-description {
    color: #6c757d;
    font-size: 0.9rem;
    margin-bottom: 12px;
    font-style: italic;
}

.example-formula {
    background: #2d3748;
    color: #e2e8f0;
    padding: 12px;
    border-radius: 6px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.85rem;
    overflow-x: auto;
    margin-bottom: 10px;
    border-left: 4px solid #667eea;
}

.example-actions {
    text-align: center;
    margin-top: 10px;
}

.example-action {
    color: #667eea;
    font-size: 0.9rem;
    font-weight: 500;
}

.examples-accordion {
    margin-top: 20px;
}

.examples-table-group {
    border: 1px solid #e9ecef;
    border-radius: 8px;
    margin-bottom: 10px;
    overflow: hidden;
}

.examples-table-group.current-table {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}

.examples-table-header {
    background: #f8f9fa;
    padding: 15px 20px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s ease;
}

.examples-table-header:hover {
    background: #e9ecef;
}

.examples-table-group.current-table .examples-table-header {
    background: #667eea;
    color: white;
}

.table-name {
    font-weight: 600;
    font-size: 1rem;
}

.table-count {
    color: #6c757d;
    font-size: 0.9rem;
}

.examples-table-group.current-table .table-count {
    color: #e2e8f0;
}

.toggle-icon {
    font-weight: bold;
    transition: transform 0.2s ease;
}

.examples-table-content {
    display: none;
    padding: 20px;
    background: white;
}

.examples-error {
    text-align: center;
    padding: 40px;
    color: #dc3545;
}

.examples-error h3 {
    color: #dc3545;
    margin-bottom: 10px;
}