/* ==========================================================================
   AUTOKLASEN CHAT - OPERATOR DASHBOARD CSS
   ========================================================================== */

/* --------------------------------------------------------------------------
   Variables
   -------------------------------------------------------------------------- */
:root {
    --primary: #e94560;
    --primary-dark: #d63050;
    --secondary: #1a1a2e;
    --secondary-light: #16213e;
    --bg: #0f0f1a;
    --bg-card: #1a1a2e;
    --bg-input: #252540;
    --text: #ffffff;
    --text-secondary: #a0a0b0;
    --text-muted: #6c6c7c;
    --border: #2a2a40;
    --success: #28a745;
    --warning: #ffc107;
    --danger: #dc3545;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --transition: 0.2s ease;
    --header-height: 60px;
    --sidebar-width: 320px;
}

/* --------------------------------------------------------------------------
   Reset & Base
   -------------------------------------------------------------------------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

#app {
    height: 100%;
}

/* --------------------------------------------------------------------------
   Screens
   -------------------------------------------------------------------------- */
.screen {
    display: none;
    height: 100%;
}

.screen.active {
    display: flex;
}

/* --------------------------------------------------------------------------
   Login Screen
   -------------------------------------------------------------------------- */
#login-screen {
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg) 0%, var(--secondary) 100%);
}

.login-container {
    width: 100%;
    max-width: 380px;
    padding: 20px;
}

.login-logo {
    text-align: center;
    margin-bottom: 40px;
}

.logo-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 16px;
}

.login-logo h1 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 4px;
}

.login-logo p {
    color: var(--text-secondary);
    font-size: 14px;
}

.login-form {
    background: var(--bg-card);
    padding: 32px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    transition: border-color var(--transition);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.error-message {
    color: var(--danger);
    font-size: 13px;
    margin-bottom: 16px;
    min-height: 20px;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.btn-outline:hover:not(:disabled) {
    border-color: var(--text-secondary);
    color: var(--text);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--bg-input);
    color: var(--text);
}

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

/* Button loading state */
.btn .btn-loader {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.btn.loading .btn-text {
    display: none;
}

.btn.loading .btn-loader {
    display: block;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */
.header {
    height: var(--header-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-title {
    font-size: 20px;
    font-weight: 600;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.operator-name {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Status Badge */
.status-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-connecting {
    background: rgba(255, 193, 7, 0.15);
    color: var(--warning);
}

.status-connecting .status-dot {
    background: var(--warning);
    animation: pulse 1.5s infinite;
}

.status-connected {
    background: rgba(40, 167, 69, 0.15);
    color: var(--success);
}

.status-connected .status-dot {
    background: var(--success);
}

.status-disconnected {
    background: rgba(220, 53, 69, 0.15);
    color: var(--danger);
}

.status-disconnected .status-dot {
    background: var(--danger);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* --------------------------------------------------------------------------
   Main Content
   -------------------------------------------------------------------------- */
#dashboard-screen {
    flex-direction: column;
}

.main-content {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* --------------------------------------------------------------------------
   Conversations Panel
   -------------------------------------------------------------------------- */
.conversations-panel {
    width: var(--sidebar-width);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

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

.panel-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
}

/* Conversation Item */
.conversation-item {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background var(--transition);
}

.conversation-item:hover {
    background: var(--bg-input);
}

.conversation-item.active {
    background: var(--primary);
}

.conversation-item.active .conv-status,
.conversation-item.active .conv-time,
.conversation-item.active .conv-preview {
    color: rgba(255, 255, 255, 0.8);
}

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

.conv-visitor {
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.conv-badge {
    background: var(--primary);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
}

.conversation-item.active .conv-badge {
    background: white;
    color: var(--primary);
}

.conv-time {
    font-size: 12px;
    color: var(--text-muted);
}

.conv-preview {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-status {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.conv-status.ai {
    color: var(--warning);
}

.conv-status.operator {
    color: var(--success);
}

/* Empty State */
.empty-state {
    padding: 60px 20px;
    text-align: center;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* --------------------------------------------------------------------------
   Chat Panel
   -------------------------------------------------------------------------- */
.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    min-width: 0;
}

.chat-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.placeholder-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Chat Header */
.chat-header {
    padding: 12px 20px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
}

.chat-header-info {
    flex: 1;
}

.chat-header-info h3 {
    font-size: 15px;
    font-weight: 600;
}

.chat-status {
    font-size: 12px;
    color: var(--text-muted);
}

.chat-header-actions {
    display: flex;
    gap: 8px;
}

/* Visitor Info */
.visitor-info {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}

.visitor-info-toggle {
    width: 100%;
    padding: 10px 20px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: color var(--transition);
}

.visitor-info-toggle:hover {
    color: var(--text);
}

.visitor-info-toggle svg {
    transition: transform var(--transition);
}

.visitor-info.collapsed .visitor-info-toggle svg {
    transform: rotate(-90deg);
}

.visitor-info-content {
    padding: 0 20px 16px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.visitor-info.collapsed .visitor-info-content {
    display: none;
}

.info-row {
    font-size: 12px;
}

.info-label {
    color: var(--text-muted);
    display: block;
    margin-bottom: 2px;
}

.info-value {
    color: var(--text-secondary);
    word-break: break-all;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    max-width: 75%;
    animation: messageIn 0.2s ease;
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
}

.message-content {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.message-time {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
    padding: 0 4px;
}

.message-sender {
    font-size: 11px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 4px;
    padding: 0 4px;
}

/* Message types */
.message.visitor {
    align-self: flex-start;
}

.message.visitor .message-content {
    background: var(--bg-card);
    border-bottom-left-radius: 4px;
}

.message.ai,
.message.operator {
    align-self: flex-end;
}

.message.ai .message-content {
    background: var(--secondary-light);
    border-bottom-right-radius: 4px;
}

.message.operator .message-content {
    background: var(--primary);
    border-bottom-right-radius: 4px;
}

.message.ai .message-time,
.message.operator .message-time {
    text-align: right;
}

/* Chat Input */
.chat-input-area {
    padding: 16px 20px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.message-input {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    transition: border-color var(--transition);
}

.message-input:focus {
    outline: none;
    border-color: var(--primary);
}

.message-input:disabled {
    opacity: 0.5;
}

.message-input::placeholder {
    color: var(--text-muted);
}

#send-btn {
    flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Toast Notifications
   -------------------------------------------------------------------------- */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 14px 20px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: toastIn 0.3s ease;
    min-width: 280px;
    max-width: 400px;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
}

.toast.toast-out {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastOut {
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

.toast-icon {
    font-size: 20px;
}

.toast-message {
    flex: 1;
    font-size: 14px;
}

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

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

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

/* --------------------------------------------------------------------------
   Mobile Styles
   -------------------------------------------------------------------------- */
.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 100%;
    }
    
    .mobile-only {
        display: flex;
    }
    
    .conversations-panel {
        position: absolute;
        inset: var(--header-height) 0 0 0;
        width: 100%;
        z-index: 10;
        transition: transform var(--transition);
    }
    
    .main-content {
        position: relative;
    }
    
    /* Hide sidebar when chat is open on mobile */
    .main-content.chat-open .conversations-panel {
        transform: translateX(-100%);
    }
    
    .chat-panel {
        position: absolute;
        inset: 0;
        z-index: 5;
    }
    
    .chat-header-info h3 {
        font-size: 14px;
    }
    
    .chat-header-actions .btn {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    .message {
        max-width: 85%;
    }
    
    .visitor-info-content {
        grid-template-columns: 1fr;
    }
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Utilities
   -------------------------------------------------------------------------- */
.hidden {
    display: none !important;
}
