/* VimesTask — Enhanced UI */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

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

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --success: #10b981;
    --success-light: #d1fae5;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --purple: #8b5cf6;
    --purple-light: #ede9fe;
    --bg: #f1f5f9;
    --card: #ffffff;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --sidebar-active: #2563eb;
    --sidebar-text: #cbd5e1;
    --sidebar-text-active: #ffffff;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.12), 0 4px 8px rgba(0, 0, 0, 0.06);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: 0.2s ease;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ===================== LOGIN ===================== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1e3a8a 0%, #6d28d9 50%, #1e293b 100%);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 50%;
    top: -200px;
    right: -200px;
    pointer-events: none;
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
    animation: fadeUp 0.5s ease;
    position: relative;
    z-index: 1;
}

.login-box {
    background: white;
    padding: 44px 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.login-box h1 {
    font-size: 30px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 6px;
    text-align: center;
    letter-spacing: -0.5px;
}

.login-box h2 {
    font-size: 15px;
    color: var(--text-muted);
    margin-bottom: 32px;
    text-align: center;
    font-weight: 400;
}

/* ===================== FORMS ===================== */
.form-group {
    margin-bottom: 20px;
}

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

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    color: var(--text);
    background: var(--card);
    transition: border-color var(--transition), box-shadow var(--transition);
    touch-action: manipulation;
    -webkit-appearance: none;
    appearance: none;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

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

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

/* ===================== BUTTONS ===================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--sidebar-bg);
    color: white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.btn-secondary:hover {
    background: var(--sidebar-hover);
    transform: translateY(-1px);
}

.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

button[type="submit"].btn-primary {
    width: 100%;
    justify-content: center;
    padding: 13px;
    font-size: 15px;
}

/* ===================== HEADER ===================== */
.header {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 200;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 24px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 20px;
}

.logo h2 {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo h2::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    box-shadow: 0 0 0 3px var(--primary-light);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 14px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--purple) 100%);
    color: white;
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.user-name {
    font-weight: 600;
    font-size: 14px;
}

.user-role {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===================== LAYOUT ===================== */
.container {
    display: flex;
    min-height: calc(100vh - 61px);
}

/* ===================== SIDEBAR ===================== */
.sidebar {
    width: 240px;
    background: var(--sidebar-bg);
    flex-shrink: 0;
    padding: 20px 0;
    display: flex;
    flex-direction: column;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition);
    position: relative;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: white;
    transform: translateX(2px);
}

.nav-item.active {
    background: var(--sidebar-active);
    color: var(--sidebar-text-active);
    box-shadow: 0 2px 10px rgba(37, 99, 235, 0.35);
}

.nav-item .icon {
    font-size: 17px;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

/* ===================== MAIN CONTENT ===================== */
.main-content {
    flex: 1;
    padding: 28px 32px;
    overflow-y: auto;
}

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

.dashboard-header h1 {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text);
}

/* ===================== STAT CARDS ===================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--card);
    padding: 22px 24px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border-left: 4px solid transparent;
    transition: transform var(--transition), box-shadow var(--transition);
    animation: fadeUp 0.4s ease both;
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    transform: translate(20px, -20px);
    opacity: 0.06;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

/* Accent colors per card — applied via JS-added classes or nth-child */
.stat-card:nth-child(1) {
    border-left-color: var(--primary);
}

.stat-card:nth-child(1)::after {
    background: var(--primary);
}

.stat-card:nth-child(2) {
    border-left-color: var(--warning);
}

.stat-card:nth-child(2)::after {
    background: var(--warning);
}

.stat-card:nth-child(3) {
    border-left-color: var(--success);
}

.stat-card:nth-child(3)::after {
    background: var(--success);
}

.stat-card:nth-child(4) {
    border-left-color: var(--purple);
}

.stat-card:nth-child(4)::after {
    background: var(--purple);
}

.stat-card h3 {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.8px;
    margin-bottom: 10px;
}

.stat-number {
    font-size: 38px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -1px;
    line-height: 1;
}

.stat-card:nth-child(1) .stat-number {
    color: var(--primary);
}

.stat-card:nth-child(2) .stat-number {
    color: var(--warning);
}

.stat-card:nth-child(3) .stat-number {
    color: var(--success);
}

