/* ============================================================
   Mindray Laptop Asset Management — style.css
   Mindray Theme: Red & White
   ============================================================ */

:root {
    --brand-primary:   #cc0000;
    --brand-dark:      #8b0000;
    --brand-light:     #fff0f0;
    --brand-accent:    #ff4444;
    --sidebar-bg:      #8b0000;
    --sidebar-width:   256px;
    --sidebar-mini:    68px;
    --header-height:   60px;
    --card-radius:     12px;
    --shadow-sm:       0 2px 8px rgba(0,0,0,0.08);
    --shadow-md:       0 4px 20px rgba(0,0,0,0.12);
    --text-primary:    #1a1a1a;
    --text-secondary:  #546e7a;
    --bg-body:         #fff5f5;
    --white:           #ffffff;
    --success:         #2e7d32;
    --danger:          #c62828;
    --warning:         #f57f17;
    --info:            #cc0000;

    /* Dark mode overrides */
    --dm-bg:           #1a0000;
    --dm-sidebar:      #0f0000;
    --dm-card:         #2a0a0a;
    --dm-text:         #f5e8e8;
    --dm-border:       #4a1a1a;
    --dm-input:        #3a0a0a;
}

/* ── Base ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    margin: 0;
    transition: background 0.3s, color 0.3s;
}

body.dark-mode {
    background: var(--dm-bg);
    color: var(--dm-text);
}

/* ── Layout ─────────────────────────────────────────────────── */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 1000;
    transition: width 0.28s cubic-bezier(0.4,0,0.2,1), transform 0.28s;
    overflow: hidden;
    box-shadow: 4px 0 24px rgba(139,0,0,0.35);
}

.sidebar.collapsed {
    width: var(--sidebar-mini);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1rem 1rem 1.1rem;
    border-bottom: 1px solid rgba(255,255,255,0.15);
    min-height: var(--header-height);
    background: rgba(0,0,0,0.2);
    text-decoration: none;
}

.sidebar-brand img {
    height: 32px;
    width: auto;
    border-radius: 4px;
    flex-shrink: 0;
    filter: brightness(0) invert(1);
    transition: filter 0.2s;
}

.sidebar-brand img.color-logo {
    filter: none;
    background: white;
    border-radius: 6px;
    padding: 2px 6px;
    height: 36px;
    object-fit: contain;
}

.sidebar-brand-text {
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.2s;
}
.sidebar-brand-text small {
    display: block;
    font-size: 0.65rem;
    font-weight: 400;
    color: rgba(255,255,255,0.6);
    margin-top: 1px;
}
.sidebar.collapsed .sidebar-brand-text,
.sidebar.collapsed .nav-label {
    opacity: 0;
    pointer-events: none;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.75rem 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.sidebar-section {
    padding: 0.5rem 0.75rem 0.25rem;
    font-size: 0.63rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: rgba(255,255,255,0.35);
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
}
.sidebar.collapsed .sidebar-section { opacity: 0; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem 0.65rem 1.25rem;
    color: rgba(255,255,255,0.75);
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: all 0.18s;
    white-space: nowrap;
    user-select: none;
    position: relative;
}
.nav-item:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}
.nav-item.active {
    background: rgba(255,68,68,0.25);
    color: #ffaaaa;
    border-left-color: #ffaaaa;
}
.nav-item i {
    font-size: 1.15rem;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}
.nav-label {
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.2s;
}

/* Tooltip for collapsed sidebar */
.sidebar.collapsed .nav-item::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(var(--sidebar-mini) + 8px);
    background: #3a0a0a;
    color: #fff;
    font-size: 0.78rem;
    padding: 0.3rem 0.65rem;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
    z-index: 2000;
    box-shadow: var(--shadow-md);
}
.sidebar.collapsed .nav-item:hover::after { opacity: 1; }

/* Sidebar footer */
.sidebar-footer {
    padding: 0.75rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    background: rgba(0,0,0,0.15);
}

