/* MotherBase+ Cloud Web App Styles */

:root {
    --primary: #00d4ff;
    --primary-dark: #0099cc;
    --secondary: #8b5cf6;
    --bg-dark: #0a0a0f;
    --bg-panel: #13131a;
    --bg-card: #1a1a25;
    --border: #2a2a3a;
    --text: #f0f0f5;
    --text-muted: #8b8b9a;
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --radius: 12px;
    --shadow: 0 4px 20px rgba(0,0,0,0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* Screen Management */
.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: block;
}

/* Login Screen */
#login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0a0a0f 0%, #13131a 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 40px;
}

.logo {
    text-align: center;
    margin-bottom: 40px;
}

.logo-icon {
    font-size: 64px;
    display: block;
    margin-bottom: 16px;
}

.logo h1 {
    font-size: 32px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 14px;
}

.login-form {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
}

.input-group {
    margin-bottom: 24px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--text-muted);
}

.input, .select, .textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    transition: border-color 0.2s;
}

.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.hint {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn:hover {
    background: var(--border);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    color: #000;
    font-weight: 600;
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-small {
    padding: 8px 16px;
    font-size: 12px;
}

/* Checkbox */
.checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-muted);
    cursor: pointer;
}

.checkbox input {
    cursor: pointer;
}

.login-options {
    margin-top: 16px;
}

.login-footer {
    margin-top: 24px;
    text-align: center;
    font-size: 13px;
}

.login-footer a {
    color: var(--primary);
    text-decoration: none;
}

.login-footer a:hover {
    text-decoration: underline;
}

.divider {
    margin: 0 12px;
    color: var(--border);
}

/* Main App Layout */
#main-screen {
    display: none;
    flex-direction: row;
    min-height: 100vh;
}

#main-screen.active {
    display: flex;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-header .logo-icon {
    font-size: 32px;
}

.sidebar-header .logo-text {
    font-size: 18px;
    font-weight: 600;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    color: var(--text-muted);
    text-decoration: none;
    margin-bottom: 4px;
    transition: all 0.2s;
}

.nav-item:hover {
    background: var(--bg-card);
    color: var(--text);
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(0,212,255,0.1), rgba(139,92,246,0.1));
    color: var(--primary);
    border: 1px solid rgba(0,212,255,0.2);
}

.nav-icon {
    font-size: 20px;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.tenant-info {
    margin-bottom: 12px;
}

.tenant-name {
    font-weight: 500;
    font-size: 14px;
}

.tenant-tier {
    font-size: 12px;
    color: var(--text-muted);
}

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.page-header h2 {
    font-size: 28px;
    font-weight: 600;
}

.header-actions {
    display: flex;
    gap: 12px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    font-size: 32px;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(0,212,255,0.1), rgba(139,92,246,0.1));
    border-radius: 12px;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

.panel h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Lists */
.session-list, .rule-list, .knowledge-grid, .rules-list {
    min-height: 200px;
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

/* Session Item */
.session-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: var(--bg-panel);
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.session-item:hover {
    background: var(--border);
}

.session-id {
    font-family: monospace;
    font-size: 13px;
    color: var(--primary);
}

.session-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.session-rating {
    color: var(--warning);
}

/* Knowledge Card */
.knowledge-card {
    background: var(--bg-panel);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    border-left: 4px solid var(--primary);
}

.knowledge-card.pitfall {
    border-left-color: var(--error);
}

.knowledge-card.pattern {
    border-left-color: var(--success);
}

.knowledge-card.insight {
    border-left-color: var(--secondary);
}

.knowledge-type {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.knowledge-type.pitfall {
    background: rgba(239,68,68,0.1);
    color: var(--error);
}

.knowledge-type.pattern {
    background: rgba(34,197,94,0.1);
    color: var(--success);
}

.knowledge-type.insight {
    background: rgba(139,92,246,0.1);
    color: var(--secondary);
}

/* Rule Item */
.rule-item {
    display: flex;
    align-items: center;
    padding: 16px;
    background: var(--bg-panel);
    border-radius: 8px;
    margin-bottom: 8px;
}

.rule-number {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 12px;
    font-weight: 700;
    color: #000;
    margin-right: 16px;
}

.rule-info {
    flex: 1;
}

.rule-title {
    font-weight: 500;
    margin-bottom: 4px;
}

.rule-desc {
    font-size: 13px;
    color: var(--text-muted);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 18px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
}

.modal-close:hover {
    color: var(--text);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--text-muted);
}

/* Toast */
#toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 2000;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    animation: slideIn 0.3s ease;
}

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid var(--error);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -260px;
        height: 100vh;
        z-index: 100;
        transition: left 0.3s;
    }
    
    .sidebar.open {
        left: 0;
    }
    
    .main-content {
        padding: 20px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
}