.stat-card:nth-child(4) .stat-number {
    color: var(--purple);
}

/* ===================== TASKS SECTION ===================== */
.tasks-section {
    background: var(--card);
    padding: 24px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.tasks-section h2 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text);
}

.filter-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 4px;
    border: none;
    width: fit-content;
}

.tab-btn {
    padding: 8px 18px;
    background: none;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 500;
    font-size: 13px;
    color: var(--text-muted);
    font-family: 'Inter', sans-serif;
    transition: all var(--transition);
}

.tab-btn:hover {
    color: var(--text);
}

.tab-btn.active {
    background: var(--card);
    color: var(--primary);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

/* ===================== TASK ITEMS ===================== */
.tasks-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.task-item {
    padding: 16px 18px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
    background: var(--card);
    animation: fadeUp 0.3s ease both;
}

.task-item:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.08);
    transform: translateY(-1px);
}

.task-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
    gap: 12px;
}

.task-title {
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
    flex: 1;
}

.task-badges {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.task-priority,
.task-status {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.priority-low {
    background: var(--primary-light);
    color: #1e40af;
}

.priority-medium {
    background: var(--warning-light);
    color: #92400e;
}

.priority-high {
    background: #fed7aa;
    color: #9a3412;
}

.priority-urgent {
    background: var(--danger-light);
    color: #991b1b;
}

.status-todo {
    background: #e0e7ff;
    color: #3730a3;
}

.status-in_progress {
    background: var(--primary-light);
    color: #1e40af;
}

.status-review {
    background: var(--warning-light);
    color: #92400e;
}

.status-completed {
    background: var(--success-light);
    color: #065f46;
}

.status-cancelled {
    background: #f1f5f9;
    color: #64748b;
}

.task-description {
    color: var(--text-muted);
    font-size: 13.5px;
    margin-bottom: 12px;
    line-height: 1.5;
}

.task-meta {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: var(--text-muted);
    align-items: center;
}

.task-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ===================== MODAL ===================== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(3px);
    animation: fadeIn 0.2s ease;
    overflow-y: auto;
    padding: 24px 16px;
    /* Khi JS set display:block, override sang flex để căn giữa */
}

/* JS dùng display:block — override để căn giữa */
.modal[style*="display: block"],
.modal[style*="display:block"] {
    display: flex !important;
    align-items: flex-start;
    justify-content: center;
}

.modal-content {
    background: var(--card);
    margin: 0 auto;
    padding: 32px;
    border-radius: var(--radius-lg);
    width: 92%;
    max-width: 680px;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideDown 0.25s ease;
    position: relative;
}

.modal-large {
    max-width: min(960px, 92vw);
    width: 92%;
}

.modal-content h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.close {
    position: absolute;
    top: 20px;
    right: 24px;
    color: var(--text-muted);
    font-size: 24px;
    font-weight: 400;
    cursor: pointer;
    line-height: 1;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.close:hover {
    background: var(--bg);
    color: var(--text);
}

/* ===================== EDITOR ===================== */
#editor {
    min-height: 280px;
    background: white;
    border-radius: 0 0 6px 6px;
}

.ql-editor {
    min-height: 280px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
}

.ql-toolbar {
    border-radius: 6px 6px 0 0;
}

/* ===================== ATTACHMENTS ===================== */
.attachments-section {
    margin-top: 24px;
}

.attachment-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 12px;
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    transition: border-color var(--transition);
}

.attachment-item:hover {
    border-color: var(--primary);
}

.attachment-item img {
    max-width: 100px;
    max-height: 100px;
    border-radius: 4px;
    transition: transform var(--transition);
}

.attachment-item img:hover {
    transform: scale(1.05);
}

.attachment-item a {
    text-decoration: none;
    color: var(--text);
}

.attachment-item .file-link {
    color: var(--primary);
    font-weight: 500;
    transition: color var(--transition);
}

.attachment-item .file-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* ===================== COMMENTS ===================== */
.comments-section {
    margin-top: 24px;
}

.comment-item {
    padding: 14px 16px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    border-left: 3px solid var(--border);
    transition: border-color var(--transition);
}

.comment-item:hover {
    border-left-color: var(--primary);
}

