/* EZChungCu System Styling - Premium Vanilla CSS */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #eff6ff;
    --success: #16a34a;
    --success-light: #dcfce7;
    --warning: #ca8a04;
    --warning-light: #fef9c3;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --dark: #0f172a;
    --dark-card: #1e293b;
    --light: #f8fafc;
    --border: #e2e8f0;
    --text-muted: #64748b;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
}

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 
}

body { 
    background-color: var(--light); 
    color: var(--dark); 
    height: 100vh; 
    display: flex; 
    flex-direction: column; 
    overflow: hidden;
    font-size: 13.5px;
}

/* Scrollbar Style */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* 1. MÀN HÌNH ĐĂNG NHẬP (SLEEK GRADIENT MOCKUP) */
#login-screen {
    display: flex; 
    align-items: center; 
    justify-content: center; 
    height: 100vh; 
    background: radial-gradient(circle at top left, #1e293b, #0f172a);
    padding: 1rem; 
    position: fixed; 
    inset: 0; 
    z-index: 9999;
}
.login-box { 
    background: rgba(255, 255, 255, 0.95); 
    backdrop-filter: blur(10px);
    padding: 2.5rem 2rem; 
    border-radius: var(--radius-lg); 
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5); 
    width: 100%; 
    max-width: 420px; 
    border: 1px solid rgba(255,255,255,0.2);
}
.login-header { 
    text-align: center; 
    margin-bottom: 2rem; 
}
.login-header h1 { 
    color: var(--primary); 
    font-size: 2.2rem; 
    font-weight: 800; 
    letter-spacing: -1px; 
}
.login-header span { 
    color: #38bdf8; 
}
.login-header p { 
    color: var(--text-muted); 
    font-size: 0.85rem; 
    margin-top: 0.5rem; 
}
.form-group { 
    margin-bottom: 1.25rem; 
}
.form-group label { 
    display: block; 
    margin-bottom: 0.4rem; 
    font-weight: 600; 
    font-size: 13.5px; 
    color: #475569; 
}
.form-control { 
    width: 100%; 
    padding: 0.75rem 0.85rem; 
    border: 1px solid var(--border); 
    border-radius: var(--radius-md); 
    font-size: 13.5px; 
    transition: all 0.2s ease; 
}
.form-control:focus { 
    outline: none; 
    border-color: var(--primary); 
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.btn-login { 
    width: 100%; 
    padding: 0.8rem; 
    background: var(--primary); 
    border: none; 
    color: white; 
    font-weight: 700; 
    border-radius: var(--radius-md); 
    font-size: 1rem; 
    cursor: pointer; 
    transition: all 0.2s; 
    margin-top: 1rem; 
}
.btn-login:hover { 
    background: var(--primary-dark); 
    transform: translateY(-1px);
}
.login-error { 
    color: var(--danger); 
    font-size: 0.85rem; 
    font-weight: 600; 
    text-align: center; 
    margin-top: 0.75rem; 
    display: none; 
}

/* 2. CHƯƠNG TRÌNH CHÍNH LAYOUT (PC VIEW) */
#main-dashboard { 
    display: none; 
    width: 100%; 
    height: 100vh; 
}
.sidebar { 
    width: 260px; 
    background-color: var(--dark); 
    color: #94a3b8; 
    padding: 1.5rem; 
    display: flex; 
    flex-direction: column; 
    justify-content: space-between; 
    flex-shrink: 0; 
}
.logo-container { 
    margin-bottom: 2.5rem; 
}
.brand { 
    color: white; 
    font-size: 1.5rem; 
    font-weight: 800; 
    display: flex; 
    align-items: center; 
    gap: 0.5rem; 
}
.brand span { 
    color: #38bdf8; 
}
.dev-tag { 
    font-size: 0.65rem; 
    color: #64748b; 
    letter-spacing: 0.5px; 
    text-transform: uppercase; 
    font-weight: bold; 
    margin-top: 0.25rem; 
    padding-left: 2.25rem; 
}

