/* ═══════════════════════════════════════════════════
   Component Management System — Global Styles
   Color Schema:
     White background: #ffffff
     Primary / Buttons / Headings: #00adee
     Section backgrounds: #f8f9fa
   ═══════════════════════════════════════════════════ */

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

:root {
    --primary:    #00adee;
    --primary-d:  #0090cc;
    --primary-l:  #e0f6ff;
    --bg:         #ffffff;
    --section:    #f8f9fa;
    --border:     #dee2e6;
    --text:       #212529;
    --text-muted: #6c757d;
    --danger:     #dc3545;
    --success:    #28a745;
    --warning:    #ffc107;
    --info:       #17a2b8;
    --shadow:     0 2px 12px rgba(0,173,238,.12);
    --radius:     10px;
}

body {
    font-family: poppins;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--section); }
::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 3px; }

/* ════════════════ LOGIN PAGE ════════════════ */
.login-page {
    background: linear-gradient(135deg, #e0f6ff 0%, #f0faff 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,173,238,.18);
    padding: 40px 36px;
    width: 100%;
    max-width: 420px;
}

.login-header { text-align: center; margin-bottom: 28px; }
.login-icon   { font-size: 42px; margin-bottom: 10px; }
.login-header h1 { color: var(--primary); font-size: 1.6rem; margin-bottom: 4px; }
.login-header p  { color: var(--text-muted); font-size: .9rem; }

.role-toggle { display: flex; gap: 10px; margin-top: 6px; }
.role-btn { flex: 1; }
.role-btn input { display: none; }
.role-btn span {
    display: block;
    text-align: center;
    padding: 10px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: .9rem;
    transition: all .2s;
}
.role-btn input:checked + span {
    border-color: var(--primary);
    background: var(--primary-l);
    color: var(--primary);
    font-weight: 600;
}

.credentials-hint {
    background: var(--section);
    border-left: 3px solid var(--primary);
    padding: 8px 12px;
    border-radius: 4px;
    font-size: .82rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

/* ════════════════ LAYOUT ════════════════ */
.layout { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
    width: 250px;
    background: #fff;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    box-shadow: 2px 0 12px rgba(0,0,0,.06);
    transition: transform .3s;
}

.sidebar-brand {
    padding: 22px 20px 18px;
    border-bottom: 1px solid var(--border);
}
.sidebar-brand h2 { color: var(--primary); font-size: 1.1rem; }
.sidebar-brand small { color: var(--text-muted); font-size: .78rem; }

.sidebar-user {
    padding: 14px 20px;
    background: var(--primary-l);
    border-bottom: 1px solid var(--border);
}
.sidebar-user .u-name { font-weight: 600; font-size: .92rem; }
.sidebar-user .u-role { font-size: .78rem; color: var(--primary); font-weight: 500; }

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 20px;
    text-decoration: none;
    color: var(--text);
    font-size: .9rem;
    transition: all .2s;
    border-left: 3px solid transparent;
}
.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: var(--primary-l);
    color: var(--primary);
    border-left-color: var(--primary);
    font-weight: 600;
}
.sidebar-nav a .nav-icon { font-size: 1.1rem; width: 22px; text-align: center; }

.sidebar-footer { padding: 14px 20px; border-top: 1px solid var(--border); }
.sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--danger);
    text-decoration: none;
    font-size: .88rem;
}

/* ── Main Content ── */
.main-content {
    margin-left: 250px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 14px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 2px 8px rgba(0,0,0,.04);
}
.topbar h1 { font-size: 1.2rem; color: var(--primary); font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.page-body { padding: 28px; flex: 1; }

/* ── Mobile sidebar toggle ── */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--primary);
}

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

.stat-card {
    background: var(--section);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    border: 1px solid var(--border);
    transition: box-shadow .2s;
}
.stat-card:hover { box-shadow: var(--shadow); }

.stat-icon {
    width: 50px; height: 50px;
    border-radius: 12px;
    background: var(--primary-l);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}