.comment-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 13px;
}

.comment-author {
    font-weight: 600;
    color: var(--text);
}

.comment-time {
    color: var(--text-muted);
}

/* ===================== UPLOAD AREA ===================== */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 28px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    margin-top: 12px;
    color: var(--text-muted);
    font-size: 14px;
}

.upload-area:hover {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
}

.upload-area input[type="file"] {
    display: none;
}

/* ===================== MESSAGES ===================== */
.error-message {
    color: var(--danger);
    font-size: 13px;
    margin: 10px 0;
    display: none;
    padding: 10px 14px;
    background: var(--danger-light);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--danger);
}

.error-message.show {
    display: block;
}

.success-message {
    color: #065f46;
    font-size: 13px;
    margin: 10px 0;
    padding: 10px 14px;
    background: var(--success-light);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--success);
}

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

/* ===================== LOADING ===================== */
.loading {
    text-align: center;
    padding: 48px;
    color: var(--text-muted);
    font-size: 14px;
}

.loading::before {
    content: '';
    display: block;
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

/* ===================== ANIMATIONS ===================== */
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-16px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

/* Stagger animation for cards */
.stat-card:nth-child(1) {
    animation-delay: 0.05s;
}

.stat-card:nth-child(2) {
    animation-delay: 0.10s;
}

.stat-card:nth-child(3) {
    animation-delay: 0.15s;
}

.stat-card:nth-child(4) {
    animation-delay: 0.20s;
}

/* ===================== RESPONSIVE ===================== */
/* ===================== RESPONSIVE ===================== */

/* Tablet */
@media (max-width: 768px) {

    /* Header */
    .header-content {
        padding: 10px 16px;
        gap: 8px;
    }

    .logo img {
        height: 32px;
    }

    .logo a[href*="drive"] span,
    .logo a[href*="drive"] {
        font-size: 12px;
    }

    /* Hide doc link text on small screens */
    .logo>a:last-child {
        display: none;
    }

    .user-info {
        display: none;
    }

    .user-menu {
        gap: 8px;
    }

    .btn.btn-secondary {
        padding: 7px 12px;
        font-size: 12px;
    }

    /* Layout */
    .container {
        flex-direction: column;
    }

    /* Sidebar — horizontal scrollable icon bar */
    .sidebar {
        width: 100%;
        padding: 8px 12px;
        overflow-x: auto;
        /* prevent sidebar from being too tall */
        flex-shrink: 0;
    }

    .sidebar-nav {
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 4px;
        padding: 0;
        width: max-content;
        min-width: 100%;
    }

    .nav-item {
        padding: 8px 14px;
        font-size: 13px;
        white-space: nowrap;
        border-radius: 6px;
        flex-shrink: 0;
    }

    .nav-item:hover {
        transform: none;
    }

    /* Main */
    .main-content {
        padding: 16px 12px;
    }

    .dashboard-header {
        margin-bottom: 16px;
        flex-wrap: wrap;
        gap: 10px;
    }

    .dashboard-header h1 {
        font-size: 20px;
    }

    /* Stats */
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
        margin-bottom: 16px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-number {
        font-size: 28px;
    }

    /* Tasks */
    .tasks-section {
        padding: 16px;
    }

    .filter-tabs {
        overflow-x: auto;
        width: 100%;
    }

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

    /* Modal */
    .modal {
        padding: 12px;
    }

    .modal-content {
        padding: 20px 16px;
        max-height: calc(100vh - 24px);
        border-radius: 10px;
    }

    .modal-content h2 {
        font-size: 17px;
    }
}

/* Mobile */
@media (max-width: 480px) {
    .header-content {
        padding: 8px 12px;
    }

    .logo img {
        height: 28px;
    }

    .user-avatar {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .stat-card {
        padding: 14px 12px;
    }

    .stat-number {
        font-size: 24px;
    }

    .stat-card h3 {
        font-size: 10px;
    }

    .filter-tabs {
        width: 100%;
        overflow-x: auto;
    }

    .tab-btn {
        padding: 7px 12px;
        font-size: 12px;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .task-item {
        padding: 12px 14px;
    }

    .task-title {
        font-size: 14px;
    }

    .task-badges {
        flex-wrap: wrap;
        gap: 4px;
    }

    .modal-content {
        padding: 16px 14px;
        border-radius: 8px;
    }

    .close {
        top: 12px;
        right: 14px;
        font-size: 20px;
    }
}

/* ===================== AI CHATBOT WIDGET ===================== */
#ai-widget {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 9999;
    font-family: 'Inter', sans-serif;
}

/* Floating Toggle Button */
#ai-toggle-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 2px solid rgba(109, 40, 217, 0.6);
    cursor: pointer;
    background: rgba(109, 40, 217, 0.12);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #7c3aed;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 0 rgba(109, 40, 217, 0.35);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    animation: ai-glow-ring 2.5s ease-in-out infinite;
}

#ai-toggle-btn:hover,
#ai-toggle-btn.active {
    transform: scale(1.1);
    background: rgba(109, 40, 217, 0.22);
    border-color: rgba(109, 40, 217, 0.9);
    box-shadow: 0 0 20px rgba(109, 40, 217, 0.4), 0 0 40px rgba(109, 40, 217, 0.15);
    animation: none;
}

