/* ========================================================= */
/* 3T CONSTRUCTION CRM - STYLESHEET                          */
/* ========================================================= */

/* STREAMING_CHUNK:Thiết lập biến màu và font chữ... */
:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --bg-gradient: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    --error-gradient: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    --warning-bg: linear-gradient(135deg, #fff9e6 0%, #fff5d6 100%);

    --font-main: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-heading: 'Times New Roman', Times, serif;

    /* Biến Dashboard mới */
    --nav-height: 60px;
    --sidebar-width: 280px;
    --primary-dark: #0f172a;
    --accent-blue: #3b82f6;
    --sidebar-bg: #111827; /* Darker for better contrast */
}

body {
    font-family: var(--font-main);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ========================================================= */
/* 1. MÀN HÌNH ĐĂNG NHẬP (LOGIN VIEW)                        */
/* ========================================================= */

/* STREAMING_CHUNK:Hiệu ứng Background Float... */
#login-view {
    background: var(--bg-gradient);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

/* Bong bóng nổi trang trí nền */
#login-view::before,
#login-view::after {
    content: '';
    position: absolute;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 50%;
    filter: blur(2px);
    z-index: 0;
}

#login-view::before {
    width: 500px;
    height: 500px;
    top: -200px;
    right: -150px;
    animation: floatUp 8s ease-in-out infinite;
}

#login-view::after {
    width: 350px;
    height: 350px;
    bottom: -100px;
    left: -150px;
    animation: floatDown 10s ease-in-out infinite;
}

@keyframes floatUp {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-30px) scale(1.05); }
}

@keyframes floatDown {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(30px) scale(0.95); }
}