.btn-collapse-sidebar {
    background: transparent;
    border: 1.5px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.55);
    border-radius: 8px;
    padding: 0.35rem 0.65rem;
    cursor: pointer;
    font-size: 0.82rem;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    transition: all 0.18s;
}
.btn-collapse-sidebar:hover {
    background: rgba(255,255,255,0.12);
    color: #fff;
}
.sidebar.collapsed .btn-collapse-sidebar span { display: none; }

/* ── Main content ────────────────────────────────────────────── */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.28s cubic-bezier(0.4,0,0.2,1);
}
.main-content.sidebar-mini { margin-left: var(--sidebar-mini); }

/* ── Top header ─────────────────────────────────────────────── */
.top-header {
    height: var(--header-height);
    background: var(--white);
    border-bottom: 3px solid var(--brand-primary);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 900;
    box-shadow: 0 2px 12px rgba(204,0,0,0.1);
}
.dark-mode .top-header {
    background: var(--dm-card);
    border-color: var(--brand-primary);
}

.header-logo {
    height: 28px;
    width: auto;
}

.header-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--brand-primary);
    flex: 1;
}

/* ── Page sections ───────────────────────────────────────────── */
.page-section { display: none; }
.page-section.active { display: block; }

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.dark-mode .section-title { color: var(--dm-text); }

.page-body { padding: 1.5rem; }

/* ── Stat cards ─────────────────────────────────────────────── */
.stat-card {
    background: var(--white);
    border-radius: var(--card-radius);
    padding: 1.25rem 1.4rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid #ffe0e0;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.dark-mode .stat-card {
    background: var(--dm-card);
    border-color: var(--dm-border);
}

.stat-icon {
    width: 52px; height: 52px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}
