@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --sidebar-width: 260px;
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --sidebar-active: rgba(99, 102, 241, 0.15);
    --sidebar-accent: #6366f1;
    --bg-main: #f1f5f9;
    --card-bg: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --purple: #8b5cf6;
    --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --gradient-danger: linear-gradient(135deg, #ef4444 0%, #f97316 100%);
    --gradient-success: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --gradient-info: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
    --gradient-warning: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.04), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.06), 0 4px 10px rgba(0,0,0,0.04);
    --radius: 12px;
    --radius-sm: 8px;
}

* { box-sizing: border-box; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    margin: 0;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ─── Sidebar ────────────────────────────────────── */
.sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-brand .logo {
    width: 40px; height: 40px;
    border-radius: 10px;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-brand .logo svg { width: 22px; height: 22px; }

.sidebar-brand h1 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
    line-height: 1.2;
}

.sidebar-brand small {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 400;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.sidebar-nav .nav-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 16px 12px 8px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: #cbd5e1;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s ease;
    margin-bottom: 2px;
}

.sidebar-nav a:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.sidebar-nav a.active {
    background: var(--sidebar-active);
    color: var(--sidebar-accent);
}

.sidebar-nav a i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
    cursor: pointer;
    position: relative;
}

.sidebar-user:hover { background: var(--sidebar-hover); }

.sidebar-user .avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.sidebar-user .user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user .user-name {
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user .user-role {
    color: var(--text-muted);
    font-size: 0.7rem;
}

.sidebar-footer {
    position: relative;
}
.user-dropdown {
    display: none;
    position: absolute;
    bottom: calc(100% + 4px);
    left: 8px; right: 8px;
    background: #1e293b;
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.3);
    z-index: 1100;
    border: 1px solid rgba(255,255,255,0.08);
}

.user-dropdown.show { display: block; }

.user-dropdown a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 0.82rem;
    transition: background 0.15s;
}

.user-dropdown a:hover { background: rgba(255,255,255,0.05); color: #fff; }
.user-dropdown a.text-danger:hover { color: var(--danger); }

/* ─── Main content ────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    padding: 0;
}

.topbar {
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar h2 {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
}

.topbar .status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
}

.status-on { background: #ecfdf5; color: #059669; }
.status-pause { background: #fffbeb; color: #d97706; }
.status-off { background: #fef2f2; color: #dc2626; }
.status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.status-on .status-dot { background: #10b981; animation: pulse-green 2s infinite; }
.status-pause .status-dot { background: #f59e0b; }
.status-off .status-dot { background: #ef4444; }

@keyframes pulse-green {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.content-area {
    padding: 28px 32px;
}

/* ─── Cards ────────────────────────────────── */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease;
}

.card:hover { box-shadow: var(--shadow-md); }

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 0.9rem;
    padding: 16px 20px;
    color: var(--text-primary);
}

.card-body { padding: 20px; }

/* ─── Stat cards ────────────────────────────────── */
.stat-card {
    border: none;
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.stat-card .stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: #fff;
    margin-bottom: 14px;
}

.stat-card .stat-value {
    font-size: clamp(1.1rem, 2.5vw, 1.8rem);
    font-weight: 800;
    line-height: 1;
    margin-bottom: 4px;
    word-break: break-all;
    overflow-wrap: break-word;
}

.stat-card .stat-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-card .stat-bar {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
}

/* ─── Tables ────────────────────────────────── */
.table { font-size: 0.85rem; }
.table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    padding: 12px 16px;
}

.table td {
    padding: 10px 16px;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
}

