/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #0f172a;
    color: #e2e8f0;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
}

/* Typography */
h1 {
    font-size: 2rem;
    font-weight: 600;
    color: #93c5fd;
    margin-bottom: 0.5rem;
}

h2 {
    font-size: 1.5rem;
    font-weight: 500;
    color: #cbd5e1;
    margin-bottom: 0.75rem;
}

p {
    color: #cbd5e1;
    margin-bottom: 1rem;
}

a {
    color: #93c5fd;
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: #60a5fa;
}

/* Navigation */
nav {
    background: #1e293b;
    border-bottom: 1px solid #334155;
    padding: 1rem 2rem;
}

nav.nav-with-env {
    border-bottom: 2px solid var(--env-color, #334155);
}

.nav-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-left {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.nav-logo {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.nav-right {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.nav-right form {
    display: flex;
    align-items: center;
    margin: 0;
}

.nav-link {
    color: #cbd5e1;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: background 0.2s, color 0.2s;
}

.nav-link:hover {
    background: #334155;
    color: #93c5fd;
}

.nav-user {
    color: #cbd5e1;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    line-height: 1;
}

.nav-user strong {
    color: #93c5fd;
}

/* Main Content */
main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

/* SQL Editor Modal */
.sql-editor-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: transparent;
    z-index: 1000;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.sql-editor-modal .sql-editor-content {
    pointer-events: auto;
}

.sql-editor-modal .sql-editor-content * {
    pointer-events: auto;
}

.sql-editor-content {
    background: white;
    border-radius: 8px;
    width: 85%;
    max-width: 1400px;
    height: 85vh;
    overflow: auto;
    resize: both;
    min-width: 800px;
    min-height: 600px;
    position: relative;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: box-shadow 0.3s ease;
}

.sql-editor-content::after {
    content: '⋰';
    position: absolute;
    bottom: 2px;
    right: 2px;
    color: #ccc;
    font-size: 20px;
    pointer-events: none;
}

.sql-editor-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #e0e0e0;
}

.sql-editor-modal .header-actions {
    display: flex;
    gap: 0.5rem;
}

.sql-editor-modal .btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

.sql-input-section {
    padding: 1rem 1.5rem;
}

.sql-textarea {
    width: 100%;
    min-height: 300px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    padding: 1rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    resize: vertical;
}

.sql-textarea:focus {
    outline: none;
    border-color: #4CAF50;
}

.action-buttons {
    padding: 0 1.5rem 1rem 1.5rem;
    display: flex;
    gap: 0.5rem;
}

.messages-section {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e0e0e0;
}

.messages-section h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    color: #333;
}

.messages-pane {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 0.5rem;
    background: #f9f9f9;
}

.messages-empty,
.messages-loading {
    padding: 1rem;
    text-align: center;
    color: #666;
    font-style: italic;
}

.message-line {
    padding: 0.4rem 0.6rem;
    margin: 0.2rem 0;
    border-radius: 3px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.message-success {
    background: #e8f5e9;
    color: #2e7d32;
}

.message-error {
    background: #ffebee;
    color: #c62828;
}

.message-icon {
    font-weight: bold;
    font-size: 14px;
}

.message-sql {
    flex: 1;
}

.message-result {
    color: #666;
    font-size: 12px;
}

.message-error-detail {
    padding: 0.5rem;
    margin: 0.2rem 0;
    background: #fff3cd;
    border-left: 3px solid #ff9800;
    font-family: 'Courier New', Courier, monospace;
    font-size: 12px;
    color: #856404;
}

.message-summary {
    margin-top: 0.5rem;
    padding: 0.6rem;
    border-radius: 4px;
    font-weight: bold;
    text-align: center;
}

.copy-error-btn {
    padding: 0.2rem 0.5rem;
    font-size: 11px;
    background: white;
    border: 1px solid #ccc;
    border-radius: 3px;
    cursor: pointer;
}

.copy-error-btn:hover {
    background: #f0f0f0;
}

/* Results section */
.results-section {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e0e0e0;
}

.results-section h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    color: #333;
}

.result-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
    border-bottom: 2px solid #e0e0e0;
}

.result-tab {
    padding: 0.5rem 1rem;
    background: #f5f5f5;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 14px;
    color: #666;
    transition: all 0.2s;
}

.result-tab:hover {
    background: #e8e8e8;
}

.result-tab.active {
    background: white;
    color: #4CAF50;
    border-bottom-color: #4CAF50;
    font-weight: bold;
}

.result-table-wrapper {
    overflow: auto;
    max-height: 400px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.result-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.result-table th {
    background: #e8e8e8;
    padding: 0.6rem;
    text-align: left;
    font-weight: bold;
    border-bottom: 2px solid #ddd;
    position: sticky;
    top: 0;
    z-index: 10;
    color: #333;
}

.result-table td {
    padding: 0.5rem;
    border-bottom: 1px solid #eee;
    font-family: 'Courier New', Courier, monospace;
    background: #ffffff;
    color: #333;
}

.result-table tbody tr:hover td {
    background: #bbdefb;
    color: #333;
}

.result-table td em {
    color: #999;
    font-style: italic;
}

.expand-btn {
    padding: 0.1rem 0.4rem;
    font-size: 10px;
    background: #e3f2fd;
    border: 1px solid #2196f3;
    border-radius: 3px;
    cursor: pointer;
    color: #1976d2;
}

.expand-btn:hover {
    background: #2196f3;
    color: white;
}

.result-summary {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: #f5f5f5;
    border-radius: 4px;
    font-size: 12px;
    color: #666;
    text-align: center;
}

.no-results {
    padding: 2rem;
    text-align: center;
    color: #999;
    font-style: italic;
}

/* Footer */
footer {
    background: #1e293b;
    border-top: 1px solid #334155;
    padding: 1rem 2rem;
    text-align: center;
}

footer.footer-with-env {
    border-top: 2px solid var(--env-color, #334155);
}

footer p {
    color: #94a3b8;
    font-size: 0.9rem;
    margin: 0;
}
/* Progress dots for database refresh */
.progress-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #2d3748;
    border: 2px solid #4a5568;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #a0aec0;
    transition: all 0.3s ease;
}

.progress-dot.active {
    background: #3182ce;
    border-color: #3182ce;
    color: white;
    animation: pulse 1s infinite;
}

.progress-dot.complete {
    background: #48bb78;
    border-color: #48bb78;
    color: white;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}
/* Login Container */
.login-container {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    text-align: center;
}

.subtitle {
    color: #94a3b8;
    font-size: 1rem;
    margin-bottom: 2rem;
}

/* Dashboard */
.dashboard {
    width: 100%;
    max-width: 1200px;
}

.dashboard-intro {
    color: #94a3b8;
    font-size: 1.1rem;
    margin-bottom: 2rem;
}

/* Forms */
form {
    margin-top: 1.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

label {
    display: block;
    color: #cbd5e1;
    font-weight: 500;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 0.75rem;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 6px;
    color: #e2e8f0;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus,
input[type="password"]:focus {
    outline: none;
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.1);
}

/* Buttons */
button {
    cursor: pointer;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: 6px;
    padding: 0.75rem 1.5rem;
    transition: background-color 0.2s, transform 0.1s;
}

button:hover {
    transform: translateY(-1px);
}

button:active {
    transform: translateY(0);
}

.btn-primary {
    width: 100%;
    background: #3b82f6;
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
}

.btn-logout {
    background: #475569;
    color: #e2e8f0;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.btn-logout:hover {
    background: #64748b;
}

/* Cards */
.card {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

/* Status Indicators */
.status-unknown {
    color: #94a3b8;
    font-weight: 500;
}

.status-running {
    color: #34d399;
    font-weight: 500;
}

.status-stopped {
    color: #f87171;
    font-weight: 500;
}

/* Error Messages */
.error {
    background: #7f1d1d;
    border: 1px solid #991b1b;
    border-radius: 6px;
    color: #fca5a5;
    padding: 0.75rem;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    nav {
        padding: 1rem;
    }

    .nav-content {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
    }

    main {
        padding: 1rem;
    }

    .login-container {
        padding: 2rem;
    }

    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.25rem;
    }
}

@media (max-width: 480px) {
    .login-container {
        padding: 1.5rem;
    }

    button {
        font-size: 0.95rem;
    }
}

/* Dashboard Styles */
.dashboard {
    width: 100%;
    max-width: 1400px;
    padding: 2rem;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.dashboard-header h1 {
    margin: 0;
}

.header-actions {
    display: flex;
    gap: 12px;
}

.btn-refresh {
    background: #3b82f6;
    color: white;
    padding: 0.6rem 1.2rem;
    font-size: 0.95rem;
}

.btn-refresh:hover {
    background: #2563eb;
}

.btn-refresh:disabled {
    background: #475569;
    cursor: not-allowed;
    transform: none;
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #334155;
}

.card-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

.card-body {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
}

.status-row .label {
    color: #94a3b8;
    font-weight: 500;
    font-size: 0.9rem;
}

.status-row .value {
    color: #e2e8f0;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    text-align: right;
    max-width: 60%;
    word-break: break-word;
}

.status-indicator {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
}

.status-good {
    background: #064e3b;
    color: #34d399;
    border: 1px solid #10b981;
}

.status-warn {
    background: #713f12;
    color: #fbbf24;
    border: 1px solid #f59e0b;
}

.status-error {
    background: #7f1d1d;
    color: #fca5a5;
    border: 1px solid #ef4444;
}

.status-unknown {
    background: #1e293b;
    color: #94a3b8;
    border: 1px solid #475569;
}

.warning {
    background: #713f12;
    border: 1px solid #f59e0b;
    border-radius: 6px;
    color: #fbbf24;
    padding: 0.75rem;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.error-msg {
    background: #7f1d1d;
    border: 1px solid #ef4444;
    border-radius: 6px;
    color: #fca5a5;
    padding: 0.75rem;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    font-family: 'Courier New', monospace;
    word-break: break-word;
}

.dashboard-footer {
    text-align: center;
    padding-top: 1rem;
    border-top: 1px solid #334155;
}

.dashboard-footer p {
    color: #94a3b8;
    font-size: 0.9rem;
    margin: 0;
}

#last-updated {
    color: #cbd5e1;
    font-weight: 500;
}

/* Responsive Dashboard */
@media (max-width: 768px) {
    .dashboard {
        padding: 1rem;
    }

    .dashboard-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .status-grid {
        grid-template-columns: 1fr;
    }

    .status-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .status-row .value {
        max-width: 100%;
        text-align: left;
    }
}
