/* ===========================
   ITEconic MailPro - Main CSS
   Brand: #fc8307 (orange) / #c80d0f (red)
   =========================== */

:root {
    --bg-primary: #0d0f14;
    --bg-secondary: #13161e;
    --bg-card: #181c26;
    --bg-hover: #1e2230;
    --border: #242837;
    --border-light: #2d3347;
    --accent: #fc8307;
    --accent-glow: rgba(252,131,7,0.18);
    --accent-2: #c80d0f;
    --accent-3: #f75f4f;
    --accent-green: #34d399;
    --accent-yellow: #fbbf24;
    --text-primary: #e8eaf2;
    --text-secondary: #8891aa;
    --text-muted: #555d75;
    --sidebar-width: 240px;
    --topbar-height: 60px;
    --radius: 10px;
    --radius-sm: 7px;
    --shadow: 0 4px 24px rgba(0,0,0,0.4);
    --shadow-glow: 0 0 24px rgba(252,131,7,0.2);
    --font-display: 'Syne', sans-serif;
    --font-body: 'DM Sans', sans-serif;
    --transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg-primary: #f4f5f9;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-hover: #fff5ee;
    --border: #e8e8ee;
    --border-light: #d8d8e8;
    --text-primary: #1a1f36;
    --text-secondary: #5a6483;
    --text-muted: #9aa0ba;
    --shadow: 0 4px 24px rgba(0,0,0,0.06);
    --shadow-glow: 0 0 24px rgba(252,131,7,0.12);
    --accent-glow: rgba(252,131,7,0.1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
/* Prevent <script> tags from becoming visible flex items */
script { display: none !important; }
body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: var(--transition);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.sidebar-brand {
    padding: 16px 18px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.brand-logo-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
    text-decoration: none;
}

.brand-logo-img {
    height: 28px;
    width: auto;
    display: block;
    /* invert for dark mode so logo stays visible */
    filter: brightness(1.1);
}

[data-theme="dark"] .brand-logo-img {
    filter: brightness(0) invert(1) sepia(1) saturate(3) hue-rotate(340deg) brightness(1.1);
}

.brand-badge {
    font-size: 9px;
    font-weight: 700;
    background: linear-gradient(135deg, #fc8307, #c80d0f);
    color: #fff;
    padding: 2px 8px;
    border-radius: 20px;
    letter-spacing: 0.8px;
    text-transform: uppercase;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-section-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    padding: 14px 10px 6px;
    font-family: var(--font-display);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    position: relative;
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.nav-link.active {
    color: var(--accent);
    background: var(--accent-glow);
}

.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}

.nav-link i { font-size: 16px; flex-shrink: 0; }

.nav-badge {
    margin-left: auto;
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
}

.nav-badge-new {
    margin-left: auto;
    background: var(--accent-3);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.sidebar-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 14px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.user-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 11px;
    color: var(--text-muted);
}

.logout-btn {
    margin-left: auto;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 18px;
    padding: 6px;
    border-radius: 8px;
    transition: var(--transition);
    flex-shrink: 0;
}
.logout-btn:hover { color: var(--accent-3); background: rgba(247,95,79,0.1); }

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}

/* ===== TOPBAR ===== */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-left { display: flex; align-items: center; gap: 14px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.sidebar-toggle {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.sidebar-toggle:hover { color: var(--accent); border-color: var(--accent); }

.page-breadcrumb {
    font-size: 14px;
    color: var(--text-secondary);
}
.page-breadcrumb .bc-current {
    color: var(--text-primary);
    font-weight: 600;
    font-family: var(--font-display);
}

.topbar-actions { display: flex; align-items: center; gap: 14px; }

.status-indicator {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: 20px;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-muted);
}

.status-dot.active {
    background: var(--accent-green);
    box-shadow: 0 0 8px var(--accent-green);
    animation: pulse 1.5s infinite;
}

.notif-btn {
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: var(--transition);
}
.notif-btn:hover { color: var(--accent); }

.notif-count {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--accent-3);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.theme-toggle {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.theme-toggle:hover { color: var(--accent-yellow); border-color: var(--accent-yellow); }

/* ===== PAGE CONTENT ===== */
.page-content {
    flex: 1;
    padding: 24px 28px;
    max-width: 1400px;
    width: 100%;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-title {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.page-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ===== CARDS ===== */
.mp-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    transition: var(--transition);
}

.mp-card:hover { border-color: var(--border-light); }

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

.mp-card-title {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.mp-card-title i { color: var(--accent); }

/* ===== STAT CARDS ===== */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent);
    border-radius: var(--radius) var(--radius) 0 0;
}

.stat-card.green::before { background: var(--accent-green); }
.stat-card.purple::before { background: var(--accent-2); }
.stat-card.red::before { background: var(--accent-3); }
.stat-card.yellow::before { background: var(--accent-yellow); }

.stat-card:hover {
    border-color: var(--border-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.stat-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.stat-value {
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 8px;
}

.stat-change {
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-change.up { color: var(--accent-green); }
.stat-change.down { color: var(--accent-3); }

.stat-icon {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 42px;
    opacity: 0.07;
    color: var(--accent);
}

/* ===== BUTTONS ===== */
.btn-mp {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    transition: var(--transition);
    border: none;
    text-decoration: none;
}

.btn-mp-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 14px rgba(79,142,247,0.3);
}
.btn-mp-primary:hover { background: #3a7de8; transform: translateY(-1px); color: #fff; }

.btn-mp-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-mp-outline:hover { color: var(--accent); border-color: var(--accent); }

.btn-mp-success {
    background: var(--accent-green);
    color: #000;
}
.btn-mp-success:hover { opacity: 0.9; }

.btn-mp-danger {
    background: var(--accent-3);
    color: #fff;
}
.btn-mp-danger:hover { opacity: 0.9; }

.btn-mp-sm { padding: 6px 14px; font-size: 12px; }
.btn-mp-lg { padding: 13px 28px; font-size: 15px; }

/* ===== TABLES ===== */
.mp-table-wrap { overflow-x: auto; border-radius: var(--radius); }

.mp-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.mp-table thead tr {
    background: var(--bg-hover);
    border-bottom: 1px solid var(--border);
}

.mp-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--text-muted);
    white-space: nowrap;
}

.mp-table td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    vertical-align: middle;
}

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

.mp-table tbody tr {
    transition: var(--transition);
}

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

/* ===== FORMS ===== */
.mp-form-group { margin-bottom: 18px; }

.mp-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 7px;
}

.mp-input,
.mp-select,
.mp-textarea {
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 10px 14px;
    font-size: 14px;
    font-family: var(--font-body);
    transition: var(--transition);
    outline: none;
}

.mp-input:focus,
.mp-select:focus,
.mp-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.mp-input::placeholder { color: var(--text-muted); }
.mp-textarea { min-height: 120px; resize: vertical; }
.mp-select option { background: var(--bg-secondary); }

/* ===== BADGES ===== */
.badge-mp {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.badge-active { background: rgba(52,211,153,0.15); color: var(--accent-green); }
.badge-inactive { background: rgba(255,255,255,0.05); color: var(--text-muted); }
.badge-running { background: rgba(79,142,247,0.15); color: var(--accent); }
.badge-paused { background: rgba(251,191,36,0.15); color: var(--accent-yellow); }
.badge-failed { background: rgba(247,95,79,0.15); color: var(--accent-3); }
.badge-completed { background: rgba(52,211,153,0.15); color: var(--accent-green); }
.badge-scheduled { background: rgba(124,92,246,0.15); color: var(--accent-2); }

/* ===== PROGRESS ===== */
.mp-progress {
    height: 6px;
    background: var(--border);
    border-radius: 10px;
    overflow: hidden;
}

.mp-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    border-radius: 10px;
    transition: width 0.6s ease;
}

/* ===== ALERTS / TOASTS ===== */
.alert-toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 500;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.alert-toast-success { background: rgba(52,211,153,0.1); border: 1px solid rgba(52,211,153,0.3); color: var(--accent-green); }
.alert-toast-error { background: rgba(247,95,79,0.1); border: 1px solid rgba(247,95,79,0.3); color: var(--accent-3); }

.alert-toast button {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    margin-left: auto;
    opacity: 0.7;
    font-size: 16px;
}

/* ===== UPLOAD ZONE ===== */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-primary);
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.upload-icon { font-size: 40px; color: var(--accent); margin-bottom: 12px; }
.upload-title { font-size: 16px; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
.upload-subtitle { font-size: 13px; color: var(--text-muted); }

/* ===== STEPS WIZARD ===== */
.wizard-steps {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 30px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 24px;
    overflow-x: auto;
}

.wizard-step {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    position: relative;
    min-width: 140px;
}

.wizard-step:not(:last-child)::after {
    content: '';
    flex: 1;
    height: 2px;
    background: var(--border);
    margin: 0 10px;
}

.wizard-step.done:not(:last-child)::after { background: var(--accent); }

.step-num {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: var(--transition);
}

.wizard-step.active .step-num {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.wizard-step.done .step-num {
    background: var(--accent-green);
    border-color: var(--accent-green);
    color: #fff;
}

.step-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}

.wizard-step.active .step-label { color: var(--accent); }
.wizard-step.done .step-label { color: var(--accent-green); }

/* ===== MODAL ===== */
.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.modal-header {
    border-bottom: 1px solid var(--border);
    padding: 18px 24px;
}

.modal-title {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--text-primary);
}

.modal-body { padding: 24px; }

.modal-footer {
    border-top: 1px solid var(--border);
    padding: 16px 24px;
}

.btn-close { filter: invert(0.5); }

/* ===== CHARTS ===== */
.chart-container { position: relative; }

/* ===== DONUT CHART LEGEND ===== */
.chart-legend {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-label { color: var(--text-secondary); flex: 1; }
.legend-val { font-weight: 700; color: var(--text-primary); }

/* ===== REAL-TIME LOG ===== */
.log-stream {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    max-height: 200px;
    overflow-y: auto;
    color: var(--accent-green);
    line-height: 1.7;
}

/* ===== SIDEBAR COLLAPSED ===== */
.sidebar.collapsed {
    width: 68px;
}

.sidebar.collapsed .brand-name,
.sidebar.collapsed .brand-badge,
.sidebar.collapsed .nav-link span,
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .nav-badge-new,
.sidebar.collapsed .user-details,
.sidebar.collapsed .logout-btn {
    display: none;
}

.sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 10px;
}

.sidebar.collapsed .sidebar-footer {
    justify-content: center;
}

.sidebar.collapsed ~ .main-content {
    margin-left: 68px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
}

/* ===== MISC ===== */
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.fs-7 { font-size: 12px; }

.text-accent { color: var(--accent); }
.text-green { color: var(--accent-green); }
.text-red { color: var(--accent-3); }
.text-yellow { color: var(--accent-yellow); }
.text-muted-mp { color: var(--text-muted); }

.border-mp { border-color: var(--border) !important; }
.bg-card { background: var(--bg-card); }

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

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

/* AI section */
.ai-bubble {
    background: linear-gradient(135deg, rgba(79,142,247,0.08), rgba(124,92,246,0.08));
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 16px;
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-secondary);
}

.ai-bubble.user {
    background: var(--accent-glow);
    border-color: rgba(79,142,247,0.3);
    color: var(--text-primary);
    text-align: right;
}
