/* ===== BASE STYLES ===== */
:root {
    --primary: #4F46E5; /* Indigo */
    --primary-light: #818CF8;
    --secondary: #10B981; /* Emerald */
    --background: #F3F4F6;
    --surface: rgba(255, 255, 255, 0.7);
    --surface-border: rgba(255, 255, 255, 0.5);
    --text-main: #1F2937;
    --text-muted: #6B7280;
    
    /* Severity Colors */
    --sev-nhe: #3B82F6;
    --sev-nang: #F59E0B;
    --sev-nghiemtrong: #EF4444;

    --radius-lg: 20px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-image: url('background.png');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
    background-color: var(--background); /* Fallback */
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Background gradient blobs (ẩn đi vì đã có ảnh nền) */
.bg-shape {
    display: none;
}

.shape-1 {
    width: 500px;
    height: 500px;
    background: linear-gradient(135deg, var(--primary-light), #C084FC);
    top: -100px;
    left: -100px;
}

.shape-2 {
    width: 600px;
    height: 600px;
    background: linear-gradient(135deg, #6EE7B7, #3B82F6);
    bottom: -150px;
    right: -100px;
    animation-delay: -5s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(30px, 50px) scale(1.1); }
}

/* ===== LAYOUT ===== */
.app-container {
    display: flex;
    min-height: 100vh;
    padding: 20px;
    gap: 20px;
    max-width: 1600px;
    margin: 0 auto;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: 280px;
    background: var(--surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.05);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), #C084FC);
    border-radius: var(--radius-md);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.3);
}

.logo h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-main);
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
}

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

.nav-item:hover {
    background: rgba(255, 255, 255, 0.5);
    color: var(--primary);
    transform: translateX(5px);
}

.nav-item.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    font-weight: 600;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    margin-top: auto;
}

.avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

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

.user-info .role {
    font-size: 13px;
    color: var(--text-muted);
}

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow: hidden;
}

.top-bar {
    background: var(--surface);
    backdrop-filter: blur(16px);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.05);
}

.top-bar h1 {
    font-size: 24px;
    font-weight: 700;
    background: linear-gradient(to right, var(--primary), #8B5CF6);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.search-bar {
    position: relative;
    width: 300px;
}

.search-bar i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 20px;
}

.search-bar input {
    width: 100%;
    padding: 12px 15px 12px 45px;
    border: 1px solid rgba(255,255,255,0.8);
    border-radius: 30px;
    background: rgba(255,255,255,0.5);
    font-size: 15px;
    outline: none;
    transition: var(--transition);
}

.search-bar input:focus {
    background: white;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.content-wrapper {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 20px;
    /* Custom Scrollbar */
}

.content-wrapper::-webkit-scrollbar {
    width: 6px;
}
.content-wrapper::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.2);
    border-radius: 10px;
}

/* Sections */
.tab-content {
    display: none;
    animation: fadeIn 0.4s ease-out;
}

.tab-content.active {
    display: block;
}

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

/* Glass Panels & Cards */
.glass-panel {
    background: var(--surface);
    backdrop-filter: blur(16px);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
}

.glass-card {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.8);
    border-radius: var(--radius-md);
    padding: 25px;
    transition: var(--transition);
    box-shadow: 0 4px 15px rgba(0,0,0,0.02);
}

.glass-card:hover {
    transform: translateY(-5px);
    background: white;
    box-shadow: 0 15px 30px rgba(0,0,0,0.08);
}

/* Workflow Tab */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.workflow-card {
    text-align: center;
}

.workflow-card .card-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--secondary), #34D399);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    color: white;
    margin: 0 auto 20px;
    box-shadow: 0 10px 20px rgba(16, 185, 129, 0.3);
}

.workflow-card h3 {
    margin-bottom: 10px;
    font-size: 18px;
    color: var(--text-main);
}

.workflow-card p {
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.5;
}

/* Equipment Tab */
.eq-card {
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.eq-img {
    width: 100%;
    height: 180px;
    object-fit: cover;
}

.eq-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.eq-content h3 {
    margin-bottom: 8px;
    font-size: 18px;
}

.eq-content p {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 20px;
    flex: 1;
}

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

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #8B5CF6);
    color: white;
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.4);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.6);
    transform: translateY(-2px);
}

/* Incident Form */
.form-container {
    max-width: 800px;
    margin: 0 auto;
}

.form-container h2 {
    margin-bottom: 5px;
}

.form-container .subtitle {
    color: var(--text-muted);
    margin-bottom: 25px;
}

#incident-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

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

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-main);
}

.form-group input, .form-group select, .form-group textarea {
    padding: 12px 15px;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.7);
    font-size: 15px;
    outline: none;
    transition: var(--transition);
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}

