/* Core Design Tokens & Variables */
:root {
    --bg-main: #0b0f19;
    --bg-card: rgba(17, 24, 39, 0.75);
    --bg-card-hover: rgba(31, 41, 55, 0.85);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(16, 185, 129, 0.2);
    
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;

    --color-emerald: #10b981;
    --color-emerald-glow: rgba(16, 185, 129, 0.4);
    --color-violet: #8b5cf6;
    --color-violet-glow: rgba(139, 92, 246, 0.4);
    
    --color-warning: #f59e0b;
    --color-warning-glow: rgba(245, 158, 11, 0.3);
    --color-danger: #ef4444;
    --color-danger-glow: rgba(239, 68, 68, 0.3);
    --color-info: #3b82f6;

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    
    --shadow-main: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --transition-fast: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset and Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-main);
    background-image: 
        radial-gradient(at 0% 0%, rgba(139, 92, 246, 0.08) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(16, 185, 129, 0.08) 0px, transparent 50%),
        radial-gradient(at 50% 100%, rgba(17, 24, 39, 0.95) 0px, transparent 80%);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    overflow: hidden;
}

/* App Container Layout */
.app-container {
    width: 100%;
    max-width: 1600px;
    height: 100vh;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    animation: fadeIn 0.4s ease-out;
}

/* Header Styles */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    width: 46px;
    height: 46px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--color-emerald), var(--color-violet));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.3);
}

header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    background: linear-gradient(to right, #ffffff, #d1d5db);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

header .subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
}

.user-badge i {
    color: var(--color-violet);
    width: 15px;
    height: 15px;
}

/* Main Content Grid */
main {
    flex: 1;
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 1.5rem;
    height: calc(100vh - 120px);
    overflow: hidden;
}

/* Sidebar Section (Sessions) */
.sessions-section {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-main);
}

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

.section-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.section-header h2 i {
    color: var(--color-violet);
}

.badge {
    background: rgba(139, 92, 246, 0.15);
    border: 1px solid rgba(139, 92, 246, 0.3);
    color: #c084fc;
    padding: 2px 10px;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 600;
}

.sessions-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Scrollbars */
.sessions-list::-webkit-scrollbar,
.detail-body::-webkit-scrollbar {
    width: 6px;
}
.sessions-list::-webkit-scrollbar-track,
.detail-body::-webkit-scrollbar-track {
    background: transparent;
}
.sessions-list::-webkit-scrollbar-thumb,
.detail-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

/* Session Items */
.session-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.2rem;
    cursor: pointer;
    transition: var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.session-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: transparent;
    transition: var(--transition-fast);
}

.session-item:hover {
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.15);
}

.session-item.active {
    background: rgba(139, 92, 246, 0.04);
    border-color: rgba(139, 92, 246, 0.4);
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.05);
}

.session-item.active::before {
    background: var(--color-violet);
}

.session-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.session-name {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}

