/* M-Pesa Orchestrator - Modern Dark Theme */

:root {
    /* Color palette - M-Pesa inspired greens with dark theme */
    --color-primary: #00a651;
    --color-primary-dark: #008c44;
    --color-primary-light: #00d468;
    --color-accent: #ffcc00;
    --color-accent-dark: #e6b800;
    
    /* Dark theme backgrounds */
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-elevated: #30363d;
    
    /* Text colors */
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    
    /* Semantic colors */
    --color-success: #238636;
    --color-success-bg: rgba(35, 134, 54, 0.15);
    --color-warning: #d29922;
    --color-warning-bg: rgba(210, 153, 34, 0.15);
    --color-error: #da3633;
    --color-error-bg: rgba(218, 54, 51, 0.15);
    --color-info: #58a6ff;
    --color-info-bg: rgba(88, 166, 255, 0.15);
    
    /* Borders */
    --border-color: #30363d;
    --border-color-light: #21262d;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    
    /* Fonts */
    --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Monaco', monospace;
    
    /* Sizing */
    --sidebar-width: 260px;
    --header-height: 64px;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--color-primary-light);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--color-accent);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 0.5em;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }

p { margin-bottom: 1rem; }

code, pre {
    font-family: var(--font-mono);
    font-size: 0.9em;
}

code {
    background: var(--bg-tertiary);
    padding: 0.2em 0.4em;
    border-radius: var(--radius-sm);
}

pre {
    background: var(--bg-tertiary);
    padding: 1rem;
    border-radius: var(--radius-md);
    overflow-x: auto;
    border: 1px solid var(--border-color);
}

/* Layout */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2rem;
    color: white;
}

.sidebar-logo-text {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.sidebar-logo-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.nav-section {
    padding: 0 1rem;
    margin-bottom: 1.5rem;
}

.nav-section-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    padding: 0 0.75rem;
    margin-bottom: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0.75rem;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    transition: all 0.2s;
    margin-bottom: 2px;
}

.nav-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(0, 166, 81, 0.15);
    color: var(--color-primary-light);
}

.nav-item-icon {
    width: 20px;
    height: 20px;
    opacity: 0.8;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: var(--bg-tertiary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--color-primary-light);
}

.user-info {
    flex: 1;
}

.user-name {
    font-size: 0.9rem;
    font-weight: 500;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.page-header {
    padding: 1.5rem 2rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 600;
}

.page-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.page-actions {
    display: flex;
    gap: 0.75rem;
}

.page-content {
    padding: 2rem;
}

/* Cards */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.form-label-hint {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(0, 166, 81, 0.2);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-input.is-invalid,
.form-select.is-invalid {
    border-color: var(--color-error);
}

.form-error {
    font-size: 0.8rem;
    color: var(--color-error);
    margin-top: 0.25rem;
}

.form-help {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 500;
    font-family: inherit;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--color-primary-dark);
    color: white;
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.btn-danger {
    background: var(--color-error);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #c52d2a;
    color: white;
}

.btn-success {
    background: var(--color-success);
    color: white;
}

.btn-sm {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1rem;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    padding: 0.5rem;
}

/* Tables */
.table-wrapper {
    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-color);
}

.table th {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--bg-tertiary);
}

.table tbody tr:hover {
    background: var(--bg-tertiary);
}

.table td {
    font-size: 0.9rem;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 999px;
}

.badge-success {
    background: var(--color-success-bg);
    color: #3fb950;
}

.badge-warning {
    background: var(--color-warning-bg);
    color: var(--color-warning);
}

.badge-error {
    background: var(--color-error-bg);
    color: #f85149;
}

.badge-info {
    background: var(--color-info-bg);
    color: var(--color-info);
}

.badge-muted {
    background: var(--bg-tertiary);
    color: var(--text-muted);
}

/* Alerts */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.alert-success {
    background: var(--color-success-bg);
    border: 1px solid rgba(35, 134, 54, 0.3);
    color: #3fb950;
}

.alert-warning {
    background: var(--color-warning-bg);
    border: 1px solid rgba(210, 153, 34, 0.3);
    color: var(--color-warning);
}

.alert-error {
    background: var(--color-error-bg);
    border: 1px solid rgba(218, 54, 51, 0.3);
    color: #f85149;
}

.alert-info {
    background: var(--color-info-bg);
    border: 1px solid rgba(88, 166, 255, 0.3);
    color: var(--color-info);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    margin: 0.25rem 0;
    color: var(--text-primary);
}

.stat-change {
    font-size: 0.85rem;
}

.stat-change.positive {
    color: var(--color-success);
}

.stat-change.negative {
    color: var(--color-error);
}

/* Login Page */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-primary) 0%, #0a2818 100%);
    padding: 2rem;
}

.login-box {
    width: 100%;
    max-width: 420px;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo {
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.8rem;
    color: white;
    margin: 0 auto 1rem;
    box-shadow: 0 8px 32px rgba(0, 166, 81, 0.3);
}

.login-title {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.login-subtitle {
    color: var(--text-muted);
}

.login-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
}

/* Logs */
.log-entry {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color-light);
    display: grid;
    grid-template-columns: 140px 80px 100px 1fr;
    gap: 1rem;
    align-items: start;
}

.log-entry:hover {
    background: var(--bg-tertiary);
}

.log-time {
    color: var(--text-muted);
}

.log-level {
    font-weight: 600;
}

.log-level.DEBUG { color: var(--text-muted); }
.log-level.INFO { color: var(--color-info); }
.log-level.WARNING { color: var(--color-warning); }
.log-level.ERROR { color: var(--color-error); }
.log-level.CRITICAL { color: #ff6b6b; }

.log-module {
    color: var(--color-primary-light);
}

.log-message {
    color: var(--text-primary);
    word-break: break-word;
}

/* JSON Viewer */
.json-viewer {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
}

.json-key { color: var(--color-info); }
.json-string { color: var(--color-success); }
.json-number { color: var(--color-warning); }
.json-boolean { color: #ff79c6; }
.json-null { color: var(--text-muted); }

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

/* Loading */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.tab {
    padding: 0.75rem 1.25rem;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    cursor: pointer;
    transition: all 0.2s;
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    color: var(--color-primary-light);
    border-bottom-color: var(--color-primary);
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 2rem;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Utility */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--color-success); }
.text-error { color: var(--color-error); }
.text-warning { color: var(--color-warning); }
.text-mono { font-family: var(--font-mono); }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.flex { display: flex; }
.flex-between { justify-content: space-between; }
.flex-center { justify-content: center; }
.items-center { align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

.hidden { display: none !important; }

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .page-header {
        padding: 1rem;
    }
    
    .page-content {
        padding: 1rem;
    }
    
    .log-entry {
        grid-template-columns: 1fr;
        gap: 0.25rem;
    }
}

