/* EGZORA AI Platform Design System */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
    --bg-dark: #09090b;
    --bg-card: rgba(18, 18, 24, 0.7);
    --bg-glow: radial-gradient(circle at 50% 50%, #1e1b4b 0%, #09090b 100%);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.16);
    --text-primary: #f4f4f5;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    
    --primary: #8b5cf6; /* Violet */
    --primary-glow: rgba(139, 92, 246, 0.3);
    --secondary: #06b6d4; /* Cyan */
    --secondary-glow: rgba(6, 182, 212, 0.3);
    --accent: #ec4899; /* Pink */
    
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    
    --font-head: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg-dark: #f9fafb;
    --bg-card: rgba(255, 255, 255, 0.8);
    --bg-glow: radial-gradient(circle at 50% 50%, #f3e8ff 0%, #f9fafb 100%);
    --border-color: rgba(0, 0, 0, 0.08);
    --border-hover: rgba(0, 0, 0, 0.16);
    --text-primary: #18181b;
    --text-secondary: #52525b;
    --text-muted: #71717a;
    
    --primary: #7c3aed;
    --primary-glow: rgba(124, 58, 237, 0.1);
    --secondary: #0891b2;
    --secondary-glow: rgba(8, 145, 178, 0.1);
    --accent: #db2777;
}

[data-theme="light"] .glass {
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.06);
    background: rgba(255, 255, 255, 0.7);
}

[data-theme="light"] .glass-hover:hover {
    box-shadow: 0 8px 32px 0 rgba(124, 58, 237, 0.15);
}

[data-theme="light"] .modal-overlay, [data-theme="light"] .modal {
    background: rgba(0, 0, 0, 0.45);
}

[data-theme="light"] .modal-card, [data-theme="light"] .modal-content {
    background: #ffffff;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.12);
    border-color: rgba(0, 0, 0, 0.08);
}

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

body {
    background-color: var(--bg-dark);
    background-image: var(--bg-glow);
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

/* Glassmorphism utility */
.glass {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

.glass-hover:hover {
    border-color: var(--border-hover);
    box-shadow: 0 8px 32px 0 var(--primary-glow);
    transform: translateY(-2px);
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-head);
    font-weight: 600;
    letter-spacing: -0.02em;
}

/* Typography styles */
.gradient-text {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Auth Page layout */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100vw;
    height: 100vh;
    position: relative;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    padding: 40px;
    border-radius: var(--radius-lg);
    z-index: 10;
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-logo {
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 8px;
    font-family: var(--font-head);
}

/* Forms input element */
.form-group {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
}

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

.form-input, .form-select, .form-textarea {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
    background: rgba(255, 255, 255, 0.08);
}

.form-select option {
    background-color: #18181b;
    color: #f4f4f5;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    font-weight: 600;
    font-family: var(--font-head);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    outline: none;
    border: none;
    font-size: 0.95rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
}

.btn-primary:hover {
    box-shadow: 0 0 20px var(--primary-glow);
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--border-hover);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
}

/* Main Dashboard layout with Sidebar */
.app-layout {
    display: flex;
    width: 100%;
    max-width: 100%;
    height: 100vh;
}

.sidebar {
    width: 260px;
    height: 100%;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    padding: 24px;
    flex-shrink: 0;
}

.brand-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 40px;
    width: 100%;
}

.brand-name {
    font-size: 1.6rem;
    font-weight: 800;
    font-family: var(--font-head);
}

.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 6px;
    z-index: 1001;
    outline: none;
}
.mobile-menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background-color: var(--text-primary);
    transition: var(--transition);
    border-radius: 2px;
}
.mobile-menu-toggle.active span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
}
.mobile-menu-toggle.active span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.nav-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.nav-item:hover, .nav-item.active {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
    border-left: 3px solid var(--primary);
}

