/* CDMS Panel — Corporate Minimalist */
:root {
    --primary: #4a4e69;
    --primary-dark: #3a3d54;
    --primary-light: #5c6080;
    --accent: #e76f51;
    --accent-hover: #d65d3f;
    --secondary: #6d597a;
    --tertiary: #723d46;
    --deep: #502f4c;
    --teal: #005f73;
    --muted: #9a8c98;
    --lavender: #70587c;
    
    --bg: #f4f3f1;
    --bg-card: #ffffff;
    --bg-sidebar: #2d2f3e;
    --bg-sidebar-hover: #383a4d;
    
    --text: #333340;
    --text-light: #6b6b7b;
    --text-muted: #9a9aaa;
    --text-sidebar: #c8c8d4;
    --text-sidebar-active: #ffffff;
    
    --border: #e2e0de;
    --border-light: #eeedeb;
    
    --radius: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.1);
    
    --sidebar-width: 240px;
    --sidebar-collapsed-width: 64px;
    --topbar-height: 60px;
    
    --transition: 0.2s ease;
}

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

body {
    font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
    display: flex;
    min-height: 100vh;
}

a { color: var(--teal); text-decoration: none; }
a:hover { color: var(--primary); }

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

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 1px;
}

.logo i { font-size: 22px; color: var(--accent); }

.sidebar-toggle {
    background: none; border: none;
    color: var(--text-sidebar);
    cursor: pointer; font-size: 16px;
    padding: 4px;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius);
    color: var(--text-sidebar);
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition);
    margin-bottom: 2px;
}

.nav-item:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-sidebar-active);
}

.nav-item.active {
    background: var(--primary);
    color: var(--text-sidebar-active);
}

.nav-item i { width: 20px; text-align: center; font-size: 15px; }

.nav-divider {
    height: 1px;
    background: rgba(255,255,255,0.06);
    margin: 12px 14px;
}

.sidebar-footer {
    padding: 12px 8px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    color: var(--text-sidebar);
    font-size: 13px;
}

.user-info i { font-size: 20px; }

.logout-btn { color: var(--tertiary) !important; }
.logout-btn:hover { background: rgba(114,61,70,0.2) !important; }

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left var(--transition);
    min-height: 100vh;
}

.top-bar {
    height: var(--topbar-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.page-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    flex: 1;
}

.top-bar-right { display: flex; gap: 8px; }

.mobile-toggle { display: none; }

.content-wrapper { padding: 24px; }

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

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

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

/* Stat Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.stat-icon {
    width: 42px; height: 42px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.stat-icon.blue { background: rgba(0,95,115,0.1); color: var(--teal); }
.stat-icon.purple { background: rgba(109,89,122,0.1); color: var(--secondary); }
.stat-icon.orange { background: rgba(231,111,81,0.1); color: var(--accent); }
.stat-icon.dark { background: rgba(74,78,105,0.1); color: var(--primary); }

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

/* Table */
.table-wrapper { overflow-x: auto; }

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

th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 12px;
    border-bottom: 2px solid var(--border);
}

td {
    padding: 12px;
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
    vertical-align: middle;
}

tr:hover td { background: rgba(244,243,241,0.5); }

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.badge-active { background: rgba(0,95,115,0.1); color: var(--teal); }
.badge-paused { background: rgba(154,140,152,0.1); color: var(--muted); }
.badge-image { background: rgba(109,89,122,0.1); color: var(--secondary); }
.badge-html { background: rgba(231,111,81,0.1); color: var(--accent); }
.badge-rawhtml { background: rgba(80,47,76,0.1); color: var(--deep); }
.badge-text { background: rgba(74,78,105,0.1); color: var(--primary); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
    text-decoration: none;
    line-height: 1.4;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); color: #fff; }