.menu-list { 
    list-style: none; 
}
.menu-item { 
    display: flex; 
    align-items: center; 
    gap: 0.75rem; 
    padding: 0.75rem 1rem; 
    border-radius: var(--radius-sm); 
    margin-bottom: 0.5rem; 
    cursor: pointer; 
    transition: all 0.2s; 
    font-weight: 500; 
}
.menu-item:hover, .menu-item.active { 
    background-color: var(--dark-card); 
    color: white; 
}
.sidebar-scrollable-area::-webkit-scrollbar {
    width: 4px;
}
.sidebar-scrollable-area::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-scrollable-area::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 4px;
}
.sidebar-scrollable-area::-webkit-scrollbar-thumb:hover {
    background: #475569;
}
.user-info { 
    display: flex; 
    align-items: center; 
    gap: 0.75rem; 
    padding-top: 1rem; 
    border-top: 1px solid #334155; 
}
.user-avatar { 
    width: 40px; 
    height: 40px; 
    background: var(--primary); 
    border-radius: 50%; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    color: white; 
    font-weight: bold; 
}

.content-area { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    min-width: 0; 
    height: 100vh; 
    overflow: hidden; 
}
.top-bar { 
    height: 60px; 
    background: white; 
    border-bottom: 1px solid var(--border); 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    padding: 0 1.5rem; 
    flex-shrink: 0; 
}
.page-title { 
    font-size: 13.5px; 
    font-weight: 700; 
}
.main-content { 
    padding: 1.5rem; 
    overflow-y: auto; 
    flex: 1; 
    -webkit-overflow-scrolling: touch; 
}

/* Stats Cards Grid */
.stats-grid { 
    display: grid; 
    grid-template-columns: repeat(5, 1fr); 
    gap: 1rem; 
    margin-bottom: 1.5rem; 
}
.stat-card { 
    background: white; 
    padding: 1.25rem 1rem; 
    border-radius: var(--radius-md); 
    border: 1px solid var(--border); 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}
.stat-val { 
    font-size: 13.5px; 
    font-weight: 700; 
    margin-top: 0.25rem; 
}
.stat-label { 
    font-size: 13.5px; 
    color: var(--text-muted); 
    font-weight: 600; 
}
.icon-wrapper { 
    width: 40px; 
    height: 40px; 
    border-radius: 50%; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    flex-shrink: 0; 
}

/* Card layout */
.card { 
    background: white; 
    border-radius: var(--radius-md); 
    border: 1px solid var(--border); 
    margin-bottom: 1.5rem; 
    box-shadow: 0 1px 3px rgba(0,0,0,0.05); 
    overflow: hidden; 
}
.card-header { 
    padding: 1rem; 
    border-bottom: 1px solid var(--border); 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    background: #fff; 
    gap: 0.75rem; 
}
.card-title { 
    font-weight: 700; 
    font-size: 13.5px; 
    display: flex; 
    align-items: center; 
    gap: 0.5rem; 
}

/* Table styling */
.table-responsive { 
    width: 100%; 
    overflow-x: auto; 
    display: block; 
}
.data-table { 
    width: 100%; 
    border-collapse: collapse; 
    text-align: left; 
}
.data-table th { 
    background: #f8fafc; 
    padding: 0.75rem 1rem; 
    font-size: 13.5px; 
    font-weight: 600; 
    color: #475569; 
    border-bottom: 1px solid var(--border); 
}
.data-table td { 
    padding: 0.85rem 1rem; 
    border-bottom: 1px solid var(--border); 
    font-size: 13.5px; 
    vertical-align: middle; 
}

/* Registered Service Styles */
.service-row { 
    background-color: #f8fafc; 
}
.service-list-container { 
    display: flex; 
    flex-direction: column; 
    gap: 0.4rem; 
    padding: 0.4rem 0; 
}
.service-item-inline { 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    background: white; 
    padding: 0.5rem 0.75rem; 
    border: 1px solid #e2e8f0; 
    border-radius: var(--radius-sm); 
    font-size: 0.78rem;
}

/* Calculations box */
.billing-summary-box { 
    background: var(--primary-light); 
    border: 1px dashed var(--primary); 
    padding: 0.75rem; 
    border-radius: var(--radius-sm); 
    margin-top: 0.5rem; 
    display: grid; 
    grid-template-columns: repeat(3, 1fr); 
    gap: 0.75rem; 
    text-align: center; 
}
.billing-summary-box div { 
    border-right: 1px solid #dbeafe; 
}
.billing-summary-box div:last-child { 
    border-right: none; 
}
.billing-summary-box span { 
    font-size: 0.72rem; 
    color: #475569; 
    display: block; 
}
.billing-summary-box strong { 
    font-size: 0.85rem; 
    color: var(--dark); 
    font-weight: 700; 
    margin-top: 0.15rem; 
    display: block; 
}

