:root {
    --bg-dark: #0f172a;
    --sidebar-bg: #1e293b;
    --accent: #38bdf8;
    --text-main: #f8fafc;
    --text-dim: #94a3b8;
    --border: #334155;
    --glass: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.1);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid var(--border);
    gap: 1rem;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.topbar-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.topbar-hint {
    font-size: 0.8rem;
    color: var(--text-dim);
    white-space: nowrap;
}

.topbar-label {
    font-size: 0.85rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.topbar-select,
.topbar-input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-main);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    min-width: 180px;
}

.app-container {
    display: grid;
    grid-template-columns: 350px 1fr 350px;
    flex: 1;
    height: auto;
    min-height: 0;
}

.admin-container {
    grid-template-columns: 1fr;
}

.admin-panel {
    border-right: none;
}

body.admin-page {
    overflow-y: auto;
    overflow-x: hidden;
    height: auto;
    min-height: 100vh;
}

body.admin-page .app-container {
    height: auto;
    min-height: calc(100vh - 60px);
}

/* Columns */
.column {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    background: var(--glass);
    backdrop-filter: blur(10px);
    min-height: 0;
}

.column:last-child {
    border-right: none;
}

.column-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.column-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 3px;
    border-radius: 8px;
}

.tab {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-dim);
    padding: 0.5rem;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.tab.active {
    background: var(--accent);
    color: white;
}

/* Chat List */
.chat-list {
    overflow-y: auto;
    flex-grow: 1;
}

.chat-item {
    padding: 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: background 0.2s;
}

.chat-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.chat-item.active {
    background: rgba(56, 189, 248, 0.1);
    border-left: 3px solid var(--accent);
}

.chat-item .item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.chat-item .name {
    font-weight: 500;
}

.chat-item .time {
    font-size: 0.75rem;
    color: var(--text-dim);
}

.chat-item .snippet {
    font-size: 0.85rem;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-badge {
    display: inline-block;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    margin-top: 4px;
    text-transform: uppercase;
    font-weight: 600;
}

.status-badge.ai-handling {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.status-badge.human-needed {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.status-badge.human-handling {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.chat-window {
    background: transparent;
    min-height: 0;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-info-brief {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.avatar {
    width: 40px;
    height: 40px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.messages-container {
    flex-grow: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 0;
}

.message {
    max-width: 70%;
    padding: 1rem;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.message.user {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.05);
    border-bottom-left-radius: 2px;
}

.message.ai {
    align-self: flex-end;
    background: rgba(56, 189, 248, 0.1);
    color: var(--accent);
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-bottom-right-radius: 2px;
}

.message.human {
    align-self: flex-end;
    background: var(--success);
    color: white;
    border-bottom-right-radius: 2px;
}

.delivery-status {
    margin-top: 0.35rem;
    font-size: 0.72rem;
    opacity: 0.9;
}

.delivery-status.accepted,
.delivery-status.sent {
    color: var(--text-dim);
}

.delivery-status.delivered,
.delivery-status.read {
    color: #93c5fd;
}

.delivery-status.failed {
    color: #fecaca;
}

.delivery-status.mocked {
    color: #fde68a;
}

.chat-footer {
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    gap: 1rem;
}

#message-input {
    flex-grow: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    color: white;
    outline: none;
}

#message-input:focus {
    border-color: var(--accent);
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: opacity 0.2s;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-ai {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-dim);
    border: 1px solid var(--border);
}

.btn-ai.active {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border-color: var(--success);
}

/* CRM */
.profile-panel {
    padding: 1.5rem;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

#profile-content {
    min-height: 0;
    padding-bottom: 2rem;
}

.profile-card {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.manage-card {
    margin-bottom: 1.5rem;
}

.card-title {
    font-size: 1rem;
    margin-bottom: 1rem;
}

.manage-grid {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.manage-grid input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-main);
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
}

.manage-actions {
    display: flex;
    gap: 0.75rem;
}

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

.info-group {
    margin-bottom: 1.25rem;
}

.info-label {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.info-value {
    font-size: 1rem;
}

.info-group input,
.info-group select {
    width: 100%;
    margin-top: 0.35rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-main);
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
}

.info-group textarea {
    width: 100%;
    margin-top: 0.35rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-main);
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    resize: vertical;
    min-height: 72px;
}

.tag {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: rgba(56, 189, 248, 0.2);
    color: var(--accent);
    border-radius: 4px;
    font-size: 0.75rem;
    margin-right: 0.5rem;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}