.btn-accent {
    background: var(--accent);
    color: #fff;
}
.btn-accent:hover { background: var(--accent-hover); color: #fff; }

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

.btn-sm { padding: 5px 10px; font-size: 12px; }

.btn-danger {
    background: var(--tertiary);
    color: #fff;
}
.btn-danger:hover { background: #5e2f38; color: #fff; }

.btn-group { display: flex; gap: 6px; }

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

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    background: var(--bg-card);
    transition: border-color var(--transition);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(74,78,105,0.1);
}

.form-textarea { min-height: 120px; resize: vertical; }

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

.form-inline {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Alerts */
.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    border-radius: var(--radius);
    margin: 0 24px 0;
    font-size: 13px;
    position: relative;
}

.alert-success {
    background: rgba(0,95,115,0.08);
    color: var(--teal);
    border: 1px solid rgba(0,95,115,0.15);
}

.alert-error {
    background: rgba(114,61,70,0.08);
    color: var(--tertiary);
    border: 1px solid rgba(114,61,70,0.15);
}

.alert-info {
    background: rgba(74,78,105,0.08);
    color: var(--primary);
    border: 1px solid rgba(74,78,105,0.15);
}

.alert-close {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: inherit;
    opacity: 0.6;
}

.alert-close:hover { opacity: 1; }

/* Code block (for embed codes) */
.code-block {
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 16px;
    border-radius: var(--radius);
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 12px;
    line-height: 1.6;
    overflow-x: auto;
    position: relative;
}

.code-block .copy-btn {
    position: absolute;
    top: 8px; right: 8px;
    background: rgba(255,255,255,0.1);
    border: none;
    color: #cdd6f4;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
}

.code-block .copy-btn:hover { background: rgba(255,255,255,0.2); }

/* Preview */
.preview-frame {
    background: #f0f0f0;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.preview-label {
    position: absolute;
    top: 6px; left: 8px;
    font-size: 10px;
    color: var(--text-muted);
    background: rgba(255,255,255,0.8);
    padding: 2px 6px;
    border-radius: 3px;
}

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

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 13px;
    max-width: 360px;
    margin: 0 auto 20px;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    margin: 20px;
}

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

.modal-header h3 { font-size: 16px; font-weight: 600; }

.modal-close {
    background: none; border: none;
    font-size: 20px; cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
}

.modal-body { padding: 20px; }
.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    margin-bottom: 20px;
}

.tab {
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition);
    background: none;
    border-top: none; border-left: none; border-right: none;
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Weight indicator */
.weight-bar {
    display: flex;
    gap: 2px;
    align-items: center;
}

.weight-dot {
    width: 6px; height: 14px;
    border-radius: 2px;
    background: var(--border);
}

.weight-dot.filled { background: var(--accent); }

/* Toggle switch */
.toggle {
    position: relative;
    width: 40px; height: 22px;
    display: inline-block;
}

.toggle input { display: none; }

.toggle-slider {
    position: absolute; inset: 0;
    background: var(--border);
    border-radius: 22px;
    cursor: pointer;
    transition: var(--transition);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px; height: 16px;
    left: 3px; top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: var(--transition);
}

.toggle input:checked + .toggle-slider { background: var(--teal); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* Collapsed sidebar */
.sidebar-collapsed .sidebar { width: var(--sidebar-collapsed-width); }
.sidebar-collapsed .sidebar .logo span,
.sidebar-collapsed .sidebar .nav-item span,
.sidebar-collapsed .sidebar .user-info span { display: none; }
.sidebar-collapsed .main-content { margin-left: var(--sidebar-collapsed-width); }

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.mobile-open { transform: translateX(0); }
    .main-content { margin-left: 0 !important; }
    .mobile-toggle {
        display: flex;
        background: none; border: none;
        font-size: 20px; cursor: pointer;
        color: var(--text);
    }
    .content-wrapper { padding: 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .top-bar { padding: 0 16px; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
}

/* Login page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
}

.login-box {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    margin: 20px;
}

.login-box .logo {
    justify-content: center;
    margin-bottom: 32px;
    font-size: 24px;
}

.login-box .logo i { font-size: 28px; }

.login-box .form-input {
    padding: 12px 14px;
    font-size: 14px;
}

.login-box .btn {
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 14px;
}

/* Utility */
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.text-right { text-align: right; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
