/**
 * StyAI - Modern SaaS Admin Dashboard Stylesheet
 * Supports Dark & Light Modes with CSS custom properties
 */

:root {
    --bg-body: #0B0B0D;              /* Deep luxury black */
    --bg-surface: #141416;           /* Secondary dark background */
    --bg-surface-elevated: #1B1B1F;  /* Card surface */
    --bg-surface-hover: #26262B;
    --border-color: #303034;         /* StyMetics border */
    --border-subtle: #202024;
    
    --text-primary: #FFFFFF;         /* Crisp white */
    --text-secondary: #B8B3B0;       /* Neutral gray-beige */
    --text-muted: #7E7976;
    
    --brand-accent: #630D16;         /* Primary brand accent - Burgundy */
    --brand-accent-hover: #6B1922;   /* Burgundy variant */
    --brand-secondary: #EDE4DA;      /* Secondary brand color - warm beige */
    
    --accent-primary: #630D16;
    --accent-primary-hover: #6B1922;
    --accent-primary-subtle: rgba(99, 13, 22, 0.28);
    
    --accent-success: #10b981;
    --accent-success-subtle: rgba(16, 185, 129, 0.15);
    
    --accent-warning: #f59e0b;
    --accent-warning-subtle: rgba(245, 158, 11, 0.15);
    
    --accent-danger: #ef4444;
    --accent-danger-subtle: rgba(239, 68, 68, 0.15);
    
    --accent-info: #38bdf8;
    --accent-info-subtle: rgba(56, 189, 248, 0.15);

    --sidebar-width: 270px;
    --navbar-height: 64px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.5);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg-body: #0B0B0D;
    --bg-surface: #141416;
    --bg-surface-elevated: #1B1B1F;
    --bg-surface-hover: #26262B;
    --border-color: #303034;
    --border-subtle: #202024;
    
    --text-primary: #FFFFFF;
    --text-secondary: #B8B3B0;
    --text-muted: #7E7976;
    
    --brand-accent: #630D16;
    --brand-accent-hover: #6B1922;
    --brand-secondary: #EDE4DA;
    
    --accent-primary: #630D16;
    --accent-primary-hover: #6B1922;
    --accent-primary-subtle: rgba(99, 13, 22, 0.28);
    
    --shadow-card: 0 4px 15px rgba(0, 0, 0, 0.4);
}
    
    --accent-warning: #d97706;
    --accent-warning-subtle: rgba(217, 119, 6, 0.1);
    
    --accent-danger: #dc2626;
    --accent-danger-subtle: rgba(220, 38, 38, 0.1);
    
    --accent-info: #0891b2;
    --accent-info-subtle: rgba(8, 145, 178, 0.1);
    
    --shadow-card: 0 4px 15px rgba(0, 0, 0, 0.05);
}

/* Base styling */
body {
    background-color: var(--bg-body);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 0.925rem;
    line-height: 1.5;
    overflow-x: hidden;
    transition: background-color 0.25s ease, color 0.25s ease;
}

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

/* App Layout */
.app-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* Sidebar */
.app-sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}

.sidebar-header {
    height: var(--navbar-height);
    padding: 0 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
}

.brand-badge {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--text-primary);
}

.brand-logo-icon {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, #630D16, #6B1922);
    border: 1px solid rgba(237, 228, 218, 0.25);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #EDE4DA;
    font-weight: 800;
    font-size: 1.1rem;
    box-shadow: 0 4px 12px rgba(99, 13, 22, 0.45);
}

.sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0.75rem;
}

.sidebar-nav-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 0.75rem 0.75rem 0.35rem 0.75rem;
    font-weight: 700;
}

.nav-item-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.85rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 0.2rem;
    transition: var(--transition);
}

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

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

.nav-item-link.active {
    color: #fff;
    background: linear-gradient(90deg, #630D16, #6B1922);
    border-left: 3px solid #EDE4DA;
    font-weight: 600;
    box-shadow: 0 4px 14px rgba(99, 13, 22, 0.35);
}

.sidebar-footer {
    padding: 0.85rem 1rem;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-surface);
}

/* Main Content Area */
.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100vh;
}