/* Defects Tab */
.filters-container {
    display: flex;
    gap: 20px;
    align-items: flex-end;
    margin-bottom: 25px;
    padding: 15px 25px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.filter-group select {
    padding: 10px 35px 10px 15px;
    border-radius: 20px;
    border: 1px solid rgba(0,0,0,0.1);
    background: white;
    outline: none;
    font-weight: 500;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%231F2937%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 12px top 50%;
    background-size: 10px auto;
}

.defect-stats {
    margin-left: auto;
    font-weight: 600;
    color: var(--primary);
    background: rgba(79,70,229,0.1);
    padding: 8px 16px;
    border-radius: 20px;
}

.defects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.defect-card {
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.defect-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

.defect-card.sev-nhe::before { background-color: var(--sev-nhe); }
.defect-card.sev-nang::before { background-color: var(--sev-nang); }
.defect-card.sev-nghiemtrong::before { background-color: var(--sev-nghiemtrong); }

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

.defect-code {
    font-weight: 700;
    font-size: 20px;
    color: var(--primary);
}

.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge.category {
    background: rgba(0,0,0,0.05);
    color: var(--text-muted);
}

.badge.severity {
    color: white;
}
.badge.severity.sev-nhe { background: var(--sev-nhe); }
.badge.severity.sev-nang { background: var(--sev-nang); }
.badge.severity.sev-nghiemtrong { background: var(--sev-nghiemtrong); }

.defect-card h3 {
    font-size: 16px;
    margin-bottom: 10px;
    line-height: 1.4;
}

.defect-card p {
    font-size: 13px;
    color: var(--text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 15px;
    flex: 1;
}

.defect-card .btn {
    width: 100%;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.4);
    backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white !important;
    width: 100%;
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    padding: 40px;
    animation: modalSlideIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalSlideIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.close-modal {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 28px;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.close-modal:hover {
    color: var(--primary);
    transform: rotate(90deg);
}

.modal-header {
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(0,0,0,0.1);
}

.modal-header .badge {
    margin-right: 8px;
    margin-bottom: 10px;
    display: inline-block;
}

.modal-header h2 {
    font-size: 24px;
    color: var(--primary);
}

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

.info-group h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    color: var(--text-main);
    margin-bottom: 8px;
}

.info-group h4 i {
    color: var(--primary);
    font-size: 20px;
}

.info-group p {
    font-size: 14.5px;
    color: var(--text-muted);
    line-height: 1.6;
    background: rgba(0,0,0,0.02);
    padding: 15px;
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--primary-light);
}

/* Responsive */
@media (max-width: 1024px) {
    .app-container {
        flex-direction: column;
        padding: 10px;
    }
    .sidebar {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        padding: 15px;
        gap: 0;
    }
    .logo {
        margin-bottom: 0;
        margin-right: 0;
        flex: 1;
        order: 1;
    }
    .user-profile {
        margin-left: auto;
        padding-top: 0;
        border-top: none;
        border-left: none;
        padding-left: 0;
        order: 2;
        margin-top: 0;
    }
    .nav-menu {
        flex-direction: row;
        width: 100%;
        justify-content: space-between;
        gap: 0;
        margin-top: 15px;
        order: 3;
        overflow-x: auto;
        -ms-overflow-style: none;
        scrollbar-width: none;
    }
    .nav-menu::-webkit-scrollbar {
        display: none;
    }
    .nav-item {
        padding: 10px;
        flex: 1;
        display: flex;
        justify-content: center;
        min-width: 45px;
    }
    .nav-item span {
        display: none;
    }
    .nav-item i {
        font-size: 22px;
    }
    .top-bar {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
        padding: 15px;
    }
    .search-bar {
        width: 100%;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* ===== CHATBOT STYLES ===== */
.chatbot-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 140px); /* Adjust based on your header/padding */
    padding: 0;
    overflow: hidden;
}

.chatbot-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--surface-border);
    background: rgba(255, 255, 255, 0.4);
}

.chatbot-title {
    display: flex;
    align-items: center;
    gap: 15px;
}

.chatbot-title i {
    font-size: 32px;
    color: var(--primary);
    background: white;
    padding: 10px;
    border-radius: 50%;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.chatbot-config {
    display: flex;
    gap: 10px;
    align-items: center;
}

.chatbot-config input {
    padding: 8px 15px;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 20px;
    font-size: 13px;
    outline: none;
    width: 250px;
}

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

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

.message-content {
    padding: 12px 18px;
    border-radius: 18px;
    font-size: 14.5px;
    line-height: 1.5;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

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

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

.ai-message {
    align-self: flex-start;
}

.ai-message .message-content {
    background: white;
    color: var(--text-main);
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(0,0,0,0.05);
}

.chat-input-area {
    display: flex;
    gap: 10px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.4);
    border-top: 1px solid var(--surface-border);
    align-items: flex-end;
}

.chat-input-area textarea {
    flex: 1;
    padding: 12px 20px;
    border-radius: 24px;
    border: 1px solid rgba(0,0,0,0.1);
    outline: none;
    resize: none;
    font-size: 15px;
    font-family: 'Outfit', sans-serif;
    background: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.02);
    min-height: 45px;
    max-height: 120px;
}

.chat-input-area textarea:focus {
    border-color: var(--primary);
}

.btn-icon {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon i {
    font-size: 20px;
    margin-left: 3px;
}

/* Loading Dots */
.typing-indicator {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    padding: 8px 12px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--primary-light);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Responsive adjust for Chatbot */
@media (max-width: 768px) {
    .chatbot-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    .chatbot-config {
        width: 100%;
    }
    .chatbot-config input {
        flex: 1;
    }
    .message {
        max-width: 95%;
    }
}

/* User Profile & Logout */
.user-profile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 20px;
    border-top: 1px solid var(--surface-border);
    margin-top: auto;
}

.user-profile .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 12px;
}

.user-profile .user-info {
    flex: 1;
}

.user-profile .name {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-main);
}

.user-profile .role {
    font-size: 13px;
    color: var(--text-muted);
}

.logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: 22px;
    text-decoration: none;
    transition: var(--transition);
    background: transparent;
}

.logout-btn:hover {
    color: #EF4444; /* Red color on hover */
    background: rgba(239, 68, 68, 0.1);
}