.user-profile-section {
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-email {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}

.logout-icon {
    cursor: pointer;
    color: var(--text-muted);
}

.logout-icon:hover {
    color: var(--danger);
}

/* Content Panel */
.content-area {
    flex-grow: 1;
    height: 100%;
    overflow-y: auto;
    padding: 40px;
    display: flex;
    flex-direction: column;
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

/* Tab Panels */
.tab-content {
    display: none;
    flex-direction: column;
    gap: 30px;
    animation: fadeIn 0.4s ease-out;
}

.tab-content.active {
    display: flex;
}

/* Grid systems */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}

.metric-card {
    padding: 24px;
    border-radius: var(--radius-md);
    position: relative;
    overflow: hidden;
}

.metric-title {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.metric-value {
    font-size: 1.8rem;
    font-weight: 700;
    font-family: var(--font-head);
}

.metric-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 6px;
}

/* Chat playground */
.playground-grid {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 24px;
    flex-grow: 1;
    min-height: 500px;
}

.play-sessions-list {
    max-height: 350px;
}

.agent-selector-panel {
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.chat-panel {
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 600px;
}

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

.chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-bubble {
    max-width: 80%;
    padding: 12px 18px;
    border-radius: var(--radius-md);
    line-height: 1.5;
    font-size: 0.95rem;
}

.chat-bubble.user {
    background: rgba(139, 92, 246, 0.15);
    border: 1px solid rgba(139, 92, 246, 0.3);
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

.chat-bubble.agent {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    align-self: flex-start;
    border-bottom-left-radius: 2px;
}

.chat-bubble.tool {
    background: rgba(6, 182, 212, 0.08);
    border: 1px dashed var(--secondary);
    align-self: flex-start;
    font-family: monospace;
    font-size: 0.85rem;
    max-width: 90%;
}

.chat-input-area {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
}

/* Tables styling */
.table-container {
    border-radius: var(--radius-md);
    overflow: hidden;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th {
    background: rgba(255, 255, 255, 0.02);
    padding: 16px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
    color: var(--text-primary);
}

tr:hover td {
    background: rgba(255, 255, 255, 0.01);
}

/* Badges */
.badge {
    display: inline-flex;
    padding: 4px 8px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-primary { background: rgba(139, 92, 246, 0.15); color: var(--primary); }

/* Modal overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(9, 9, 11, 0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-card {
    background: var(--bg-card);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    border-radius: var(--radius-lg);
    padding: 32px;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    position: relative;
    animation: modalFadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Spinner */
.spinner {
    border: 3px solid rgba(255,255,255,0.1);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border-left-color: var(--primary);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Backward compatible styling for .modal and .modal-content */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(9, 9, 11, 0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-card);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    border-radius: var(--radius-lg);
    padding: 32px;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    position: relative;
    animation: modalFadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Custom scrollbars for modal content and code box */
.modal-content::-webkit-scrollbar,
.code-box::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
.modal-content::-webkit-scrollbar-track,
.code-box::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 4px;
}
.modal-content::-webkit-scrollbar-thumb,
.code-box::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 4px;
}
.modal-content::-webkit-scrollbar-thumb:hover,
.code-box::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Global Form Controls within .form-group for consistency */
.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group select,
.form-group textarea {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
    width: 100%;
    margin-top: 4px;
}

.form-group input[type="text"]:focus,
.form-group input[type="number"]:focus,
.form-group input[type="password"]:focus,
.form-group input[type="email"]:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
    background: rgba(255, 255, 255, 0.08);
}

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

.form-group select option {
    background-color: #18181b;
    color: #f4f4f5;
}

/* Toast Notification System */
#toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 9999;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    min-width: 300px;
    max-width: 450px;
    background: rgba(18, 18, 24, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    color: var(--text-primary);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 12px;
    transform: translateX(120%);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s, margin 0.3s;
    opacity: 0;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid var(--danger);
}

.toast.warning {
    border-left: 4px solid var(--warning);
}

.toast.info {
    border-left: 4px solid var(--primary);
}

.toast-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.toast-message {
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.4;
    flex-grow: 1;
}

.toast-close {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.2rem;
    transition: var(--transition);
    border: none;
    background: transparent;
    padding: 0 4px;
}

.toast-close:hover {
    color: var(--text-primary);
}

/* ==============================================================================
   📱 MOBILE & TABLET RESPONSIVE STYLING (GLOBAL COMPETITIVE LAYOUT)
   ============================================================================== */

/* Make all tables responsive by default using containers */
.table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Base style overrides for mobile compatibility */
@media (max-width: 1024px) {
    .playground-grid {
        display: flex;
        flex-direction: column-reverse;
        gap: 15px;
        height: auto;
    }
    
    .chat-panel {
        height: 420px;
    }

    .play-sessions-list {
        max-height: 180px;
    }
}

@media (max-width: 992px) {
    body {
        flex-direction: column;
    }

    .app-layout {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
        width: 100%;
        max-width: 100%;
        padding-top: 75px; /* Offset for fixed mobile sidebar header */
    }

    /* Convert Sidebar to fixed top collapsible header on mobile */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 15px 20px;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        z-index: 1000;
        box-sizing: border-box;
    }

    .brand-section {
        margin-bottom: 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }

    .brand-name {
        font-size: 1.3rem;
    }

    .sidebar .mobile-menu-toggle {
        display: flex;
    }

    /* Hide standard nav lists by default, show vertically when active */
    .nav-menu {
        display: none;
        flex-direction: column;
        gap: 8px;
        width: 100%;
        margin-top: 15px;
        max-height: calc(100vh - 90px);
        overflow-y: auto;
    }

    .nav-menu.active {
        display: flex;
    }

    .nav-item {
        padding: 12px 16px;
        font-size: 0.95rem;
        width: 100%;
    }

    .nav-item:hover, .nav-item.active {
        border-left: 3px solid var(--primary);
        border-bottom: none;
    }

    .user-profile-section {
        display: none !important; /* Hide profile summary on small header space */
    }

    .sidebar.active .user-profile-section {
        display: flex !important;
        padding-top: 15px;
        border-top: 1px solid var(--border-color);
        margin-top: 15px;
        width: 100%;
    }

    /* Content adjustments */
    .content-area {
        padding: 20px;
        height: auto;
        overflow-y: visible;
    }

    .header-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        margin-bottom: 20px;
    }

    .header-container .btn {
        width: 100%;
    }

    /* Metrics system grid */
    .metrics-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .metric-card {
        padding: 18px;
    }

    /* Modals size adjustments */
    .modal-content, .modal-card {
        width: 95% !important;
        margin: 10px;
        padding: 20px;
    }

    /* Chat bubble widths */
    .chat-bubble {
        max-width: 90%;
    }
}

/* Extra small screens adjustments */
@media (max-width: 480px) {
    .auth-card {
        padding: 24px 16px;
        margin: 16px;
    }

    .brand-name {
        font-size: 1.1rem;
    }

    .btn {
        padding: 10px 16px;
        font-size: 0.88rem;
    }

    td, th {
        padding: 12px 8px;
        font-size: 0.82rem;
    }
}

/* Responsive Grid Helper */
.two-col-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.two-col-grid > * {
    min-width: 0; /* Prevents children like tables or charts from blowing up grid size */
}

@media (max-width: 992px) {
    .two-col-grid {
        grid-template-columns: 1fr;
    }
}

/* Responsive Charts/Canvas constraints */
.chart-wrapper {
    position: relative;
    width: 100%;
    height: 320px; /* Adjusted height */
    margin-top: 20px;
}

.chart-wrapper canvas, canvas {
    max-width: 100% !important;
}

/* Responsive Toast Notifications for Mobile */
@media (max-width: 480px) {
    #toast-container {
        right: 12px;
        left: 12px;
        top: 12px;
        width: calc(100% - 24px);
    }
    .toast {
        min-width: 100%;
        max-width: 100%;
    }
}

