/* CSS Variables - Dark Theme */
:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #60a5fa;
    --secondary: #64748b;
    --success: #22c55e;
    --success-dark: #16a34a;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg-body: #0f172a;
    --bg-surface: #1e293b;
    --bg-surface-alt: #334155;
    --border: #475569;
    --border-light: #334155;
    --text: #f1f5f9;
    --text-secondary: #e2e8f0;
    --text-muted: #94a3b8;
    --radius: 8px;
    --shadow: 0 4px 6px rgba(0,0,0,0.3);
}

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

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

/* Navbar */
.navbar {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand a {
    color: white;
    text-decoration: none;
    font-size: 1.25rem;
    font-weight: 600;
}

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

.nav-links a {
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    transition: color 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
    color: white;
}

.nav-links a.logout {
    color: var(--danger);
}

/* Container */
.container {
    max-width: 1200px;
    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;
    color: var(--text);
}

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

/* Cards */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card h3 {
    margin-bottom: 1rem;
    color: var(--text);
    font-size: 1.1rem;
}

/* Grid */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    width: 100%;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 38px;
    padding: 0 1.25rem;
    border: none;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    vertical-align: middle;
    box-sizing: border-box;
}

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

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

.btn-secondary {
    background: var(--bg-surface-alt);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

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

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

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

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-full {
    width: 100%;
}

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

/* Forms */
form {
    width: 100%;
}

.form {
    /* No max-width - uses full card width */
}

.form-section {
    margin-bottom: 2rem;
}

.form-section h3 {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.section-desc {
    color: var(--text-muted);
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9375rem;
    background: var(--bg-surface-alt);
    color: var(--text);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.form-group input:disabled {
    background: var(--bg-surface);
    color: var(--text-muted);
}

.form-group small {
    display: block;
    margin-top: 0.375rem;
    color: var(--text-muted);
    font-size: 0.8125rem;
}

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

/* Input with prefix */
.input-with-prefix {
    display: flex;
    align-items: stretch;
}

.input-prefix {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-right: none;
    border-radius: var(--radius) 0 0 var(--radius);
    padding: 0.75rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    white-space: nowrap;
}

.input-with-prefix input {
    border-radius: 0 var(--radius) var(--radius) 0;
}

/* Folder preview - prevent layout shift */
.form-group small code {
    display: inline-block;
    min-width: 280px;
    word-break: break-all;
}

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

.checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.checkbox-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-surface-alt);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s;
}

.checkbox-item:hover {
    background: var(--border);
}

.checkbox-item input[type="checkbox"] {
    width: auto;
    margin-top: 0.25rem;
}

.checkbox-content {
    flex: 1;
}

.checkbox-content strong {
    display: block;
}

.checkbox-content small {
    color: var(--text-muted);
}

/* Tables */
.table-container {
    overflow-x: auto;
}

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

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

.table th {
    background: var(--bg-surface-alt);
    font-weight: 600;
    color: var(--text);
}

.table tbody tr:hover {
    background: var(--bg-surface-alt);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

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

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

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

/* Details list */
.details-list {
    display: grid;
    gap: 0.75rem;
}

.details-list dt {
    font-size: 0.8125rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.details-list dd {
    margin-bottom: 0.5rem;
}

/* Credentials */
.credential-box {
    margin-bottom: 1rem;
}

.credential-box label {
    display: block;
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 0.375rem;
}

.copy-field {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.copy-field code {
    flex: 1;
    padding: 0.5rem 0.75rem;
    background: var(--bg-surface-alt);
    border-radius: var(--radius);
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.875rem;
}

.credential-actions {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* Instructions */
.instructions-card {
    background: linear-gradient(to bottom right, #1e3a5f, #1e293b);
}

.instructions-intro {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.instructions-box {
    background: var(--bg-surface);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.instructions-box h4 {
    margin-bottom: 0.75rem;
    color: var(--text);
}

.instructions-box h5 {
    margin: 1rem 0 0.5rem;
    color: var(--text);
    font-size: 0.9375rem;
}

.instructions-box ul {
    margin-left: 1.25rem;
    margin-bottom: 0.5rem;
}

.instructions-box li {
    margin-bottom: 0.375rem;
}

.code-block {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    background: var(--dark);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin: 0.75rem 0;
}

.code-block code {
    flex: 1;
    color: #22d3ee;
    font-family: 'SF Mono', Monaco, monospace;
}

.code-block .btn {
    background: rgba(255,255,255,0.1);
    color: white;
}

.connection-details {
    background: var(--bg-surface-alt);
    border-radius: var(--radius);
    padding: 1rem;
}

.detail-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    min-width: 100px;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* User list */
.user-list {
    list-style: none;
}

.user-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.user-list li:last-child {
    border-bottom: none;
}

.user-list a {
    color: var(--text);
    text-decoration: none;
}

.user-list a:hover {
    color: var(--primary);
}

/* Danger zone */
.danger-zone {
    border: 1px solid #7f1d1d;
    background: rgba(127, 29, 29, 0.2);
}

.danger-zone h3 {
    color: var(--danger);
}

.danger-zone p {
    color: var(--text-muted);
}

/* Card header with action button */
.card-header-with-action {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.card-header-with-action h3 {
    margin-bottom: 0.25rem;
}

.card-header-with-action .instructions-intro {
    margin-bottom: 0;
}

.btn-copy-instructions {
    white-space: nowrap;
    flex-shrink: 0;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.empty-inline {
    color: var(--text-muted);
    font-style: italic;
}

.empty-inline a {
    color: var(--primary);
}

/* Notes */
.notes-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.notes-section h4 {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

/* Code */
code {
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    background: var(--bg-surface-alt);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-size: 0.875em;
    color: var(--primary-light);
}

/* Text utilities */
.text-muted {
    color: var(--text-muted);
}

/* Login */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

.login-box {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    padding: 2.5rem;
    border-radius: var(--radius);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-width: 400px;
}

.login-box h1 {
    text-align: center;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.login-box .subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.login-form .form-group {
    margin-bottom: 1.25rem;
}

/* Footer */
.footer {
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    text-align: center;
    padding: 1rem;
    font-size: 0.875rem;
}

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

    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
    }

    .container {
        padding: 1rem;
    }

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

    .grid-2 {
        grid-template-columns: 1fr;
    }

    .table th,
    .table td {
        padding: 0.625rem;
        font-size: 0.875rem;
    }
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-surface-alt);
    border: 1px solid var(--border);
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-muted);
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--success);
    border-color: var(--success-dark);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(20px);
    background-color: white;
}

.toggle-switch input:disabled + .toggle-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    animation: slideIn 0.3s ease-out;
    max-width: 350px;
}

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

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

.toast.fade-out {
    animation: fadeOut 0.3s ease-out forwards;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Status cell with toggle */
.status-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-toggle .badge {
    min-width: 60px;
    text-align: center;
}
