/**
 * MetalCloud Dashboard Styles
 * World-class UI with Apple aesthetics + distinctive copper accents
 */

:root {
    --black-deep: #0a0a0a;
    --black-soft: #111111;
    --black-card: #161616;
    --black-elevated: #1c1c1c;
    --black-hover: #242424;
    --black-border: #2a2a2a;
    --metal-copper: #d4722c;
    --metal-amber: #f0a050;
    --metal-gold: #ffd700;
    --metal-glow: rgba(212, 114, 44, 0.4);
    --gradient-metal: linear-gradient(135deg, var(--metal-copper) 0%, var(--metal-amber) 50%, var(--metal-gold) 100%);
    --white-pure: #ffffff;
    --white-soft: #f5f5f7;
    --gray-300: #a1a1a6;
    --gray-400: #86868b;
    --gray-500: #6e6e73;
    --gray-600: #48484a;
    --success: #30d158;
    --success-bg: rgba(48, 209, 88, 0.12);
    --warning: #ffd60a;
    --warning-bg: rgba(255, 214, 10, 0.12);
    --error: #ff453a;
    --error-bg: rgba(255, 69, 58, 0.12);
    --sidebar-width: 260px;
    --header-height: 64px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --font-system: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', monospace;
    --transition-fast: 0.15s ease;
    --transition-smooth: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; }
body { font-family: var(--font-system); background: var(--black-deep); color: var(--white-soft); line-height: 1.5; -webkit-font-smoothing: antialiased; }
::selection { background: var(--metal-copper); color: var(--white-pure); }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; font-size: inherit; }

/* Layout */
.app-container { display: flex; min-height: 100vh; }

.sidebar { width: var(--sidebar-width); background: var(--black-soft); border-right: 1px solid var(--black-border); display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 100; }
.sidebar-header { height: var(--header-height); padding: 0 20px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--black-border); }
.sidebar-logo { width: 36px; height: 36px; background: var(--gradient-metal); border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.1rem; color: var(--black-deep); }
.sidebar-brand { font-weight: 600; font-size: 1.1rem; letter-spacing: -0.02em; }
.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-section { margin-bottom: 24px; }
.nav-section-title { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--gray-500); padding: 0 12px; margin-bottom: 8px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-md); color: var(--gray-300); transition: all var(--transition-fast); margin-bottom: 2px; position: relative; }
.nav-item:hover { background: var(--black-hover); color: var(--white-soft); }
.nav-item.active { background: var(--black-elevated); color: var(--white-pure); }
.nav-item.active::before { content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%); width: 3px; height: 24px; background: var(--gradient-metal); border-radius: 0 2px 2px 0; }
.nav-item-icon { width: 20px; text-align: center; font-size: 1.1rem; }
.nav-item-text { font-size: 0.9rem; font-weight: 500; }
.nav-item-badge { margin-left: auto; padding: 2px 8px; background: var(--metal-copper); color: var(--white-pure); font-size: 0.7rem; font-weight: 600; border-radius: 100px; }
.sidebar-footer { padding: 16px; border-top: 1px solid var(--black-border); }
.user-menu { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-md); transition: background var(--transition-fast); cursor: pointer; }
.user-menu:hover { background: var(--black-hover); }
.user-avatar { width: 36px; height: 36px; background: var(--gradient-metal); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 0.9rem; color: var(--black-deep); }
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 0.85rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.75rem; color: var(--gray-400); }