.session-sub {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Status Pills */
.status-pill {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 50px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.status-pill::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.status-pill.connected {
    background: rgba(16, 185, 129, 0.1);
    color: var(--color-emerald);
    border: 1px solid rgba(16, 185, 129, 0.2);
}
.status-pill.connected::before {
    background: var(--color-emerald);
    box-shadow: 0 0 8px var(--color-emerald);
    animation: pulse 1.5s infinite alternate;
}

.status-pill.connecting {
    background: rgba(59, 130, 246, 0.1);
    color: var(--color-info);
    border: 1px solid rgba(59, 130, 246, 0.2);
}
.status-pill.connecting::before {
    background: var(--color-info);
}

.status-pill.pairing_code {
    background: rgba(245, 158, 11, 0.1);
    color: var(--color-warning);
    border: 1px solid rgba(245, 158, 11, 0.2);
}
.status-pill.pairing_code::before {
    background: var(--color-warning);
    animation: pulse 1.5s infinite alternate;
}

.status-pill.disconnected, .status-pill.offline {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}
.status-pill.disconnected::before, .status-pill.offline::before {
    background: var(--text-muted);
}

/* Workspace Section */
.workspace-section {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.workspace-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    flex: 1;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-main);
    overflow: hidden;
}

.welcome-card {
    align-items: center;
    justify-content: center;
    padding: 3rem;
    text-align: center;
}

.welcome-icon {
    width: 64px;
    height: 64px;
    color: var(--color-emerald);
    margin-bottom: 1.5rem;
    filter: drop-shadow(0 0 10px rgba(16, 185, 129, 0.2));
}

.welcome-card h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.welcome-card p {
    color: var(--text-secondary);
    max-width: 540px;
    line-height: 1.6;
    font-size: 0.95rem;
}

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

.detail-header h3 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.status-badge-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.detail-body {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

.card-group {
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-group h4 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-group h4 i {
    color: var(--color-emerald);
}

.group-description {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
}

/* Switch Styles (Individuals vs Groups Toggles) */
.toggle-container {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

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

.toggle-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.toggle-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.toggle-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.toggle-sub {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
    flex-shrink: 0;
}

.switch input { 
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border: 1px solid var(--border-color);
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: var(--color-emerald);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
    border-color: rgba(16, 185, 129, 0.5);
}

input:checked + .slider:before {
    transform: translateX(24px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Forms */
.form-control {
    margin-bottom: 1.25rem;
}

.form-control label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.form-control input,
.form-control textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    color: white;
    font-size: 0.95rem;
    transition: var(--transition-fast);
}

.form-control input:focus,
.form-control textarea:focus {
    outline: none;
    border-color: var(--color-violet);
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.15);
}

.form-control small {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    border: 1px solid transparent;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-violet), #6d28d9);
    color: white;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.2);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.3);
}

.btn-success {
    background: linear-gradient(135deg, var(--color-emerald), #047857);
    color: white;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.2);
}
.btn-success:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.3);
}

.btn-danger {
    background: transparent;
    border: 1px solid var(--color-danger);
    color: var(--color-danger);
}
.btn-danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

.btn-icon {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: var(--radius-sm);
}
.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: var(--transition-normal);
}

.modal {
    background: #0f172a;
    border: 1px solid var(--border-color);
    width: 100%;
    max-width: 520px;
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.btn-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}
.btn-close:hover {
    color: white;
}

.modal-body {
    padding: 1.5rem;
}

.code-display {
    animation: fadeIn 0.3s ease-out;
}

.divider {
    height: 1px;
    background: var(--border-color);
    margin: 1.5rem 0;
}

.instruction-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 1rem;
}

.pairing-code-container {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-glow);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

#pairing-code-val {
    font-family: 'JetBrains Mono', monospace;
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--color-emerald);
    text-shadow: 0 0 10px rgba(16, 185, 129, 0.2);
}

.status-update-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Authentication Screen Overlay */
.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-main);
    background-image: 
        radial-gradient(at 0% 0%, rgba(139, 92, 246, 0.12) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(16, 185, 129, 0.12) 0px, transparent 50%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    transition: var(--transition-normal);
}

.auth-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-main);
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-icon-lg {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--color-emerald), var(--color-violet));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    margin: 0 auto 1.25rem;
    font-size: 1.8rem;
    box-shadow: 0 0 25px rgba(16, 185, 129, 0.3);
}

.auth-header h2 {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    margin-bottom: 0.25rem;
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.auth-switch {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 1.5rem;
}

.auth-switch a {
    color: var(--color-violet);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition-fast);
}

.auth-switch a:hover {
    color: #a78bfa;
    text-decoration: underline;
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-top: 1rem;
}
.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--color-emerald);
}
.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--color-danger);
}

/* Spinners */
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255, 255, 255, 0.05);
    border-top: 3px solid var(--color-violet);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 2rem auto 1rem;
}

.spinner-sm {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.05);
    border-top: 2px solid var(--color-emerald);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.hidden {
    display: none !important;
}

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

@keyframes pulse {
    0% { transform: scale(0.9); opacity: 0.6; }
    100% { transform: scale(1.1); opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.diagnostics-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.diagnostics-actions .btn {
    flex: 1;
    min-width: 160px;
}

.api-key-sidebar {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.01);
}

.api-key-header {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.api-key-header i {
    color: var(--color-violet);
    width: 14px;
    height: 14px;
}

.api-key-container {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.api-key-container input {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    color: var(--text-primary);
    outline: none;
}

.btn-api-icon {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.btn-api-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.method-selector button {
    flex: 1;
    text-align: center;
    border-radius: 4px !important;
    transition: var(--transition-fast);
}

.method-selector button.active {
    background: var(--color-violet) !important;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.2);
    color: white !important;
    border-color: rgba(139, 92, 246, 0.3) !important;
}
