/* Ollama Admin Panel - Styles */

:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --border: #334155;
    --sidebar-width: 260px;
    --radius: 8px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

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

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

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

a:hover {
    text-decoration: underline;
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    z-index: 100;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    text-align: center;
}

.sidebar-header .logo {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.sidebar-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

.nav-menu {
    list-style: none;
    padding: 1rem 0;
    flex: 1;
    overflow-y: auto;
}

.nav-menu li a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.5rem;
    color: var(--text-secondary);
    transition: all 0.2s;
    text-decoration: none;
}

.nav-menu li a:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

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

.nav-menu li a .icon {
    font-size: 1.25rem;
}

.nav-divider {
    height: 1px;
    background: var(--border);
    margin: 0.5rem 1.5rem;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.user-badge .avatar {
    font-size: 1.5rem;
}

.user-badge .username {
    display: block;
    font-weight: 500;
}

.user-badge .role {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: capitalize;
}

/* Main Content */
main {
    min-height: 100vh;
}

main.with-sidebar {
    margin-left: var(--sidebar-width);
}

.content {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

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

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 600;
}

.page-header p {
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

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

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

.card-header h2,
.card-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.card-body {
    padding: 1.5rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

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

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

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
}

.btn-outline:hover {
    background: var(--bg-tertiary);
}

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

.btn-danger:hover {
    background: #dc2626;
}

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

.btn-full {
    width: 100%;
    justify-content: center;
}

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

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
}

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

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
}

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

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

/* 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 {
    font-weight: 600;
    font-size: 0.8125rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
}

.table tr:hover {
    background: var(--bg-tertiary);
}

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

/* Status indicators */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.5rem;
}

.status-dot.active { background: var(--success); }
.status-dot.inactive { background: var(--text-muted); }

.status {
    font-weight: 500;
}

.status.online { color: var(--success); }
.status.offline { color: var(--danger); }
.status.warning { color: var(--warning); }
.status.loading { color: var(--text-muted); }

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

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

/* Modal */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    align-items: center;
    justify-content: center;
}

.modal.open {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
}

.modal-content {
    position: relative;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    margin: 1rem;
}

.modal-lg {
    max-width: 640px;
}

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

.modal-header h2 {
    font-size: 1.25rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.modal-body {
    padding: 1.5rem;
}

.modal form {
    padding: 1.5rem;
}

/* Login */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.login-box {
    width: 100%;
    max-width: 400px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 2rem;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.login-header p {
    color: var(--text-secondary);
}

.login-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Status Cards */
.status-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.status-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
}

.status-card .card-icon {
    font-size: 2rem;
}

.status-card h3 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
}

/* Quick Actions */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.action-btn:hover {
    background: var(--bg-primary);
    border-color: var(--accent);
    text-decoration: none;
}

.action-btn .icon {
    font-size: 1.5rem;
}

/* Progress Bar */
.progress-container {
    margin-bottom: 1rem;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.progress-bar {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

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

/* Models Grid */
.models-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    padding: 1.5rem;
}

.model-card {
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.model-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.model-icon {
    font-size: 1.5rem;
}

.model-header h4 {
    font-size: 0.9375rem;
    word-break: break-all;
}

.model-details {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}

.model-details .detail {
    flex: 1;
    min-width: 80px;
}

.model-details .label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.model-details .value {
    font-size: 0.875rem;
}

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

/* Recommended Models */
.recommended-models {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

.model-suggestion {
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
}

.model-suggestion:hover {
    background: var(--bg-primary);
    border: 1px solid var(--accent);
}

.model-suggestion .model-name {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.model-suggestion .model-desc {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

/* Pull Progress */
.pull-progress {
    padding: 1.5rem;
}

.pull-progress.hidden {
    display: none;
}

.pull-progress .progress-status {
    margin-bottom: 1rem;
    font-weight: 500;
}

.pull-progress .progress-details {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Chat */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 4rem);
    max-width: 900px;
    margin: 0 auto;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.chat-title {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.chat-title h1 {
    font-size: 1.5rem;
}

.session-tokens {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.chat-controls {
    display: flex;
    gap: 0.75rem;
}

.chat-controls select {
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.chat-welcome {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.chat-welcome .welcome-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.message {
    display: flex;
    gap: 1rem;
    padding: 1rem 0;
}

.message-avatar {
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border-radius: 50%;
    flex-shrink: 0;
}

.message-content {
    flex: 1;
    min-width: 0;
}

.message-text {
    line-height: 1.6;
}

.message-text pre {
    background: var(--bg-tertiary);
    padding: 1rem;
    border-radius: var(--radius);
    overflow-x: auto;
    margin: 0.5rem 0;
}

.message-text code {
    background: var(--bg-tertiary);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-family: 'Fira Code', monospace;
    font-size: 0.875rem;
}

.message-text pre code {
    background: none;
    padding: 0;
}

.chat-input-container {
    padding: 1rem 0;
    border-top: 1px solid var(--border);
}

.chat-input-wrapper {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.chat-input-wrapper textarea {
    flex: 1;
    padding: 0.875rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.9375rem;
    resize: none;
    max-height: 200px;
}

.chat-input-wrapper textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.send-btn {
    padding: 0.875rem 1.25rem;
    background: var(--accent);
    border: none;
    border-radius: var(--radius);
    color: white;
    cursor: pointer;
    transition: background 0.2s;
}

.send-btn:hover:not(:disabled) {
    background: var(--accent-hover);
}

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

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    font-size: 2rem;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 600;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Chart */
.chart-container {
    height: 200px;
}

.simple-chart {
    display: flex;
    align-items: flex-end;
    height: 100%;
    gap: 4px;
}

.chart-bar-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
}

.chart-bar {
    width: 100%;
    max-width: 40px;
    background: var(--accent);
    border-radius: 4px 4px 0 0;
    min-height: 4px;
    margin-top: auto;
}

.chart-label {
    font-size: 0.625rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    text-align: center;
}

/* API Key Display */
.key-display {
    background: var(--bg-tertiary);
    padding: 1rem;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1rem 0;
}

.key-display code {
    flex: 1;
    word-break: break-all;
    font-family: 'Fira Code', monospace;
    font-size: 0.8125rem;
}

/* Info Grid */
.info-grid {
    display: grid;
    gap: 1rem;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.info-label {
    color: var(--text-secondary);
}

.info-value code {
    background: var(--bg-tertiary);
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8125rem;
}

/* Logs */
.log-viewer {
    background: var(--bg-primary);
    padding: 1rem;
    border-radius: var(--radius);
    font-family: 'Fira Code', monospace;
    font-size: 0.8125rem;
    line-height: 1.6;
    max-height: 600px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

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

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid var(--warning);
    color: var(--warning);
}

/* Toast */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 300;
}

.toast {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    animation: slideIn 0.3s ease;
}

.toast-success { border-color: var(--success); }
.toast-error { border-color: var(--danger); }

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

/* Utility */
.loading {
    color: var(--text-muted);
    text-align: center;
    padding: 2rem;
}

.empty {
    color: var(--text-muted);
    text-align: center;
    padding: 2rem;
}

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

.hidden {
    display: none !important;
}

.running-model {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
}

.gpu-info .gpu-name {
    font-weight: 500;
    margin-bottom: 1rem;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    main.with-sidebar {
        margin-left: 0;
    }

    .content {
        padding: 1rem;
    }

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

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