.main-content { flex: 1; margin-left: var(--sidebar-width); min-height: 100vh; display: flex; flex-direction: column; }
.main-header { height: var(--header-height); background: rgba(17, 17, 17, 0.8); backdrop-filter: blur(20px); border-bottom: 1px solid var(--black-border); display: flex; align-items: center; justify-content: space-between; padding: 0 32px; position: sticky; top: 0; z-index: 50; }
.page-title { font-size: 1.25rem; font-weight: 600; letter-spacing: -0.02em; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.main-body { flex: 1; padding: 32px; max-width: 1400px; }

/* Stat Cards */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 32px; }
.stat-card { background: var(--black-card); border: 1px solid var(--black-border); border-radius: var(--radius-lg); padding: 24px; position: relative; overflow: hidden; transition: all 0.25s ease; }
.stat-card:hover { border-color: var(--black-hover); transform: translateY(-2px); }
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--gradient-metal); opacity: 0; transition: opacity var(--transition-fast); }
.stat-card:hover::before { opacity: 1; }
.stat-icon { width: 44px; height: 44px; background: linear-gradient(135deg, rgba(212, 114, 44, 0.15) 0%, rgba(240, 160, 80, 0.08) 100%); border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; font-size: 1.3rem; margin-bottom: 16px; }
.stat-value { font-size: 2rem; font-weight: 700; letter-spacing: -0.03em; margin-bottom: 4px; }
.stat-value.gradient { background: var(--gradient-metal); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.stat-label { font-size: 0.85rem; color: var(--gray-400); }
.stat-change { display: inline-flex; align-items: center; gap: 4px; font-size: 0.8rem; font-weight: 500; margin-top: 8px; padding: 4px 8px; border-radius: 100px; }
.stat-change.positive { background: var(--success-bg); color: var(--success); }
.stat-change.negative { background: var(--error-bg); color: var(--error); }

/* Cards */
.card { background: var(--black-card); border: 1px solid var(--black-border); border-radius: var(--radius-lg); overflow: hidden; }
.card-header { padding: 20px 24px; border-bottom: 1px solid var(--black-border); display: flex; align-items: center; justify-content: space-between; }
.card-title { font-size: 1rem; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.card-body { padding: 24px; }
.card-footer { padding: 16px 24px; border-top: 1px solid var(--black-border); background: var(--black-soft); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 20px; font-size: 0.9rem; font-weight: 500; border-radius: var(--radius-md); transition: all var(--transition-fast); white-space: nowrap; }
.btn-primary { background: var(--gradient-metal); color: var(--black-deep); }
.btn-primary:hover { box-shadow: 0 0 30px var(--metal-glow); transform: translateY(-1px); }
.btn-secondary { background: var(--black-elevated); color: var(--white-soft); border: 1px solid var(--black-border); }
.btn-secondary:hover { background: var(--black-hover); border-color: var(--gray-600); }
.btn-ghost { color: var(--gray-300); }
.btn-ghost:hover { background: var(--black-hover); color: var(--white-soft); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: var(--radius-sm); }

/* Forms */
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: 0.85rem; font-weight: 500; color: var(--gray-300); margin-bottom: 8px; }
.form-input { width: 100%; padding: 12px 16px; background: var(--black-soft); border: 1px solid var(--black-border); border-radius: var(--radius-md); color: var(--white-pure); font-size: 0.95rem; transition: all var(--transition-fast); }
.form-input::placeholder { color: var(--gray-500); }
.form-input:focus { outline: none; border-color: var(--metal-copper); box-shadow: 0 0 0 3px var(--metal-glow); }
.form-hint { font-size: 0.8rem; color: var(--gray-500); margin-top: 6px; }
.form-error { font-size: 0.8rem; color: var(--error); margin-top: 6px; }

/* Tables */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--black-border); }
th { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--gray-400); background: var(--black-soft); }
tr:hover td { background: var(--black-elevated); }
td { font-size: 0.9rem; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; font-size: 0.75rem; font-weight: 600; border-radius: 100px; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-error { background: var(--error-bg); color: var(--error); }
.badge-neutral { background: var(--black-elevated); color: var(--gray-300); }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* Code blocks */
.code-block { background: var(--black-soft); border: 1px solid var(--black-border); border-radius: var(--radius-md); padding: 16px; font-family: var(--font-mono); font-size: 0.85rem; overflow-x: auto; position: relative; }
.code-block .copy-btn { position: absolute; top: 8px; right: 8px; padding: 6px 10px; background: var(--black-elevated); border-radius: var(--radius-sm); font-size: 0.75rem; color: var(--gray-400); opacity: 0; transition: opacity var(--transition-fast); }
.code-block:hover .copy-btn { opacity: 1; }
.code-block .copy-btn:hover { color: var(--white-soft); }

/* Empty state */
.empty-state { text-align: center; padding: 60px 24px; }
.empty-state-icon { font-size: 3rem; margin-bottom: 16px; opacity: 0.5; }
.empty-state-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 8px; }
.empty-state-desc { font-size: 0.9rem; color: var(--gray-400); margin-bottom: 24px; max-width: 320px; margin-left: auto; margin-right: auto; }

/* Charts placeholder */
.chart-container { height: 300px; display: flex; align-items: center; justify-content: center; background: var(--black-soft); border-radius: var(--radius-md); }

/* Activity feed */
.activity-item { display: flex; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--black-border); }
.activity-item:last-child { border-bottom: none; }
.activity-icon { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1rem; flex-shrink: 0; }
.activity-icon.success { background: var(--success-bg); color: var(--success); }
.activity-icon.warning { background: var(--warning-bg); color: var(--warning); }
.activity-icon.error { background: var(--error-bg); color: var(--error); }
.activity-content { flex: 1; }
.activity-title { font-size: 0.9rem; font-weight: 500; margin-bottom: 2px; }
.activity-desc { font-size: 0.8rem; color: var(--gray-400); }
.activity-time { font-size: 0.75rem; color: var(--gray-500); margin-top: 4px; }

/* Toast */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 12px; }
.toast { background: var(--black-elevated); border: 1px solid var(--black-border); padding: 16px 20px; border-radius: var(--radius-md); display: flex; align-items: center; gap: 12px; min-width: 300px; box-shadow: 0 8px 32px rgba(0,0,0,0.4); animation: slideIn 0.3s ease; }
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--error); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Mobile Menu Toggle */
.mobile-menu-btn { display: none; width: 40px; height: 40px; background: var(--black-elevated); border: 1px solid var(--black-border); border-radius: var(--radius-sm); align-items: center; justify-content: center; }
.mobile-menu-btn span { width: 18px; height: 2px; background: var(--white-soft); position: relative; }
.mobile-menu-btn span::before, .mobile-menu-btn span::after { content: ''; position: absolute; width: 18px; height: 2px; background: var(--white-soft); left: 0; }
.mobile-menu-btn span::before { top: -6px; }
.mobile-menu-btn span::after { top: 6px; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 99; }