.stat-icon.blue   { background: #ffe0e0; color: #cc0000; }
.stat-icon.green  { background: #e8f5e9; color: #2e7d32; }
.stat-icon.orange { background: #fff3e0; color: #e65100; }
.stat-icon.red    { background: #ffebee; color: #c62828; }
.stat-icon.purple { background: #f3e5f5; color: #6a1b9a; }

.stat-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}
.dark-mode .stat-value { color: var(--dm-text); }

/* ── Data table card ─────────────────────────────────────────── */
.table-card {
    background: var(--white);
    border-radius: var(--card-radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid #ffe0e0;
    overflow: hidden;
}
.dark-mode .table-card {
    background: var(--dm-card);
    border-color: var(--dm-border);
}

/* DataTables overrides */
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    border-radius: 8px;
    border: 1px solid #e0c0c0;
    padding: 0.35rem 0.65rem;
    font-size: 0.85rem;
}
.dataTables_wrapper .dataTables_filter input:focus,
.dataTables_wrapper .dataTables_length select:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(204,0,0,0.12);
}
.dark-mode .dataTables_wrapper .dataTables_filter input,
.dark-mode .dataTables_wrapper .dataTables_length select {
    background: var(--dm-input);
    border-color: var(--dm-border);
    color: var(--dm-text);
}

table.dataTable thead th {
    background: #fff0f0;
    color: var(--brand-dark);
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 2px solid #ffd0d0;
    padding: 0.75rem 1rem;
}
.dark-mode table.dataTable thead th {
    background: #2a0a0a;
    color: #ff9999;
    border-color: var(--dm-border);
}

table.dataTable tbody td {
    padding: 0.7rem 1rem;
    font-size: 0.875rem;
    vertical-align: middle;
    border-bottom: 1px solid #fff0f0;
}
.dark-mode table.dataTable tbody td {
    border-color: var(--dm-border);
    color: var(--dm-text);
}

table.dataTable tbody tr:hover td {
    background: #fff5f5;
}
.dark-mode table.dataTable tbody tr:hover td { background: rgba(255,100,100,0.05); }

/* ── Badges ─────────────────────────────────────────────────── */
.badge-warranty-active  { background: #e8f5e9; color: #2e7d32; }
.badge-warranty-expired { background: #ffebee; color: #c62828; }
.badge-five-year        { background: #fff8e1; color: #f57f17; }

.badge {
    padding: 0.3rem 0.65rem;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn-primary-brand {
    background: var(--brand-primary);
    border: none;
    color: #fff;
    border-radius: 8px;
    font-weight: 600;
    padding: 0.5rem 1.1rem;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s;
    cursor: pointer;
    text-decoration: none;
}
.btn-primary-brand:hover {
    background: var(--brand-dark);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(204,0,0,0.35);
}

.btn-sm-action {
    padding: 0.3rem 0.55rem;
    font-size: 0.78rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}
.btn-sm-action.edit   { background: #ffe0e0; color: #cc0000; }
.btn-sm-action.delete { background: #ffebee; color: #c62828; }
.btn-sm-action.restore{ background: #e8f5e9; color: #2e7d32; }
.btn-sm-action.perm   { background: #fce4ec; color: #880e4f; }
.btn-sm-action:hover  { filter: brightness(0.9); transform: translateY(-1px); }

/* ── Forms ───────────────────────────────────────────────────── */
.form-control, .form-select {
    border-radius: 8px;
    border: 1.5px solid #e0c0c0;
    font-size: 0.875rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(204,0,0,0.12);
}
.dark-mode .form-control,
.dark-mode .form-select {
    background: var(--dm-input);
    border-color: var(--dm-border);
    color: var(--dm-text);
}
.dark-mode .form-control:focus,
.dark-mode .form-select:focus {
    border-color: var(--brand-accent);
}

.form-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.35rem;
}
.dark-mode .form-label { color: #c09090; }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-content {
    border-radius: 16px;
    border: none;
    box-shadow: 0 24px 80px rgba(0,0,0,0.25);
}
.dark-mode .modal-content {
    background: var(--dm-card);
    color: var(--dm-text);
}
.modal-header {
    background: linear-gradient(135deg, var(--brand-dark), var(--brand-primary));
    border-radius: 16px 16px 0 0;
    padding: 1.1rem 1.5rem;
    border-bottom: none;
}
.modal-title { color: #fff; font-weight: 700; font-size: 1rem; }
.modal-header .btn-close { filter: invert(1); }
.modal-body { padding: 1.5rem; }
.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #ffe0e0;
}
.dark-mode .modal-footer { border-color: var(--dm-border); }

/* ── Chart card ─────────────────────────────────────────────── */
.chart-card {
    background: var(--white);
    border-radius: var(--card-radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid #ffe0e0;
    padding: 1.25rem;
}
.dark-mode .chart-card {
    background: var(--dm-card);
    border-color: var(--dm-border);
}

/* ── Loading overlay ─────────────────────────────────────────── */
.loading-overlay {
    position: fixed; inset: 0;
    background: rgba(255,255,255,0.85);
    display: flex; align-items: center; justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
}
.dark-mode .loading-overlay { background: rgba(26,0,0,0.85); }
.loading-spinner-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}
.spinner-ring {
    width: 48px; height: 48px;
    border: 4px solid #ffe0e0;
    border-top-color: var(--brand-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Dark mode toggle ────────────────────────────────────────── */
.dark-toggle {
    background: transparent;
    border: 1.5px solid rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.7);
    border-radius: 8px;
    padding: 0.35rem 0.65rem;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.dark-toggle:hover {
    border-color: rgba(255,255,255,0.5);
    color: #fff;
    background: rgba(255,255,255,0.08);
}

/* ── User chip ───────────────────────────────────────────────── */
.user-chip {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255,255,255,0.1);
    border-radius: 24px;
    padding: 0.35rem 0.9rem 0.35rem 0.5rem;
    font-size: 0.82rem;
    color: rgba(255,255,255,0.85);
}
.user-avatar {
    width: 28px; height: 28px;
    background: var(--brand-accent);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
}

/* ── Import/Export toolbar ───────────────────────────────────── */
.btn-toolbar {
    font-size: 0.8rem;
    border-radius: 8px;
    padding: 0.4rem 0.85rem;
    border: 1.5px solid;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: all 0.18s;
    font-weight: 500;
}
.btn-tb-blue    { border-color: #cc0000; color: #cc0000; background: transparent; }
.btn-tb-blue:hover { background: #fff0f0; }
.btn-tb-green   { border-color: #2e7d32; color: #2e7d32; background: transparent; }
.btn-tb-green:hover { background: #e8f5e9; }
.btn-tb-orange  { border-color: #e65100; color: #e65100; background: transparent; }
.btn-tb-orange:hover { background: #fff3e0; }
.btn-tb-red     { border-color: #c62828; color: #c62828; background: transparent; }
.btn-tb-red:hover { background: #ffebee; }
.btn-tb-purple  { border-color: #6a1b9a; color: #6a1b9a; background: transparent; }
.btn-tb-purple:hover { background: #f3e5f5; }

/* ── Five year row highlight ─────────────────────────────────── */
tr.row-five-year td {
    background: #fffde7 !important;
}
.dark-mode tr.row-five-year td {
    background: rgba(255, 243, 99, 0.07) !important;
}

/* ── Guest banner ─────────────────────────────────────────────── */
.guest-banner {
    background: linear-gradient(135deg, #fff0f0, #ffe8e8);
    border: 1px solid #ffcccc;
    border-radius: 10px;
    padding: 0.65rem 1rem;
    font-size: 0.83rem;
    color: #8b0000;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
    }
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0 !important;
    }
    .sidebar-overlay {
        display: none;
        position: fixed; inset: 0;
        background: rgba(0,0,0,0.45);
        z-index: 999;
    }
    .sidebar-overlay.active { display: block; }
    .page-body { padding: 1rem; }
    .stat-card { padding: 1rem; }
    .stat-value { font-size: 1.5rem; }
    .section-header { flex-direction: column; align-items: flex-start; }
}

/* ── Misc ───────────────────────────────────────────────────── */
.truncate { max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    padding: 0.75rem 1rem;
    background: #fff5f5;
    border-bottom: 1px solid #ffe0e0;
}
.dark-mode .filter-bar {
    background: rgba(255,100,100,0.03);
    border-color: var(--dm-border);
}

.filter-bar select {
    font-size: 0.82rem;
    padding: 0.35rem 0.75rem;
    border-radius: 8px;
    border: 1.5px solid #e0c0c0;
    min-width: 140px;
    cursor: pointer;
}

.tag-five { 
    display: inline-block;
    background: #fff8e1;
    color: #f57f17;
    border: 1px solid #ffe082;
    border-radius: 12px;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

/* DataTables pagination */
.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 6px !important;
    padding: 0.3rem 0.6rem !important;
    font-size: 0.82rem;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--brand-primary) !important;
    border-color: var(--brand-primary) !important;
    color: #fff !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: #ffe0e0 !important;
    border-color: #ffe0e0 !important;
    color: var(--brand-primary) !important;
}

/* Settings section */
.settings-card {
    background: var(--white);
    border-radius: var(--card-radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid #ffe0e0;
    padding: 1.5rem;
    margin-bottom: 1rem;
}
.dark-mode .settings-card {
    background: var(--dm-card);
    border-color: var(--dm-border);
}
.settings-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--brand-primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1.5px solid #ffe0e0;
}
.dark-mode .settings-title { border-color: var(--dm-border); }

/* ── Warranty status badge colors ────────────────────────────── */
.warranty-active  { color: #2e7d32; font-weight: 600; }
.warranty-expired { color: #c62828; font-weight: 600; }

/* ── Animations ─────────────────────────────────────────────── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
.page-section.active { animation: fadeInUp 0.25s ease; }
.fade-in { animation: fadeInUp 0.3s ease; }

/* Search box */
.search-box {
    position: relative;
    min-width: 220px;
}
.search-box input {
    padding-left: 2.2rem;
    border-radius: 20px;
    font-size: 0.85rem;
}
.search-box .search-icon {
    position: absolute;
    left: 0.7rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* No data */
.no-data-wrap {
    padding: 3rem 1rem;
    text-align: center;
}
.no-data-icon {
    font-size: 3.5rem;
    color: #b0bec5;
    margin-bottom: 1rem;
}
.no-data-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
}
