/* ===========================================
   SEO Global - Toàn Cầu
   Dark Theme, Premium Design
   =========================================== */

:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f7f7f8;
    --bg-tertiary: #ececf1;
    --bg-hover: #e5e5ea;
    --bg-card: rgba(255, 255, 255, 0.95);
    --text-primary: #101010;
    --text-secondary: #4a4a50;
    --text-muted: #8e8ea0;
    --accent: #0056b3;
    --accent-hover: #004494;
    --accent-glow: rgba(0, 86, 179, 0.2);
    --success: #10a37f;
    --danger: #ef4444;
    --warning: #f59e0b;
    --border: rgba(0, 0, 0, 0.1);
    --border-accent: rgba(0, 86, 179, 0.3);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.2s ease;
}

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

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-hover); border-radius: 3px; }

/* ===========================================
   LOGIN PAGE
   =========================================== */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #f0f2f5 0%, #e0e7ff 50%, #f0f2f5 100%);
}

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

.login-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 48px 36px;
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 36px;
}

.logo-icon {
    width: 64px;
    height: 64px;
    background-image: url('/static/logo.png');
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    background-color: transparent;
    border-radius: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0px; /* Hide text */
    color: transparent;
    margin-bottom: 16px;
    box-shadow: 0 8px 32px var(--accent-glow);
}

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

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

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

.input-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

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

.input-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn-primary {
    width: 100%;
    padding: 13px;
    background: linear-gradient(135deg, var(--accent), #4da3ff);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.auth-toggle {
    text-align: center;
    margin-top: 20px;
    font-size: 13px;
    color: var(--text-secondary);
}

.btn-link {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    font-weight: 500;
}

.btn-link:hover { text-decoration: underline; }

.login-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 12px;
    color: var(--text-muted);
}

.error-msg {
    background: rgba(225, 112, 85, 0.1);
    border: 1px solid rgba(225, 112, 85, 0.3);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 20px;
}

.hidden { display: none !important; }

/* ===========================================
   APP LAYOUT
   =========================================== */

.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header .brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.brand .logo-sm {
    width: 36px;
    height: 36px;
    background-image: url('/static/logo.png');
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    background-color: transparent;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0px; /* Hide text */
    color: transparent;
}

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

.btn-new-chat {
    width: 100%;
    padding: 10px;
    background: var(--bg-tertiary);
    border: 1px dashed var(--border-accent);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}

.btn-new-chat:hover {
    background: var(--bg-hover);
    color: var(--accent);
    border-color: var(--accent);
}

/* Conversation List */
.conv-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.conv-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 2px;
}

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

.conv-item.active {
    background: var(--accent-glow);
    border: 1px solid var(--border-accent);
}

.conv-item .conv-title {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.conv-item .conv-delete {
    opacity: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    padding: 2px 6px;
    transition: var(--transition);
}

.conv-item:hover .conv-delete { opacity: 1; }
.conv-item .conv-delete:hover { color: var(--danger); }

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: var(--bg-hover);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
}

.user-name { font-size: 13px; font-weight: 500; }
.user-role { font-size: 11px; color: var(--text-muted); }

.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    font-size: 18px;
    transition: var(--transition);
}

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

/* Main Chat Area */
.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

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

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

.message {
    display: flex;
    gap: 14px;
    margin-bottom: 28px;
    width: 100%;
    max-width: 860px;
    margin-left: auto;
    margin-right: auto;
    animation: fadeIn 0.3s ease;
}

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

.msg-avatar {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

.msg-avatar.user-av { background: var(--bg-hover); color: var(--accent); }
.msg-avatar.ai-av { background: linear-gradient(135deg, var(--accent), #4da3ff); color: white; }

.msg-content {
    flex: 1;
    font-size: 14px;
    line-height: 1.75;
    color: var(--text-primary);
}

.msg-content h1, .msg-content h2, .msg-content h3 {
    margin-top: 20px;
    margin-bottom: 10px;
}

.msg-content h1 { font-size: 22px; }
.msg-content h2 { font-size: 18px; color: var(--accent-hover); }
.msg-content h3 { font-size: 16px; }

.msg-content p { margin-bottom: 12px; }

.msg-content ul, .msg-content ol {
    margin-bottom: 12px;
    padding-left: 24px;
}

.msg-content li { margin-bottom: 4px; }

.msg-content code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

.msg-content pre {
    background: var(--bg-tertiary);
    padding: 16px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin-bottom: 12px;
}

.msg-content blockquote {
    border-left: 3px solid var(--accent);
    padding: 12px 16px;
    background: var(--accent-glow);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin-bottom: 12px;
}

.msg-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
}

.msg-content th, .msg-content td {
    border: 1px solid var(--border);
    padding: 8px 12px;
    text-align: left;
    font-size: 13px;
}

.msg-content th {
    background: var(--bg-tertiary);
    font-weight: 600;
}

.msg-content a {
    color: var(--accent-hover);
    text-decoration: none;
}

.msg-content a:hover { text-decoration: underline; }

.msg-actions {
    margin-top: 8px;
    display: flex;
    gap: 8px;
}

.btn-copy {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}

.btn-copy:hover { border-color: var(--accent); color: var(--accent); }

.welcome-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    text-align: center;
    padding: 40px;
    overflow-y: auto;
}

.welcome-content {
    margin: auto;
    width: 100%;
}

.welcome-content h2 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--accent), #4da3ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.welcome-content p {
    color: var(--text-secondary);
    margin-bottom: 32px;
    max-width: 480px;
}

.suggestion-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    max-width: 560px;
}

.suggestion-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: left;
    cursor: pointer;
    transition: var(--transition);
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.suggestion-card:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Chat Input */
.chat-input-area {
    padding: 16px 24px 24px;
    border-top: 1px solid var(--border);
}

.chat-input-wrapper {
    max-width: 860px;
    margin: 0 auto;
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-input-wrapper textarea {
    flex: 1;
    padding: 14px 18px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    min-height: 50px;
    max-height: 200px;
    line-height: 1.5;
    transition: var(--transition);
}

.chat-input-wrapper textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn-send {
    padding: 14px 20px;
    background: linear-gradient(135deg, var(--accent), #4da3ff);
    border: none;
    border-radius: var(--radius);
    color: white;
    font-size: 18px;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.btn-send:hover { opacity: 0.9; }
.btn-send:disabled { opacity: 0.4; cursor: not-allowed; }

.typing-indicator {
    display: inline-flex;
    gap: 4px;
    padding: 8px 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typingBounce 1.4s infinite;
}

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

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* Admin Page */
.admin-layout {
    max-width: 1000px;
    margin: 0 auto;
    padding: 40px 24px;
}

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

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

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

.stat-card .stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--accent);
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.section {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
}

.section h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
}

.btn-action {
    padding: 10px 20px;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}

.btn-action:hover { opacity: 0.9; }
.btn-action:disabled { opacity: 0.5; }

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

.file-list {
    list-style: none;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.file-item:last-child { border-bottom: none; }

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

/* Responsive */
@media (max-width: 768px) {
    .mobile-only {
        display: inline-flex !important;
    }
    
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 100;
        transform: translateX(-100%);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .sidebar-overlay.show {
        display: block;
    }

    .suggestion-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr; }
    
    /* Form Cấu hình xếp dọc */
    #writing-form-container > div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }
    
    .message {
        padding: 0 10px;
    }
}