/* Logout Button */
.logout-btn { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; margin-top: 8px; border-radius: var(--radius-md); color: var(--gray-400); font-size: 0.85rem; transition: all var(--transition-fast); }
.logout-btn:hover { background: var(--error-bg); color: var(--error); }

/* Responsive - Tablet */
@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.3s ease; }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.open { display: block; }
    .main-content { margin-left: 0; }
    .main-body { padding: 24px 16px; }
    .mobile-menu-btn { display: flex; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .main-header { padding: 0 16px; }
}

/* Responsive - Mobile */
@media (max-width: 640px) {
    :root { --header-height: 56px; }
    .stat-grid { grid-template-columns: 1fr; gap: 12px; }
    .stat-card { padding: 16px; }
    .stat-value { font-size: 1.5rem; }
    .stat-icon { width: 36px; height: 36px; font-size: 1.1rem; margin-bottom: 12px; }
    .card-header { padding: 16px; flex-wrap: wrap; gap: 12px; }
    .card-body { padding: 16px; }
    .page-title { font-size: 1.1rem; }
    .header-actions { gap: 8px; }
    .btn-sm { padding: 6px 10px; font-size: 0.75rem; }
    table { font-size: 0.8rem; }
    th, td { padding: 10px 12px; }
    .toast-container { left: 16px; right: 16px; bottom: 16px; }
    .toast { min-width: auto; width: 100%; }
    .code-block { font-size: 0.75rem; padding: 12px; }
    .activity-item { padding: 12px 0; gap: 12px; }
    .activity-icon { width: 32px; height: 32px; font-size: 0.9rem; }
    
    /* Two-column grids become single */
    [style*="grid-template-columns: 1fr 1fr"] { grid-template-columns: 1fr !important; }
    [style*="grid-template-columns: 2fr 1fr"] { grid-template-columns: 1fr !important; }
}

/* Touch-friendly */
@media (hover: none) {
    .nav-item { padding: 12px; }
    .btn { min-height: 44px; }
    .form-input { min-height: 48px; padding: 14px 16px; }
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.modal-overlay.open { opacity: 1; }
.modal-content {
    background: var(--black-card);
    border: 1px solid var(--black-border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: scale(0.95) translateY(20px);
    transition: transform 0.3s ease;
}
.modal-overlay.open .modal-content { transform: scale(1) translateY(0); }
.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--black-border);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}
.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--gray-400);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}
.modal-close:hover { background: var(--black-hover); color: var(--white-soft); }
.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--black-border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: var(--black-soft);
}

/* Detail rows for job modal */
.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--black-border);
    font-size: 0.9rem;
}
.detail-row:last-child { border-bottom: none; }
.detail-row span:first-child { color: var(--gray-400); }
.detail-row span:last-child { color: var(--white-soft); }

/* Job status banners */
.job-status-banner { background: var(--black-soft); }
.job-status-banner.running { background: linear-gradient(135deg, rgba(255, 214, 10, 0.08) 0%, rgba(255, 214, 10, 0.02) 100%); border: 1px solid rgba(255, 214, 10, 0.2); }
.job-status-banner.completed { background: linear-gradient(135deg, rgba(48, 209, 88, 0.08) 0%, rgba(48, 209, 88, 0.02) 100%); border: 1px solid rgba(48, 209, 88, 0.2); }
.job-status-banner.failed { background: linear-gradient(135deg, rgba(255, 69, 58, 0.08) 0%, rgba(255, 69, 58, 0.02) 100%); border: 1px solid rgba(255, 69, 58, 0.2); }

/* Pulse animation for active jobs */
.pulse {
    display: inline-block;
    width: 6px;
    height: 6px;
    background: currentColor;
    border-radius: 50%;
    margin-right: 6px;
    animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

/* Typing dots animation */
.typing-dots {
    display: inline-block;
    animation: typingDots 1.4s infinite;
}
@keyframes typingDots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* Log level colors */
.log-level-info { color: var(--gray-300); }
.log-level-warning { color: var(--warning); }
.log-level-error { color: var(--error); }
.log-level-debug { color: var(--gray-500); }

/* Job row hover */
.job-row { transition: background var(--transition-fast); }
.job-row:hover { background: var(--black-elevated); }
.job-row.job-active { background: rgba(255, 214, 10, 0.03); }

/* Mobile modal */
@media (max-width: 640px) {
    .modal-overlay { padding: 0; align-items: flex-end; }
    .modal-content { 
        max-height: 95vh; 
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }
    .modal-body { padding: 16px; }
    .modal-header { padding: 16px; }
    .modal-footer { padding: 12px 16px; }
    .detail-row { font-size: 0.85rem; }
}

/* Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--black-border);
    border-top-color: var(--metal-copper);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Badge variants */
.badge-info { background: rgba(10, 132, 255, 0.15); color: #0a84ff; }
.badge-warning { background: rgba(255, 214, 10, 0.15); color: #ffd60a; }