@keyframes ai-glow-ring {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(109, 40, 217, 0.4), 0 0 12px rgba(109, 40, 217, 0.15);
    }

    50% {
        box-shadow: 0 0 0 10px rgba(109, 40, 217, 0), 0 0 20px rgba(109, 40, 217, 0.1);
    }
}

/* Badge */
.ai-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    animation: ai-bounce 0.6s ease;
}

@keyframes ai-bounce {
    0% {
        transform: scale(0);
    }

    60% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

/* Chat Panel */
.ai-panel {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 360px;
    height: 520px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18), 0 4px 16px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(226, 232, 240, 0.8);
    opacity: 0;
    transform: translateY(16px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-origin: bottom right;
}

.ai-panel.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Panel Header */
.ai-panel-header {
    padding: 16px 18px;
    background: linear-gradient(135deg, #4c1d95 0%, #1d4ed8 100%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

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

.ai-avatar {
    width: 38px;
    height: 38px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: white;
    font-weight: 700;
    flex-shrink: 0;
    border: 1.5px solid rgba(255, 255, 255, 0.3);
}

.ai-title {
    font-size: 14px;
    font-weight: 700;
    color: white;
    letter-spacing: -0.2px;
}

.ai-subtitle {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 1px;
}

.ai-icon-btn {
    background: rgba(255, 255, 255, 0.12);
    border: none;
    color: white;
    font-size: 15px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.ai-icon-btn:hover {
    background: rgba(255, 255, 255, 0.22);
}

/* Messages Area */
.ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
    background: #f8fafc;
}

.ai-messages::-webkit-scrollbar {
    width: 4px;
}

.ai-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

/* Message Bubbles */
.ai-msg {
    display: flex;
    animation: ai-fadeUp 0.25s ease;
}

@keyframes ai-fadeUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-msg--ai {
    justify-content: flex-start;
    flex-direction: column;
    /* stack bubble + ok-wrap vertically */
    align-items: flex-start;
    max-width: 92%;
}

.ai-msg--user {
    justify-content: flex-end;
    align-self: flex-end;
    max-width: 80%;
    margin-left: auto;
}

.ai-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.6;
    word-break: break-word;
    white-space: normal;
}

.ai-msg--ai .ai-bubble {
    width: 100%;
    /* fill full column – no more side-by-side */
    background: white;
    color: #1e293b;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
    border: 1px solid #e2e8f0;
    box-sizing: border-box;
}

.ai-msg--ai .ai-bubble p {
    margin: 0 0 6px;
    white-space: normal;
}

.ai-msg--ai .ai-bubble p:last-child {
    margin-bottom: 0;
}

.ai-msg--ai .ai-bubble ul {
    margin: 4px 0 4px 16px;
    padding: 0;
}

.ai-msg--ai .ai-bubble li {
    margin-bottom: 3px;
}

.ai-msg--ai .ai-bubble h3,
.ai-msg--ai .ai-bubble h4 {
    margin: 8px 0 4px;
    font-size: 13.5px;
    color: #1e293b;
}

.ai-msg--ai .ai-bubble strong {
    color: #1e293b;
}

.ai-msg--ai .ai-bubble code {
    background: #f1f5f9;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 12px;
    font-family: monospace;
}

.ai-msg--user .ai-bubble {
    background: linear-gradient(135deg, #4c1d95 0%, #2563eb 100%);
    color: white;
    border-bottom-right-radius: 4px;
    max-width: 100%;
}

/* Typing Indicator */
.ai-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 0;
}

.ai-dots span {
    width: 7px;
    height: 7px;
    background: #94a3b8;
    border-radius: 50%;
    animation: ai-dot 1.4s ease-in-out infinite;
}

.ai-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes ai-dot {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-5px);
        opacity: 1;
    }
}