.stat-card.danger  .stat-icon { background: #ffeaea; }
.stat-card.success .stat-icon { background: #eafaf1; }
.stat-card.warning .stat-icon { background: #fff9e6; }

.stat-info .stat-value { font-size: 1.7rem; font-weight: 700; color: var(--primary); }
.stat-card.danger  .stat-info .stat-value { color: var(--danger); }
.stat-card.success .stat-info .stat-value { color: var(--success); }
.stat-card.warning .stat-info .stat-value { color: #e6a817; }
.stat-info .stat-label { font-size: .82rem; color: var(--text-muted); margin-top: 2px; }

/* ── Section card ── */
.card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 24px;
    box-shadow: 0 1px 6px rgba(0,0,0,.05);
}
.card-header {
    background: var(--section);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 1rem; color: var(--primary); font-weight: 700; }
.card-body { padding: 20px; }

/* ════════════════ FEED ════════════════ */
.feed { display: flex; flex-direction: column; gap: 12px; }

.feed-item {
    background: var(--section);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    gap: 14px;
    align-items: flex-start;
    border-left: 4px solid var(--primary);
    transition: box-shadow .2s;
}
.feed-item:hover { box-shadow: var(--shadow); }
.feed-item.sold    { border-left-color: var(--success); }
.feed-item.damaged { border-left-color: var(--danger); }
.feed-item.testing { border-left-color: var(--warning); }

.feed-icon {
    font-size: 1.3rem;
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--primary-l);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.feed-content { flex: 1; }
.feed-title { font-weight: 600; font-size: .95rem; margin-bottom: 3px; }
.feed-meta { font-size: .8rem; color: var(--text-muted); }
.feed-meta span { margin-right: 10px; }

.feed-right { text-align: right; flex-shrink: 0; }
.feed-qty { font-size: 1.1rem; font-weight: 700; color: var(--danger); }
.feed-time { font-size: .78rem; color: var(--text-muted); }

/* ════════════════ TABLE ════════════════ */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: .88rem; }
thead th {
    background: var(--primary);
    color: #fff;
    padding: 11px 14px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background .15s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--primary-l); }
tbody td { padding: 10px 14px; vertical-align: middle; }

/* ════════════════ BADGES ════════════════ */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.badge-primary { background: var(--primary-l); color: var(--primary); }
.badge-success { background: #eafaf1; color: var(--success); }
.badge-danger  { background: #ffeaea; color: var(--danger); }
.badge-warning { background: #fff9e6; color: #e6a817; }
.badge-info    { background: #e0f7fa; color: var(--info); }

/* ════════════════ FORMS ════════════════ */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-weight: 600; font-size: .87rem; margin-bottom: 6px; color: var(--text); }

.form-control {
    width: 100%;
    padding: 10px 13px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: .9rem;
    color: var(--text);
    background: #fff;
    transition: border-color .2s, box-shadow .2s;
    outline: none;
}
.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,173,238,.12);
}
textarea.form-control { resize: vertical; min-height: 80px; }

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

.input-icon-wrap { position: relative; }
.input-icon-wrap .form-control { padding-right: 42px; }
.toggle-pw {
    position: absolute; right: 10px; top: 50%;
    transform: translateY(-50%);
    background: none; border: none;
    cursor: pointer; font-size: 1rem;
    color: var(--text-muted);
}

/* ════════════════ BUTTONS ════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 8px;
    font-size: .88rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all .2s;
    text-decoration: none;
}
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b02a37; }
.btn-success  { background: var(--success); color: #fff; }
.btn-success:hover { background: #218838; }
.btn-outline  { background: #fff; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-l); }
.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn-full { width: 100%; justify-content: center; }

/* ════════════════ ALERTS ════════════════ */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: .88rem;
    margin-bottom: 16px;
    border-left: 4px solid;
}
.alert-danger  { background: #ffeaea; color: #842029; border-color: var(--danger); }
.alert-success { background: #eafaf1; color: #155724; border-color: var(--success); }
.alert-info    { background: var(--primary-l); color: #0c5460; border-color: var(--primary); }

/* ════════════════ MODAL ════════════════ */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0; pointer-events: none;
    transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
    background: #fff;
    border-radius: 14px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
    transform: translateY(20px);
    transition: transform .2s;
}
.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
    padding: 18px 22px 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-header h3 { color: var(--primary); font-size: 1.05rem; }
.modal-close {
    background: none; border: none;
    font-size: 1.3rem; cursor: pointer;
    color: var(--text-muted); line-height: 1;
}
.modal-body { padding: 20px 22px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ════════════════ IMAGE THUMB ════════════════ */
.comp-img {
    width: 44px; height: 44px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border);
}
.comp-img-placeholder {
    width: 44px; height: 44px;
    background: var(--section);
    border: 1px solid var(--border);
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--text-muted);
}

/* ════════════════ SEARCH / FILTER BAR ════════════════ */
.filter-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 18px;
}
.filter-bar .form-control { max-width: 220px; }
.filter-bar select.form-control { max-width: 170px; }

/* ════════════════ TABS ════════════════ */
.tabs { display: flex; gap: 4px; margin-bottom: 18px; border-bottom: 2px solid var(--border); }
.tab-btn {
    padding: 9px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: .9rem;
    color: var(--text-muted);
    font-weight: 500;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all .2s;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 700; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ════════════════ EMPTY STATE ════════════════ */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state h4 { font-size: 1.05rem; margin-bottom: 6px; }
.empty-state p { font-size: .88rem; }

/* ════════════════ PAGINATION ════════════════ */
.pagination {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: center;
    margin-top: 18px;
    flex-wrap: wrap;
}
.pagination a, .pagination span {
    padding: 6px 13px;
    border-radius: 7px;
    font-size: .85rem;
    text-decoration: none;
    color: var(--primary);
    border: 1.5px solid var(--border);
    transition: all .2s;
}
.pagination a:hover  { background: var(--primary-l); border-color: var(--primary); }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ════════════════ BREADCRUMB ════════════════ */
.breadcrumb { font-size: .82rem; color: var(--text-muted); margin-bottom: 16px; }
.breadcrumb a { color: var(--primary); text-decoration: none; }
.breadcrumb span { margin: 0 6px; }

/* ════════════════ RESPONSIVE ════════════════ */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .menu-toggle { display: block; }
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
    .page-body { padding: 16px; }
    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-bar .form-control, .filter-bar select.form-control { max-width: 100%; }
}
