/**
 * Server Manager - Shared Styles
 * Professional dark/light theme with consistent styling
 */

/* CSS Variables for theming - Dark theme is default */
:root {
    /* Dark theme (default) */
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #252540;
    --bg-header: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    
    --text-primary: #e8e8f0;
    --text-secondary: #a8a8c0;
    --text-muted: #686888;
    
    --border-color: #2a2a45;
    --border-light: #1f1f35;
    
    --accent-primary: #667eea;
    --accent-secondary: #764ba2;
    --accent-hover: #7b93ff;
    
    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.15);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.15);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.15);
    --info: #3b82f6;
    --info-bg: rgba(59, 130, 246, 0.15);
    
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.4);
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    
    --transition: 0.2s ease;
    
    /* Input styles */
    --input-bg: #252540;
    --input-border: #3a3a55;
    --input-focus: #667eea;
    
    /* Nav styles */
    --nav-bg: #1a1a2e;
    --nav-hover: #252540;
    --nav-active: #667eea;
    
    /* Table styles */
    --table-header: #252540;
    --table-row-hover: #2a2a48;
    --table-border: #3a3a55;
    
    /* Console */
    --console-bg: #0d0d15;
    --console-text: #cdd6f4;
}

/* Light theme */
[data-theme="light"], .theme-light {
    --bg-primary: #f5f6fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8eaed;
    --bg-header: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    
    --text-primary: #1a1a2e;
    --text-secondary: #4a4a68;
    --text-muted: #8888a0;
    
    --border-color: #e0e0e8;
    --border-light: #f0f0f5;
    
    --accent-primary: #667eea;
    --accent-secondary: #764ba2;
    --accent-hover: #5a6fd6;
    
    --success-bg: #dcfce7;
    --warning-bg: #fef3c7;
    --danger-bg: #fee2e2;
    --info-bg: #dbeafe;
    
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.12);
    
    --input-bg: #ffffff;
    --input-border: #d0d0d8;
    --input-focus: #667eea;
    
    --nav-bg: #ffffff;
    --nav-hover: #f0f0f5;
    --nav-active: #667eea;
    
    --table-header: #f5f6fa;
    --table-row-hover: #f8f9fc;
    --table-border: #e8eaed;
    
    --console-bg: #1e1e2e;
    --console-text: #cdd6f4;
}

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

/* Base */
html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background var(--transition), color var(--transition);
}

a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--accent-hover);
}

/* Header */
.header {
    background: var(--bg-header);
    color: white;
    padding: 15px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 50;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

.header .user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* User Menu / Avatar */
.user-menu {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    transition: background var(--transition);
}

.user-menu:hover {
    background: rgba(255, 255, 255, 0.1);
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    min-width: 220px;
    box-shadow: var(--shadow-lg);
    display: none;
    z-index: 100;
    overflow: hidden;
}

.user-dropdown.show {
    display: block;
}

.user-dropdown-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
    background: var(--bg-tertiary);
}

.user-dropdown-header .avatar-large {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-full);
    background: var(--accent-primary);
    margin: 0 auto 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    font-weight: 600;
    color: white;
    overflow: hidden;
}

.user-dropdown-header .avatar-large img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-dropdown-header .display-name {
    font-weight: 600;
    color: var(--text-primary);
}

.user-dropdown-header .username {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.user-dropdown a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    color: var(--text-primary);
    transition: background var(--transition);
}

.user-dropdown a:hover {
    background: var(--nav-hover);
}

.user-dropdown a.danger {
    color: var(--danger);
}

/* Navigation */
.nav-menu {
    background: var(--nav-bg);
    padding: 12px 25px;
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.nav-menu a {
    padding: 10px 18px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.9rem;
    transition: all var(--transition);
}

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

.nav-menu a.active {
    background: var(--nav-active);
    color: white;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 25px;
}

/* Cards */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.card-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}

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

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

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

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

.btn-secondary:hover:not(:disabled) {
    background: var(--nav-hover);
}

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

.btn-success:hover:not(:disabled) {
    background: #1db954;
}

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

.btn-warning:hover:not(:disabled) {
    background: #e68a00;
}

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

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

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

.btn-lg {
    padding: 14px 28px;
    font-size: 1rem;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 14px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--input-focus);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.form-group input:disabled {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: not-allowed;
}

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

/* Tables */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--table-border);
}

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

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

table th {
    background: var(--table-header);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

table tr:hover {
    background: var(--table-row-hover);
}

table tr:last-child td {
    border-bottom: none;
}

/* Status badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.badge-info {
    background: var(--info-bg);
    color: var(--info);
}

/* Stats cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    text-align: center;
}

.stat-card h3 {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-primary);
}

.stat-value.success {
    color: var(--success);
}

.stat-value.danger {
    color: var(--danger);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color var(--transition);
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Notifications */
.notification {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 16px 24px;
    border-radius: var(--radius-md);
    color: white;
    font-weight: 500;
    z-index: 1000;
    display: none;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
}

.notification.show {
    display: block;
}

.notification.success {
    background: var(--success);
}

.notification.error {
    background: var(--danger);
}

.notification.info {
    background: var(--info);
}

.notification.warning {
    background: var(--warning);
}

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

/* Server list items */
.server-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    transition: background var(--transition);
}

.server-item:hover {
    background: var(--table-row-hover);
}

.server-item:last-child {
    border-bottom: none;
}

.server-info h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.server-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.server-actions {
    display: flex;
    gap: 8px;
}

/* Console */
.console-panel {
    background: var(--console-bg);
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.console-header {
    background: rgba(0, 0, 0, 0.3);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.console-header h3 {
    color: var(--console-text);
    font-size: 0.9rem;
    margin: 0;
}

.console-output {
    padding: 16px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.85rem;
    color: var(--console-text);
    min-height: 300px;
    max-height: 500px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.console-input-container {
    display: flex;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.console-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: none;
    padding: 14px 16px;
    color: var(--console-text);
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
}

.console-input:focus {
    outline: none;
}

.console-send {
    background: var(--accent-primary);
    border: none;
    color: white;
    padding: 14px 24px;
    cursor: pointer;
    transition: background var(--transition);
}

.console-send:hover {
    background: var(--accent-hover);
}

/* Progress bars */
.progress-bar {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent-primary);
    transition: width 0.3s ease;
}

/* Loading states */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 40px;
    color: var(--text-muted);
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state h3 {
    font-size: 1.2rem;
    margin-bottom: 10px;
    color: var(--text-secondary);
}

/* Utility classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.hidden { display: none !important; }

/* Responsive */
@media (max-width: 768px) {
    .header {
        padding: 12px 15px;
    }
    
    .header h1 {
        font-size: 1.2rem;
    }
    
    .nav-menu {
        padding: 10px 15px;
        gap: 6px;
    }
    
    .nav-menu a {
        padding: 8px 14px;
        font-size: 0.85rem;
    }
    
    .container {
        padding: 15px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .server-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .server-actions {
        width: 100%;
        justify-content: flex-start;
    }
}