.table-hover tbody tr:hover { background: #f8fafc; }

/* ─── Badges ────────────────────────────────── */
.badge {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 6px;
    letter-spacing: 0.02em;
}

.badge-robinson { background: #fef2f2; color: #dc2626; }
.badge-safe { background: #ecfdf5; color: #059669; }
.badge-active { background: #ecfdf5; color: #059669; }
.badge-inactive { background: #f1f5f9; color: #64748b; }

/* ─── Buttons ────────────────────────────────── */
.btn { border-radius: var(--radius-sm); font-weight: 500; font-size: 0.85rem; }
.btn-primary-gradient {
    background: var(--gradient-primary);
    border: none;
    color: #fff;
    padding: 10px 20px;
}
.btn-primary-gradient:hover { opacity: 0.9; color: #fff; }

/* ─── Forms ────────────────────────────────── */
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-size: 0.875rem;
    padding: 10px 14px;
}
.form-control:focus, .form-select:focus {
    border-color: var(--sidebar-accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* ─── Progress ────────────────────────────────── */
.progress { height: 6px; border-radius: 3px; background: #f1f5f9; }
.progress-bar { background: var(--gradient-primary); border-radius: 3px; }

/* ─── Modal ────────────────────────────────── */
.modal-content { border-radius: var(--radius); border: none; box-shadow: var(--shadow-lg); }
.modal-header { border-bottom: 1px solid var(--border); padding: 20px 24px; }
.modal-title { font-weight: 700; font-size: 1.1rem; }
.modal-body { padding: 24px; }
.modal-footer { border-top: 1px solid var(--border); padding: 16px 24px; }

/* ─── DataTables override ────────────────────── */
.dataTables_wrapper .dataTables_filter input {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    padding: 6px 12px;
    font-size: 0.85rem;
}
.dataTables_wrapper .dataTables_length select {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.dataTables_info, .dataTables_length, .dataTables_filter {
    font-size: 0.82rem;
    color: var(--text-secondary);
}
.page-link { border-radius: 6px !important; font-size: 0.82rem; }

/* ─── Mobile ────────────────────────────────── */
.sidebar-toggle {
    display: none;
    background: var(--sidebar-bg);
    border: none;
    color: #fff;
    width: 40px; height: 40px;
    border-radius: var(--radius-sm);
    font-size: 1.2rem;
    cursor: pointer;
}

@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .sidebar-toggle { display: flex; align-items: center; justify-content: center; }
    .content-area { padding: 20px 16px; }
    .topbar { padding: 12px 16px; }
}

/* ─── Login page ────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    background: var(--sidebar-bg);
    overflow: hidden;
}

.login-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #312e81 100%);
    position: relative;
}

.login-left::before {
    content: '';
    position: absolute;
    width: 500px; height: 500px;
    background: radial-gradient(circle, rgba(99,102,241,0.15) 0%, transparent 70%);
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
}

.login-left .brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    position: relative;
    z-index: 1;
}

.login-left .brand .logo-big {
    width: 80px; height: 80px;
    border-radius: 20px;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(99,102,241,0.3);
}

.login-left .brand .logo-big svg { width: 44px; height: 44px; }

.login-left .brand h1 {
    color: #fff;
    font-size: 2rem;
    font-weight: 800;
    margin: 0;
}

.login-left .brand p {
    color: #94a3b8;
    font-size: 0.95rem;
    text-align: center;
    max-width: 300px;
}

.login-right {
    width: 480px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 60px;
    background: var(--card-bg);
}

.login-right h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.login-right p.subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 32px;
}

.login-right .form-label {
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.login-right .input-icon {
    position: relative;
}

.login-right .input-icon i {
    position: absolute;
    left: 14px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.login-right .input-icon input {
    padding-left: 42px;
}

.login-btn {
    width: 100%;
    padding: 12px;
    background: var(--gradient-primary);
    border: none;
    border-radius: var(--radius-sm);
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.15s;
}

.login-btn:hover { opacity: 0.9; transform: translateY(-1px); }

@media (max-width: 768px) {
    .login-left { display: none; }
    .login-right { width: 100%; padding: 40px 24px; }
}

/* ─── Empty state ────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
.empty-state i { font-size: 3rem; margin-bottom: 12px; display: block; }

/* ─── Processing monitor ────────────────────────── */
.proc-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}
.proc-row:last-child { border-bottom: none; }

.proc-row-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-primary);
    white-space: nowrap;
    min-width: 100px;
}
.proc-row-header i { font-size: 1rem; color: var(--text-secondary); }

.proc-row-badges {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.proc-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    color: var(--text-muted);
    gap: 6px;
}
.proc-empty i { font-size: 1.8rem; }

.proc-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 6px;
    white-space: nowrap;
    flex-shrink: 0;
}
.proc-pending { background: #fffbeb; color: #d97706; }
.proc-inprogress { background: #eff6ff; color: #2563eb; }
.proc-done { background: #ecfdf5; color: #059669; }
.proc-output { background: #f5f3ff; color: #7c3aed; }
.proc-stuck { background: #fef2f2; color: #dc2626; }

.proc-files {
    font-size: 0.82rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.proc-files code {
    font-size: 0.78rem;
    background: #f8fafc;
    padding: 2px 6px;
    border-radius: 4px;
}
.proc-active code { border-left: 3px solid #3b82f6; }
.proc-stuck code { border-left: 3px solid #ef4444; background: #fef2f2; }

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.spin { animation: spin 1s linear infinite; display: inline-block; }

/* ─── Storage file manager ────────────────────── */
.storage-type { margin-bottom: 20px; }
.storage-type:last-child { margin-bottom: 0; }
.storage-type-header {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--border);
}

.storage-folder { margin-bottom: 12px; }
.storage-folder-header { margin-bottom: 6px; }

.storage-file {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #f8fafc;
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
    gap: 8px;
}
.storage-file:hover { background: #f1f5f9; }

.storage-file-info {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}
.storage-file-info code {
    font-size: 0.78rem;
    word-break: break-all;
}

.file-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
}
.file-stuck {
    font-size: 0.72rem;
    color: var(--danger);
    font-weight: 600;
    white-space: nowrap;
}

.storage-file-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.btn-file-action {
    width: 28px; height: 28px;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.78rem;
    color: var(--text-secondary);
    transition: all 0.15s;
    padding: 0;
}
.btn-file-action:hover { background: #f1f5f9; color: var(--text-primary); }
.btn-retry:hover { color: var(--info); border-color: var(--info); }
.btn-error:hover { color: var(--warning); border-color: var(--warning); }
.btn-delete:hover { color: var(--danger); border-color: var(--danger); }