.app-navbar {
    height: var(--navbar-height);
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.app-content {
    flex: 1;
    padding: 1.75rem 1.5rem 3rem 1.5rem;
}

/* Custom Cards */
.card-custom {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    transition: var(--transition);
    overflow: hidden;
}

.card-custom:hover {
    border-color: rgba(99, 13, 22, 0.55);
}

.card-header-custom {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header-custom h5, .card-header-custom h6 {
    margin: 0;
    font-weight: 600;
    color: var(--text-primary);
}

.card-body-custom {
    padding: 1.25rem;
}

/* Metric / Stat Card */
.stat-card {
    padding: 1.25rem;
    border-radius: var(--radius-md);
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 1.2rem;
    position: relative;
    overflow: hidden;
}

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

.stat-icon.primary { background-color: var(--accent-primary-subtle); color: var(--accent-primary); }
.stat-icon.success { background-color: var(--accent-success-subtle); color: var(--accent-success); }
.stat-icon.warning { background-color: var(--accent-warning-subtle); color: var(--accent-warning); }
.stat-icon.danger { background-color: var(--accent-danger-subtle); color: var(--accent-danger); }
.stat-icon.info { background-color: var(--accent-info-subtle); color: var(--accent-info); }

.stat-title {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

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

/* Status Badges */
.badge-status {
    padding: 0.35em 0.65em;
    font-weight: 600;
    font-size: 0.75rem;
    border-radius: 50px;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.badge-status.connected {
    background-color: var(--accent-success-subtle);
    color: var(--accent-success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-status.disconnected {
    background-color: var(--accent-warning-subtle);
    color: var(--accent-warning);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-status.error {
    background-color: var(--accent-danger-subtle);
    color: var(--accent-danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.pulse-dot.connected {
    background-color: var(--accent-success);
    box-shadow: 0 0 8px var(--accent-success);
}
.pulse-dot.disconnected {
    background-color: var(--accent-warning);
}
.pulse-dot.error {
    background-color: var(--accent-danger);
}

/* Tables */
.table-custom {
    color: var(--text-primary);
    margin-bottom: 0;
}
.table-custom thead th {
    background-color: var(--bg-surface-elevated);
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.75rem 1rem;
}
.table-custom tbody td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}
.table-custom tbody tr:hover td {
    background-color: var(--bg-surface-elevated);
}

/* Forms & Inputs */
.form-control-custom, .form-select-custom {
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.85rem;
    font-size: 0.9rem;
    transition: var(--transition);
}

.form-control-custom:focus, .form-select-custom:focus {
    background-color: var(--bg-surface);
    border-color: var(--accent-primary);
    color: var(--text-primary);
    box-shadow: 0 0 0 3px var(--accent-primary-subtle);
    outline: none;
}

.form-label-custom {
    font-weight: 500;
    font-size: 0.85rem;
    margin-bottom: 0.4rem;
    color: var(--text-secondary);
}

/* Buttons */
.btn-primary-custom {
    background: linear-gradient(135deg, #630D16, #6B1922);
    border: 1px solid rgba(237, 228, 218, 0.2);
    color: #FFFFFF;
    font-weight: 500;
    padding: 0.55rem 1.15rem;
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 12px rgba(99, 13, 22, 0.35);
    transition: var(--transition);
}
.btn-primary-custom:hover {
    background: linear-gradient(135deg, #6B1922, #801E29);
    color: #EDE4DA;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(99, 13, 22, 0.5);
}

.btn-secondary-custom {
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-weight: 500;
    padding: 0.55rem 1rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.btn-secondary-custom:hover {
    background-color: var(--bg-surface-hover);
    color: var(--text-primary);
    border-color: var(--border-color);
}

/* Testing Playground Chat Styles */
.chat-container {
    height: 480px;
    display: flex;
    flex-direction: column;
    border-radius: var(--radius-md);
    background-color: var(--bg-body);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.chat-history {
    flex: 1;
    padding: 1.25rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-bubble {
    max-width: 80%;
    padding: 0.85rem 1.15rem;
    border-radius: var(--radius-md);
    position: relative;
    font-size: 0.925rem;
    line-height: 1.5;
}

.chat-bubble.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #630D16, #6B1922);
    border: 1px solid rgba(237, 228, 218, 0.2);
    color: #FFFFFF;
    border-bottom-right-radius: 2px;
}

.chat-bubble.assistant {
    align-self: flex-start;
    background-color: var(--bg-surface-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 2px;
}

.chat-meta {
    font-size: 0.725rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Mobile responsive drawer */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 1035;
}

@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
    }
    .app-sidebar.show {
        transform: translateX(0);
    }
    .sidebar-backdrop.show {
        display: block;
    }
    .app-main {
        margin-left: 0;
    }
}