/* Input Area */
.ai-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid #e2e8f0;
    background: white;
    flex-shrink: 0;
}

.ai-textarea {
    flex: 1;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    padding: 9px 13px;
    font-size: 13.5px;
    font-family: 'Inter', sans-serif;
    color: #1e293b;
    resize: none;
    line-height: 1.4;
    background: #f8fafc;
    transition: border-color 0.2s, box-shadow 0.2s;
    max-height: 120px;
    overflow-y: auto;
}

.ai-textarea:focus {
    outline: none;
    border-color: #6d28d9;
    box-shadow: 0 0 0 3px rgba(109, 40, 217, 0.1);
    background: white;
}

.ai-textarea::placeholder {
    color: #94a3b8;
}

.ai-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, #6d28d9 0%, #2563eb 100%);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.ai-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(109, 40, 217, 0.35);
}

.ai-send-btn:disabled {
    cursor: not-allowed;
}

/* Footer disclaimer */
.ai-footer {
    text-align: center;
    font-size: 10.5px;
    color: #94a3b8;
    padding: 6px 14px 10px;
    background: white;
    flex-shrink: 0;
}

/* Mobile responsive */
@media (max-width: 480px) {
    #ai-widget {
        bottom: 16px;
        right: 16px;
    }

    .ai-panel {
        width: calc(100vw - 32px);
        height: 80vh;
        right: 0;
        bottom: 72px;
    }
}

/* ── OK Action Buttons ──────────────────────── */
.ai-ok-wrap {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    width: 100%;
}

.ai-ok-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    border: none;
    border-radius: 20px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
    /* prevent stretching */
}

/* Primary OK */
.ai-ok-btn:not(.ai-ok-btn--skip) {
    background: linear-gradient(135deg, #6d28d9, #2563eb);
    color: white;
    box-shadow: 0 2px 8px rgba(109, 40, 217, 0.25);
}

.ai-ok-btn:not(.ai-ok-btn--skip):hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(109, 40, 217, 0.4);
}

.ai-ok-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Skip button */
.ai-ok-btn--skip {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
}

.ai-ok-btn--skip:hover {
    background: #e2e8f0;
    color: #334155;
}

/* ===================== PROFILE HERO ===================== */
.profile-hero {
    display: flex;
    align-items: center;
    gap: 32px;
    padding: 32px;
    margin-bottom: 32px;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid var(--border);
}

.profile-avatar-container {
    position: relative;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    overflow: hidden;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    border: 4px solid white;
}

.profile-avatar-large {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.avatar-edit-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: white;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
}

.profile-avatar-container:hover .avatar-edit-overlay {
    opacity: 1;
}

.profile-avatar-container:hover .profile-avatar-large {
    transform: scale(1.1);
}

.avatar-edit-overlay i {
    width: 24px;
    height: 24px;
}

.avatar-edit-overlay span {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.profile-hero-info h2 {
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 8px;
    border: none;
    padding: 0;
}

.role-badge {
    display: inline-block;
    padding: 4px 12px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===================== ZONE MULTI-SELECT ===================== */
.zone-multiselect {
    position: relative;
    width: 100%;
}

.zone-multiselect-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border: 1.5px solid var(--border, #e2e8f0);
    border-radius: 8px;
    background: white;
    cursor: pointer;
    font-size: 14px;
    color: #334155;
    transition: border-color 0.2s, box-shadow 0.2s;
    min-height: 42px;
}

.zone-multiselect-display:hover {
    border-color: #6d28d9;
}

.zone-arrow {
    font-size: 10px;
    color: #94a3b8;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.zone-multiselect.open .zone-arrow {
    transform: rotate(180deg);
}

.zone-dropdown-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1.5px solid var(--border, #e2e8f0);
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 100;
    max-height: 200px;
    overflow-y: auto;
}

.zone-checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 14px;
    color: #334155;
}

.zone-checkbox-item:hover {
    background: #f1f5f9;
}

.zone-checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #6d28d9;
    cursor: pointer;
    flex-shrink: 0;
}