/* STREAMING_CHUNK:Giao diện Form Đăng nhập (Glassmorphism)... */
.login-container {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 440px;
    animation: slideUpFade 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideUpFade {
    from { opacity: 0; transform: translateY(40px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-card {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.card-header-custom {
    background: var(--bg-gradient);
    padding: 40px 30px;
    text-align: center;
    position: relative;
}

.logo-wrapper {
    width: 90px;
    height: 90px;
    margin: 0 auto 20px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    border: 4px solid rgba(255, 255, 255, 0.3);
    animation: pulseGlow 2.5s ease-in-out infinite;
}

@keyframes pulseGlow {
    0%, 100% { transform: scale(1); box-shadow: 0 10px 25px rgba(0,0,0,0.2), 0 0 0 0 rgba(255,255,255,0.4); }
    50% { transform: scale(1.03); box-shadow: 0 15px 35px rgba(0,0,0,0.3), 0 0 0 10px rgba(255,255,255,0); }
}

.brand-title {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: bold;
    color: white;
    text-transform: uppercase;
    margin-bottom: 5px;
    letter-spacing: 2px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.sub-title {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.85);
    font-weight: 500;
    letter-spacing: 0.5px;
}

/* STREAMING_CHUNK:Các Input và Nút bấm... */
.card-body-custom {
    padding: 35px 35px 40px;
}

.form-group-custom {
    margin-bottom: 22px;
}

.form-label-custom {
    font-weight: 600;
    font-size: 0.9rem;
    color: #4a5568;
    margin-bottom: 8px;
    display: block;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-wrapper {
    position: relative;
}

.input-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary-color);
    font-size: 1.1rem;
    z-index: 2;
    transition: color 0.3s ease;
}

.form-control-custom {
    padding: 14px 20px 14px 50px;
    font-size: 1rem;
    border-radius: 12px;
    border: 2px solid #e2e8f0;
    transition: all 0.3s ease;
    background: #f8fafc;
    width: 100%;
    color: #2d3748;
}

.form-control-custom::placeholder {
    color: #a0aec0;
}

.form-control-custom:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15);
    background: white;
    outline: none;
}

.form-control-custom:focus ~ .input-icon {
    color: var(--secondary-color);
}

.password-toggle {
    position: absolute;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: #a0aec0;
    font-size: 1.1rem;
    z-index: 2;
    transition: color 0.2s;
    padding: 5px; /* Tăng vùng click */
}

.password-toggle:hover {
    color: var(--primary-color);
}

/* STREAMING_CHUNK:Thành phần nút bấm và Alert lỗi... */
.btn-login {
    background: var(--bg-gradient);
    color: white;
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 12px;
    font-weight: bold;
    font-size: 1.05rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.35);
    margin-top: 15px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-login:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 25px rgba(102, 126, 234, 0.5);
    color: white;
}

.btn-login:active {
    transform: translateY(0);
}

.btn-login.loading {
    pointer-events: none;
    opacity: 0.8;
}

.btn-login.loading::after {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
    right: 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.alert-custom {
    background: var(--error-gradient);
    color: white;
    border-radius: 12px;
    padding: 14px 20px;
    margin-bottom: 25px;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 8px 20px rgba(255, 107, 107, 0.3);
    animation: errorShake 0.5s cubic-bezier(.36,.07,.19,.97) both;
    display: none; /* Mặc định ẩn */
}

@keyframes errorShake {
    10%, 90% { transform: translate3d(-2px, 0, 0); }
    20%, 80% { transform: translate3d(3px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-5px, 0, 0); }
    40%, 60% { transform: translate3d(5px, 0, 0); }
}

/* Lắc form đăng nhập (dùng class shake trên thẻ chứa) */
.shake {
    animation: errorShake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

/* STREAMING_CHUNK:Phần hỗ trợ và Footer... */
.divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 30px 0 20px;
    color: #a0aec0;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.divider::before, .divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid #e2e8f0;
}

.divider span {
    padding: 0 15px;
}

.support-box {
    background: var(--warning-bg);
    border-left: 4px solid #f59e0b;
    border-radius: 12px;
    padding: 18px;
    transition: transform 0.3s ease;
}

.support-box:hover {
    transform: translateX(5px);
}

.support-title {
    font-weight: bold;
    color: #92400e;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
}

.support-text {
    color: #b45309;
    font-size: 0.85rem;
    line-height: 1.5;
    margin-bottom: 12px;
}

.contact-info {
    background: rgba(255, 255, 255, 0.7);
    padding: 10px 15px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.contact-info i {
    color: #10b981;
    font-size: 1.4rem;
}

.contact-number {
    font-weight: 800;
    color: #1f2937;
    font-size: 1.05rem;
    letter-spacing: 0.5px;
}

.footer-text {
    text-align: center;
    margin-top: 25px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.85rem;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3);
    line-height: 1.6;
}

.footer-text .copyright {
    font-weight: bold;
    letter-spacing: 0.5px;
}

/* STREAMING_CHUNK:Quản lý Trạng thái SPA (Ẩn/Hiện)... */
.fade-transition {
    transition: opacity 0.5s ease-in-out, visibility 0.5s ease-in-out;
}

.hidden-view {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none;
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: -1;
}

/* Ngăn lỗi cuộn khi ẩn hiện giao diện */
#crm-view {
    position: relative;
    z-index: 20;
}

/* Fix CSS cho Scrollbar của phần Dashboard Tailwind */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Reponsive cho điện thoại */
@media (max-width: 480px) {
    .login-card {
        border-radius: 20px;
    }
    .card-header-custom {
        padding: 30px 20px;
    }
    .card-body-custom {
        padding: 25px 20px 30px;
    }
    .brand-title {
        font-size: 1.5rem;
    }
}

/* ========================================================= */
/* 2. MÀN HÌNH DASHBOARD (DASHBOARD VIEW)                    */
/* ========================================================= */

/* STREAMING_CHUNK:Cấu trúc Layout Dashboard... */

/* Đổi scope của body css thành scope riêng để không ảnh hưởng trang Login */
body.dashboard-mode {
    background-color: #f1f5f9 !important;
    font-family: "Times New Roman", Times, serif;
    color: #1e293b;
    padding-top: var(--nav-height); /* Dành không gian cho header fixed */
    min-height: 100vh;
}

/* Container của toàn bộ Layout (Sidebar + Main) */
.app-layout {
    display: flex;
    min-height: calc(100vh - var(--nav-height));
}

/* Căn lề cho phần Main khi có Sidebar */
.dashboard-main {
    padding: 20px 25px;
    max-width: 1600px;
    margin: 0 auto;
    flex-grow: 1;
    /* Đẩy sang phải để nhường chỗ cho Sidebar trên PC */
    margin-left: var(--sidebar-width);
    transition: all 0.3s ease;
}

/* STREAMING_CHUNK:Responsive & Mobile Sidebar... */
/*
MOBILE FIX:
Khi ở màn hình nhỏ (< 992px), Main container sẽ không bị đẩy sang phải nữa
Sidebar sẽ tự động ẩn đi và Main chiếm 100% width
*/
@media (max-width: 991.98px) {
    .dashboard-main {
        margin-left: 0;
        width: 100%;
        padding: 15px;
    }
}

/* Lớp phủ (Overlay) khi mở Sidebar trên Mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    z-index: 2060;
}
body.sidebar-open .sidebar-overlay { display: block; }
body.sidebar-open .sidebar {
    transform: translateX(0) !important;
}

/* STREAMING_CHUNK:Thành phần Dashboard Header & Cards... */
.dashboard-header {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 30px;
    color: white;
    border-bottom: 4px solid #3b82f6;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}

.header-actions-wrapper {
    width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 10px;
}
.header-actions-wrapper::-webkit-scrollbar { display: none; }
.header-actions {
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
    width: max-content;
}

.btn-quick {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-weight: 600;
    padding: 10px 18px;
    border-radius: 12px;
    transition: 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    cursor: pointer;
}
.btn-quick:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
    color: white;
}
.btn-it { border-left: 4px solid #8b5cf6 !important; }

.stat-card {
    background: white;
    border-radius: 16px;
    padding: 25px;
    border: 1px solid #e2e8f0;
    height: 100%;
    transition: 0.3s;
    position: relative;
    overflow: hidden;
}
.alert-card {
    border-radius: 16px;
    color: white;
    padding: 25px;
    height: 100%;
    cursor: pointer;
    transition: 0.3s;
    position: relative;
    overflow: hidden;
}
.alert-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.2);
}
.alert-card i.bg-icon {
    position: absolute;
    right: -10px;
    bottom: -10px;
    font-size: 5rem;
    opacity: 0.15;
    transform: rotate(-15deg);
}

.val-large {
    font-size: 2.8rem;
    font-weight: 900;
    letter-spacing: -2px;
    line-height: 1;
}
.label-small {
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    color: #64748b;
    letter-spacing: 0.5px;
}

/* STREAMING_CHUNK:Thành phần AI Chat Popup... */
/* AI UI Popup */
.ai-chat-popup {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 420px;
    height: 600px;
    background: white;
    border-radius: 24px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e2e8f0;
}
.chat-header {
    background: #0f172a;
    color: white;
    padding: 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #3b82f6;
}
.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8fafc;
}
.msg {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    margin-bottom: 12px;
    font-size: 14px;
}
.msg-ai {
    background: white;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}
.msg-user {
    background: #0f172a;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    margin-left: auto;
}

.floating-ai-btn {
    position: fixed;
    bottom: 25px;
    right: 25px;
    width: 75px;
    height: 75px;
    background: #0f172a;
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    cursor: pointer;
    z-index: 9999;
    border: 3px solid #3b82f6;
    transition: 0.3s;
}
.floating-ai-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 15px 40px rgba(59, 130, 246, 0.5);
}