/* Badges */
.badge { 
    padding: 0.2rem 0.4rem; 
    border-radius: 4px; 
    font-size: 0.72rem; 
    font-weight: 600; 
    display: inline-block; 
    white-space: nowrap; 
}
.badge-success { background: var(--success-light); color: #15803d; }
.badge-warning { background: var(--warning-light); color: #a16207; }
.badge-danger { background: var(--danger-light); color: #b91c1c; }
.badge-info { background: var(--primary-light); color: #0369a1; }

.tab-content { 
    display: none; 
}
.tab-content.active { 
    display: block; 
}
.btn-sm { 
    padding: 0.35rem 0.6rem; 
    font-size: 0.75rem; 
    font-weight: 600; 
    border-radius: 4px; 
    cursor: pointer; 
    border: none; 
    display: inline-flex; 
    align-items: center; 
    gap: 0.2rem; 
    white-space: nowrap; 
    transition: all 0.2s; 
}
.btn-outline { 
    background: white; 
    border: 1px solid var(--border); 
    color: var(--dark); 
}
.btn-outline:hover { 
    background: #f1f5f9; 
}
.btn-primary-sm { 
    background: var(--primary); 
    color: white; 
}
.btn-primary-sm:hover { 
    background: var(--primary-dark); 
}
.btn-success-sm { 
    background: var(--success); 
    color: white; 
}
.btn-success-sm:hover { 
    background: #15803d; 
}

/* Mobile View Cards */
.mobile-cards-view { 
    display: none; 
    flex-direction: column; 
    gap: 1rem; 
    padding: 0.5rem; 
}
.m-card { 
    background: white; 
    border: 1px solid var(--border); 
    border-radius: var(--radius-md); 
    padding: 1rem; 
    box-shadow: 0 1px 2px rgba(0,0,0,0.05); 
}
.m-card-title { 
    font-weight: 700; 
    font-size: 1rem; 
    color: var(--primary); 
    margin-bottom: 0.5rem; 
    border-bottom: 1px solid var(--border); 
    padding-bottom: 0.4rem; 
    display: flex; 
    justify-content: space-between; 
}
.m-data-line { 
    font-size: 0.85rem; 
    margin-bottom: 0.35rem; 
    display: flex; 
    justify-content: space-between; 
}
.m-data-line span { 
    color: var(--text-muted); 
    font-weight: 500; 
}
.m-sub-title { 
    font-weight: 600; 
    font-size: 0.8rem; 
    text-transform: uppercase; 
    color: #475569; 
    margin: 0.75rem 0 0.35rem 0; 
}

/* 3. MODAL POPUPS (GLASSMORPHISM OVERLAYS) */
.modal { 
    display: none; 
    position: fixed; 
    inset: 0; 
    background: rgba(15, 23, 42, 0.4); 
    backdrop-filter: blur(4px); 
    align-items: center; 
    justify-content: center; 
    z-index: 10000; 
    padding: 1rem; 
}
.modal-content { 
    background: white; 
    border-radius: var(--radius-lg); 
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04); 
    width: 100%; 
    max-width: 500px; 
    overflow: hidden; 
    animation: zoomIn 0.2s cubic-bezier(0.16, 1, 0.3, 1); 
}
.modal-header { 
    padding: 1.25rem; 
    border-bottom: 1px solid var(--border); 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    background: #f8fafc; 
}
.modal-body { 
    padding: 1.5rem; 
}
.modal-footer { 
    padding: 1rem; 
    border-top: 1px solid var(--border); 
    display: flex; 
    justify-content: flex-end; 
    gap: 0.5rem; 
    background: #f8fafc; 
}
.form-select { 
    width: 100%; 
    padding: 0.55rem 0.75rem; 
    border: 1px solid var(--border); 
    border-radius: var(--radius-sm); 
    font-size: 0.9rem;
}
.form-select:focus {
    outline: none;
    border-color: var(--primary);
}

@keyframes zoomIn {
    from { transform: scale(0.96); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* RESPONSIVE LAYOUT - RESPONSIVE MOBILE VIEW TUYỆT ĐỐI */
@media (max-width: 768px) {
    body {
        height: auto !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
    }

    #main-dashboard { 
        grid-template-columns: 1fr; 
        display: flex; 
        flex-direction: column; 
        height: auto !important;
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }
    
    .content-area {
        flex: none !important;
        height: auto !important;
        overflow: visible !important;
    }
    
    .main-content {
        height: auto !important;
        overflow: visible !important;
    }
    
    .sidebar { 
        width: 100%; 
        height: auto; 
        padding: 0.75rem; 
        border-bottom: 1px solid var(--border); 
        background-color: var(--dark); 
        flex-direction: column; 
        gap: 0.5rem; 
    }
    .logo-container { 
        margin-bottom: 0; 
        display: flex; 
        justify-content: space-between; 
        align-items: center; 
        width: 100%; 
    }
    .brand { 
        font-size: 1.2rem; 
    }
    .dev-tag { 
        padding-left: 0; 
        margin-top: 0; 
        font-size: 0.55rem; 
    }
    .user-info { 
        display: none; 
    }

    .menu-list { 
        display: flex; 
        overflow-x: auto; 
        gap: 0.35rem; 
        width: 100%; 
        -webkit-overflow-scrolling: touch; 
    }
    .menu-list::-webkit-scrollbar { 
        display: none; 
    }
    .menu-item { 
        margin-bottom: 0; 
        white-space: nowrap; 
        padding: 0.4rem 0.65rem; 
        font-size: 0.8rem; 
        border-radius: 4px; 
    }
    
    .top-bar { 
        padding: 0 1rem; 
        height: 45px; 
    }
    .top-bar div:last-child { 
        display: none; 
    }
    .page-title { 
        font-size: 1rem; 
    }
    .main-content { 
        padding: 0.75rem; 
    }
    
    .stats-grid { 
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); 
        gap: 0.5rem; 
        margin-bottom: 1rem; 
    }
    .stat-card { 
        padding: 0.75rem; 
    }
    .stat-val { 
        font-size: 13.5px; 
    }
    .icon-wrapper { 
        width: 32px; 
        height: 32px; 
    }
    .icon-wrapper svg { 
        width: 14px; 
        height: 14px; 
    }

    .card-header { 
        padding: 0.75rem; 
        flex-direction: column; 
        align-items: flex-start; 
        gap: 0.5rem; 
    }
    
    /* Hide tabular data layout and show modular responsive cards */
    .table-responsive { 
        display: none !important; 
    }
    .card {
        max-width: 100% !important;
        overflow: hidden !important;
    }
    .matrix-table-container {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
    }
    .matrix-table-container table {
        min-width: unset !important;
        width: 100% !important;
    }
    .matrix-table-container th {
        font-size: 10px !important;
        padding: 0.4rem 0.2rem !important;
    }
    .matrix-table-container td {
        font-size: 11px !important;
        padding: 0.4rem 0.2rem !important;
    }
    .mobile-cards-view { 
        display: flex !important; 
    }
    
    .billing-summary-box { 
        grid-template-columns: 1fr; 
        gap: 0.35rem; 
        text-align: left; 
    }
    .billing-summary-box div { 
        border-right: none; 
        border-bottom: 1px dashed #dbeafe; 
        padding-bottom: 0.35rem; 
    }
    .billing-summary-box div:last-child { 
        border-bottom: none; 
        padding-bottom: 0; 
    }

    /* Mobile specific form & modal layouts */
    .filter-bar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.5rem !important;
    }
    .filter-bar input, .filter-bar select, .filter-bar button {
        max-width: 100% !important;
        width: 100% !important;
    }
    .card-header > div {
        width: 100% !important;
        display: flex;
        gap: 0.5rem;
    }
    .card-header > div > select, .card-header > div > input, .card-header > div > button {
        flex: 1;
        width: 100% !important;
    }
    .modal-content {
        max-width: 100% !important;
        margin: 0 auto;
        border-radius: var(--radius-md) !important;
    }
    .modal-body {
        padding: 1rem !important;
        max-height: 70vh;
        overflow-y: auto;
    }
    .modal-footer {
        padding: 0.75rem !important;
        flex-direction: column-reverse;
        gap: 0.5rem !important;
    }
    .modal-footer button {
        width: 100%;
        justify-content: center;
        padding: 0.6rem !important;
    }
}

/* Card grid styles for Apartments page */
.apartment-card-grid {
    background: white;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.apartment-card-grid:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(37, 99, 235, 0.08);
    border-color: var(--primary);
    background: #fdfdfd;
}
.floor-section {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}
.floor-title-header {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.dropdown-item:hover {
    background: #f1f5f9;
    color: var(--primary) !important;
}

/* Submenu Styling */
.menu-parent {
    cursor: pointer;
}
.chevron-icon {
    transition: transform 0.2s ease-in-out;
}
.submenu-list .menu-item {
    transition: all 0.2s ease;
}

/* Mobile Submenu Adaptation */
@media (max-width: 768px) {
    #menu-finance-parent {
        display: none !important;
    }
    .submenu-list {
        display: contents !important;
    }
}

/* Floor Tab Buttons */
.floor-tab-btn {
    padding: 0.75rem 1rem !important;
    border-radius: 10px !important;
    text-align: left !important;
    cursor: pointer !important;
    background: transparent !important;
    border: 1px solid transparent !important;
    font-size: 0.82rem !important;
    font-weight: 600 !important;
    color: #64748b !important;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    width: 100% !important;
}
.floor-tab-btn:hover {
    background: #eff6ff !important;
    color: var(--primary) !important;
}
.floor-tab-btn.active {
    background: linear-gradient(135deg, var(--primary) 0%, #1d4ed8 100%) !important;
    color: white !important;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.18) !important;
}

/* Layout classes for apartments grid overview */
.apartments-container {
    display: flex;
    gap: 1.25rem;
    min-height: 550px;
}

.floor-sidebar {
    width: 200px;
    flex-shrink: 0;
    background: #f8fafc;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    padding: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    max-height: 520px;
    overflow-y: auto;
}

#floor-tabs-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.floor-content-area {
    flex-grow: 1;
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    padding: 1.25rem;
    min-height: 480px;
}

.apartment-grid-layout {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 1rem;
}

/* Mobile responsive adaptions */
@media (max-width: 768px) {
    .apartments-container {
        flex-direction: column !important;
        min-height: auto !important;
        gap: 0.75rem !important;
    }
    
    .floor-sidebar {
        width: 100% !important;
        max-height: 180px !important;
        padding: 0.5rem !important;
    }
    
    #floor-tabs-list {
        flex-direction: row !important;
        overflow-x: auto !important;
        padding-bottom: 0.5rem !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    #floor-tabs-list .floor-tab-btn {
        white-space: nowrap !important;
        width: auto !important;
        padding: 0.5rem 0.75rem !important;
        font-size: 0.78rem !important;
    }
    
    .floor-content-area {
        width: 100% !important;
        min-height: auto !important;
        padding: 0.75rem !important;
    }
    
    .apartment-grid-layout {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)) !important;
        gap: 0.5rem !important;
    }
    
    .apartment-details-grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }
    .apartment-details-grid .table-responsive {
        display: block !important;
        overflow-x: auto !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    .apartment-details-grid .data-table {
        min-width: 500px !important;
    }
    .modal-footer {
        flex-wrap: wrap !important;
        justify-content: flex-end !important;
    }
    .apt-area-badge {
        font-size: 9.5px !important;
        padding: 1px 4px !important;
        border-radius: 4px !important;
    }
    .apt-card-room-title {
        font-size: 11.5px !important;
    }
}

.apartment-details-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 0.85rem;
    align-items: start;
}

.apt-area-badge {
    font-size: 13.5px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
    white-space: nowrap;
}
.apt-card-room-title {
    font-size: 13.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Responsive helpers for technical/inspection views */
.show-on-mobile {
    display: none;
}
@media (max-width: 768px) {
    .hide-on-mobile {
        display: none !important;
    }
    .show-on-mobile {
        display: flex !important;
    }
}