.zone-checkbox-item label {
    cursor: pointer;
    flex: 1;
    user-select: none;
}

.zone-selected-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.zone-badge-sm {
    background: #ede9fe;
    color: #5b21b6;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

/* ===================== PAGINATION ===================== */
.cr-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 24px;
}

.cr-page-btn {
    padding: 8px 14px;
    background: white;
    border: 1.5px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}

.cr-page-btn:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--bg);
}

.cr-page-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

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

/* =========================================
   MOBILE DASHBOARD LAYOUT
   ========================================= */
.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }

    .mobile-only {
        display: block;
    }

    /* VimesTask Mobile Layout Styles */
    .mobile-dashboard {
        background: #f1f5f9;
        min-height: 100vh;
        padding-bottom: 80px;
        font-family: 'Inter', sans-serif;
    }

    /* Header */
    .m-header {
        background: var(--primary, #2563eb);
        /* Primary blue to match VimesTask aesthetic */
        color: white;
        padding: 40px 20px 20px;
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        border-bottom-left-radius: 24px;
        border-bottom-right-radius: 24px;
    }

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

    .m-avatar {
        width: 50px;
        height: 50px;
        border-radius: 50%;
        border: 2px solid white;
        object-fit: cover;
    }

    .m-user-details {
        display: flex;
        flex-direction: column;
    }

    .m-level {
        background: white;
        color: var(--primary, #2563eb);
        padding: 4px 10px;
        border-radius: 20px;
        font-size: 11px;
        font-weight: 700;
        margin-bottom: 4px;
        display: inline-flex;
        align-items: center;
        gap: 4px;
        width: max-content;
    }

    .m-name {
        font-size: 16px;
        font-weight: 700;
        letter-spacing: 0.5px;
    }

    .m-icon-btn {
        background: white;
        border: none;
        color: #1e293b;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 16px;
    }

    /* Quick Actions */
    .m-quick-actions {
        display: flex;
        gap: 15px;
        padding: 0 20px;
        margin-top: -15px;
    }

    .m-action-card {
        flex: 1;
        background: #fdf5e6;
        /* light orange/yellow background similar to QR cards */
        border-radius: 12px;
        padding: 12px 15px;
        display: flex;
        align-items: center;
        gap: 12px;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
        border: 1px solid #fde047;
        text-align: left;
    }

    .m-action-card:nth-child(2) {
        background: #ecfdf5;
        border-color: #6ee7b7;
    }

    .m-action-icon {
        width: 36px;
        height: 36px;
        border-radius: 8px;
        background: white;
        color: #2563eb;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 18px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    }

    .m-action-card:nth-child(2) .m-action-icon {
        color: #10b981;
    }

    .m-action-text {
        display: flex;
        flex-direction: column;
    }

    .m-action-text span {
        font-weight: 600;
        font-size: 13px;
        color: #1e293b;
    }

    .m-action-text small {
        font-size: 11px;
        color: #64748b;
    }

    /* General Section */
    .m-section {
        margin: 24px 0;
        padding: 0 20px;
    }

    .m-section-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 15px;
    }

    .m-section-title {
        font-size: 16px;
        font-weight: 700;
        color: #1e293b;
        margin: 0 0 15px 0;
    }

    /* Service Groups */
    .m-services-scroll {
        display: flex;
        overflow-x: auto;
        gap: 20px;
        padding-bottom: 10px;
        scrollbar-width: none;
    }

    .m-services-scroll::-webkit-scrollbar {
        display: none;
    }

    .m-service-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        min-width: 65px;
        text-decoration: none;
        gap: 8px;
        position: relative;
    }

    .m-service-icon {
        width: 55px;
        height: 55px;
        border-radius: 50%;
        color: white;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 22px;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    }

    .bg-red {
        background: #dc2626;
    }

    .bg-blue {
        background: #2563eb;
    }

    .bg-green {
        background: #059669;
    }

    .bg-orange {
        background: #d97706;
    }

    .bg-purple {
        background: #7c3aed;
    }

    .m-service-item span {
        font-size: 12px;
        color: #475569;
        font-weight: 500;
        text-align: center;
        white-space: normal;
        line-height: 1.2;
    }

    /* Banner */
    .m-banner {
        background: var(--primary, #2563eb);
        color: white;
        margin: 0 20px;
        border-radius: 12px;
        padding: 16px;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .m-banner-content {
        display: flex;
        align-items: center;
        gap: 12px;
    }

    .m-banner-content>i {
        font-size: 24px;
        background: rgba(255, 255, 255, 0.2);
        width: 48px;
        height: 48px;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .m-banner-text {
        display: flex;
        flex-direction: column;
    }

    .m-banner-text strong {
        font-size: 15px;
    }

    .m-banner-text span {
        font-size: 12px;
        opacity: 0.9;
    }

    .m-banner-btn {
        background: white;
        color: var(--primary, #2563eb);
        border: none;
        width: 36px;
        height: 36px;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Promo Banner */
    .m-promo {
        margin: 20px;
        border-radius: 16px;
        overflow: hidden;
        position: relative;
        height: 140px;
    }

    .m-promo-overlay {
        position: absolute;
        inset: 0;
        background: linear-gradient(to right, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.2));
        padding: 20px;
        color: white;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: flex-start;
    }

    .m-promo-overlay h3 {
        margin: 0 0 5px 0;
        font-size: 16px;
        color: #fbbf24;
    }

    .m-promo-overlay p {
        margin: 0 0 10px 0;
        font-size: 12px;
        max-width: 70%;
        line-height: 1.4;
    }

    /* Grid Stats */
    .m-link-edit {
        color: #64748b;
        font-size: 13px;
        text-decoration: none;
    }

    .m-utilities-grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 15px;
    }

    .m-utility-item {
        background: white;
        border-radius: 12px;
        padding: 15px 10px;
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
    }

    .m-utility-icon {
        background: #fff1f2;
        width: 44px;
        height: 44px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #e11d48;
        font-size: 18px;
        margin-bottom: 8px;
    }

    .m-utility-item:nth-child(2) .m-utility-icon {
        background: #fef3c7;
        color: #d97706;
    }

    .m-utility-item:nth-child(3) .m-utility-icon {
        background: #ecfdf5;
        color: #059669;
    }

    .m-utility-item span {
        font-size: 12px;
        color: #475569;
        margin-bottom: 5px;
    }

    .m-stat-number {
        font-size: 18px;
        font-weight: 700;
        color: #1e293b;
    }

    /* Bottom Navigation */
    .m-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        display: flex !important;
        /* overrides .mobile-only block */
        justify-content: space-around;
        align-items: center;
        padding: 10px 0 25px;
        /* iOS safe area */
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.06);
        z-index: 1000;
        border-top-left-radius: 20px;
        border-top-right-radius: 20px;
    }

    .m-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        color: #94a3b8;
        text-decoration: none;
        flex: 1;
        position: relative;
    }

    .m-nav-item.active {
        color: var(--primary, #2563eb);
        /* blue active */
    }

    .m-nav-item i {
        font-size: 22px;
    }

    .m-nav-item span {
        font-size: 10px;
        font-weight: 600;
    }

    .m-nav-center {
        flex: 1.2;
    }

    .m-nav-fab {
        background: var(--primary, #2563eb);
        width: 56px;
        height: 56px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        color: white;
        font-size: 26px;
        position: absolute;
        top: -30px;
        left: 50%;
        transform: translateX(-50%);
        box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
        border: 4px solid white;
    }
}

@media (max-width: 768px) {

    /* Hide top header and sidebar natively for dashboard layout */
    header,
    .sidebar {
        display: none !important;
    }

    .main-content.desktop-only {
        display: none !important;
    }

    /* Hide desktop FABs on mobile dashboard */
    #att-fab,
    #ai-widget {
        display: none !important;
    }
}