/* === RESET & BASE === */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
    background: #f5f7fa;
    color: #1a1a2e;
    line-height: 1.6;
}
a { color: #3b82f6; text-decoration: none; }
a:hover { text-decoration: underline; }

/* === CHAT INTERFACE === */
.chat-container {
    display: flex;
    height: 100vh;
    max-width: 100vw;
    overflow: hidden;
}

.chat-sidebar {
    width: 280px;
    background: #0f0f23;
    color: #e2e8f0;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.chat-sidebar .brand {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #64748b;
    margin-bottom: 8px;
}

.chat-sidebar .company-name {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 32px;
    line-height: 1.3;
}

.new-chat-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    color: #e2e8f0;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.new-chat-btn:hover {
    background: #334155;
}

.sidebar-footer {
    margin-top: auto;
    font-size: 11px;
    color: #475569;
    text-align: center;
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    min-width: 0;
}

.chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid #e2e8f0;
    background: #fff;
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
}

.chat-header .header-info h2 {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a2e;
}

.chat-header .header-info p {
    font-size: 12px;
    color: #64748b;
}

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

.message {
    display: flex;
    gap: 12px;
    max-width: 80%;
    animation: fadeIn 0.3s ease;
}

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

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message .msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.message.assistant .msg-avatar {
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: #fff;
}

.message.user .msg-avatar {
    background: #e2e8f0;
    color: #475569;
}

.message .bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message.assistant .bubble {
    background: #f1f5f9;
    color: #1e293b;
    border-bottom-left-radius: 4px;
}

.message.user .bubble {
    background: #3b82f6;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.typing-indicator {
    display: none;
    align-self: flex-start;
    padding: 12px 16px;
    background: #f1f5f9;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    gap: 4px;
}

.typing-indicator.active {
    display: flex;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    animation: bounce 1.4s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-8px); }
}

.welcome-message {
    text-align: center;
    padding: 60px 24px;
    color: #64748b;
}

.welcome-message h3 {
    font-size: 20px;
    color: #1e293b;
    margin-bottom: 8px;
}

.welcome-message p {
    font-size: 14px;
    max-width: 400px;
    margin: 0 auto;
}

.chat-input-area {
    padding: 16px 24px;
    border-top: 1px solid #e2e8f0;
    background: #fff;
}

.chat-input-wrapper {
    display: flex;
    gap: 8px;
    max-width: 800px;
    margin: 0 auto;
}

.chat-input-wrapper textarea {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    min-height: 48px;
    max-height: 120px;
    transition: border-color 0.2s;
}

.chat-input-wrapper textarea:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.send-btn {
    padding: 12px 20px;
    background: #3b82f6;
    color: #fff;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.2s;
    align-self: flex-end;
}

.send-btn:hover { background: #2563eb; }
.send-btn:disabled { background: #94a3b8; cursor: not-allowed; }

/* === ADMIN STYLES === */
.admin-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 32px 24px;
}

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

.admin-header h1 {
    font-size: 28px;
    font-weight: 700;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary { background: #3b82f6; color: #fff; }
.btn-primary:hover { background: #2563eb; text-decoration: none; }
.btn-secondary { background: #e2e8f0; color: #1e293b; }
.btn-secondary:hover { background: #cbd5e1; text-decoration: none; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; text-decoration: none; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

.client-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: box-shadow 0.2s;
}

.client-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.05); }

.client-info h3 { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.client-info .meta {
    font-size: 13px;
    color: #64748b;
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.client-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.status-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.status-active { background: #dcfce7; color: #166534; }
.status-inactive { background: #fee2e2; color: #991b1b; }

.stat-box {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 16px;
    background: #f8fafc;
    border-radius: 8px;
    min-width: 80px;
}

.stat-box .number { font-size: 20px; font-weight: 700; color: #1e293b; }
.stat-box .label { font-size: 11px; color: #64748b; text-transform: uppercase; }

/* === LOGIN === */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #0f0f23, #1e293b);
}

.login-box {
    background: #fff;
    padding: 48px 40px;
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-box h1 {
    font-size: 24px;
    margin-bottom: 8px;
    text-align: center;
}

.login-box .subtitle {
    color: #64748b;
    font-size: 14px;
    text-align: center;
    margin-bottom: 32px;
}

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

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-group textarea { min-height: 120px; resize: vertical; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.flash-message {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
}

.flash-success { background: #dcfce7; color: #166534; }
.flash-error { background: #fee2e2; color: #991b1b; }

/* === USAGE TABLE === */
.usage-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
}

.usage-table th, .usage-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
    font-size: 14px;
}

.usage-table th {
    background: #f8fafc;
    font-weight: 600;
    color: #475569;
    font-size: 12px;
    text-transform: uppercase;
}

.usage-table tr:hover td { background: #f8fafc; }

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .chat-sidebar { display: none; }

    .chat-container { flex-direction: column; }

    .message { max-width: 90%; }

    .admin-container { padding: 16px; }

    .client-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .form-row { grid-template-columns: 1fr; }
}
