/* ============================================================
   Builders Portal — Admin Stylesheet
   ============================================================ */

:root {
    --primary: #102C50;
    --primary-dark: #071B35;
    --primary-light: #173B63;
    --accent: #FF9015;
    --accent-light: #FFA63D;
    --sidebar-bg: #102C50;
    --sidebar-text: #94a3b8;
    --sidebar-active: #173B63;
    --dark: #172B45;
    --text: #172B45;
    --text-light: #718096;
    --bg: #F5F7FA;
    --white: #ffffff;
    --border: #e2e8f0;
    --success: #16a34a;
    --danger: #dc2626;
    --radius: 8px;
    --shadow: 0 2px 10px rgba(16, 44, 80, 0.06);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; }

/* ---------- Layout ---------- */
.admin-wrap { display: flex; min-height: 100vh; }

.admin-sidebar {
    width: 240px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    height: 100vh;
    max-height: 100vh;
    z-index: 50;
    overflow-y: hidden;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px;
    font-size: 17px;
    font-weight: 800;
    color: #fff;
    border-bottom: 1px solid #1e293b;
    flex-shrink: 0;
}
.sidebar-brand .brand-icon {
    width: 36px; height: 36px;
    border-radius: 9px;
    background: var(--primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
}
.sidebar-nav, .admin-nav {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 14px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    list-style: none;
    margin: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
}

/* Custom Sleek Scrollbar for Admin Sidebar Nav */
.sidebar-nav::-webkit-scrollbar,
.admin-nav::-webkit-scrollbar {
    width: 5px;
}
.sidebar-nav::-webkit-scrollbar-track,
.admin-nav::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-nav::-webkit-scrollbar-thumb,
.admin-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover,
.admin-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.38);
}

.sidebar-nav a, .admin-nav li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 8px;
    color: var(--sidebar-text);
    font-weight: 500;
    text-decoration: none;
    transition: all 0.15s;
}
.sidebar-nav a i, .admin-nav li a i { width: 20px; text-align: center; }
.sidebar-nav a:hover, .admin-nav li a:hover { background: #1e293b; color: #fff; }
.sidebar-nav a.active, .admin-nav li a.active { background: var(--sidebar-active); color: #fff; }
.sidebar-nav a .nav-badge { margin-left: auto; background: var(--danger, #dc2626); color: #fff; font-size: 11px; font-weight: 700; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; }
.sidebar-foot { padding: 14px 10px; border-top: 1px solid #1e293b; display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; }
.sidebar-foot a {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; border-radius: 8px;
    color: var(--sidebar-text); font-weight: 500; font-size: 13px;
}
.sidebar-foot a:hover { background: #1e293b; color: #fff; }

.admin-main { flex: 1; margin-left: 240px; display: flex; flex-direction: column; min-height: 100vh; }
.admin-topbar {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 16px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 40;
}
.admin-topbar h1 { font-size: 20px; font-weight: 800; color: var(--dark); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }

/* User Profile Dropdown */
.topbar-user-dropdown { position: relative; }
.topbar-user-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: transparent;
    border: 1px solid transparent;
    padding: 6px 10px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
    text-align: left;
}
.topbar-user-btn:hover,
.topbar-user-btn.active {
    background: #f8fafc;
    border-color: #e2e8f0;
}
.user-chevron {
    font-size: 11px;
    color: var(--text-light, #94a3b8);
    transition: transform 0.2s ease;
    margin-left: 2px;
}
.topbar-user-btn.active .user-chevron {
    transform: rotate(180deg);
}
.user-info b { display: block; font-size: 13px; color: var(--dark); line-height: 1.25; }
.user-info small { color: var(--text-light); font-size: 11px; line-height: 1.2; }
.user-dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    width: 230px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 12px 35px rgba(1, 30, 64, 0.15);
    z-index: 65;
    display: none;
    overflow: hidden;
    padding: 6px;
    animation: userDropFade 0.15s ease;
}
.user-dropdown-menu.open {
    display: block;
}
@keyframes userDropFade {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}
.user-dropdown-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #f8fafc;
    border-radius: 8px;
    margin-bottom: 4px;
}
.user-avatar-lg {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}
.user-meta { overflow: hidden; }
.user-meta strong {
    display: block;
    font-size: 13px;
    color: var(--dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-meta span {
    display: block;
    font-size: 11.5px;
    color: var(--text-light);
    text-transform: capitalize;
}
.user-dropdown-divider {
    height: 1px;
    background: var(--border, #e2e8f0);
    margin: 4px 0;
}
.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 7px;
    color: var(--dark);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.12s ease;
}
.user-dropdown-item i:first-child {
    width: 16px;
    text-align: center;
    color: var(--text-light);
    font-size: 13px;
}
.user-dropdown-item span { flex: 1; }
.user-dropdown-item .item-ext {
    font-size: 10px;
    color: #94a3b8;
    margin-left: auto;
}
.user-dropdown-item:hover {
    background: #f1f5f9;
    color: var(--primary);
}
.user-dropdown-item:hover i:first-child {
    color: var(--primary);
}
.user-dropdown-item.item-logout {
    color: #ef4444;
}
.user-dropdown-item.item-logout i:first-child {
    color: #ef4444;
}
.user-dropdown-item.item-logout:hover {
    background: #fef2f2;
    color: #dc2626;
}

.topbar-user { display: flex; align-items: center; gap: 10px; }
.user-avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
}
.topbar-user b { display: block; font-size: 13px; color: var(--dark); }
.topbar-user small { color: var(--text-light); font-size: 11px; }

.admin-content { flex: 1; padding: 28px; }
.admin-footer { padding: 16px 28px; color: var(--text-light); font-size: 12px; border-top: 1px solid var(--border); background: var(--white); }

/* ---------- Cards / stats ---------- */
.stat-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 26px; }
.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 14px;
}
.stat-card-icon {
    width: 46px; height: 46px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 19px;
    color: #fff;
}
.stat-card-icon.blue { background: var(--primary); }
.stat-card-icon.green { background: var(--success); }
.stat-card-icon.amber { background: #D9600A; }
.stat-card-icon.red { background: var(--danger); }
.stat-card-value { font-size: 22px; font-weight: 800; color: var(--dark); line-height: 1.2; }
.stat-card-label { color: var(--text-light); font-size: 12px; font-weight: 500; }

.panel {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
    margin-bottom: 24px;
}
.panel h2 { font-size: 16px; font-weight: 700; color: var(--dark); margin-bottom: 16px; }
.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
.data-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.data-table tr:hover td { background: #f8fafc; }
.data-table .thumb {
    width: 56px; height: 42px;
    object-fit: cover;
    border-radius: 6px;
    background: #e2e8f0;
}
.cell-title b { color: var(--dark); display: block; }
.cell-title small { color: var(--text-light); }
.text-muted { color: var(--text-light); }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- Badges ---------- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
}
.badge-residential { background: #F2F6FB; color: #102C50; }
.badge-commercial { background: #FCEEE0; color: #9A4A08; }
.badge-new { background: #fef2f2; color: #991b1b; }
.badge-contacted { background: #F2F6FB; color: #102C50; }
.badge-closed { background: #f1f5f9; color: #64748b; }
.badge-active { background: #f0fdf4; color: #166534; }
.badge-inactive { background: #f1f5f9; color: #64748b; }
.badge-upcoming { background: #FCEEE0; color: #D9600A; }
.badge-ongoing { background: #F2F6FB; color: #102C50; }
.badge-ready_to_move { background: #f0fdf4; color: #166534; }
.badge-completed { background: #f1f5f9; color: #475569; }
.badge-in_progress { background: #FCEEE0; color: #9A4A08; }
.badge-purple { background: #FCEEE0; color: #D9600A; }
.badge-blue { background: #F2F6FB; color: #102C50; }
.badge-amber { background: #FCEEE0; color: #9A4A08; }
.badge-red { background: #fef2f2; color: #991b1b; }
.badge-green { background: #f0fdf4; color: #166534; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-danger { background: #fee2e2; color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-success { background: #dcfce7; color: #166534; }
.btn-success:hover { background: var(--success); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; font-size: 13px; color: var(--dark); margin-bottom: 6px; }
.form-group label .req { color: var(--danger); }
.form-control {
    width: 100%;
    padding: 10px 13px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: #fff;
    transition: border-color 0.15s;
}
.form-control:focus { outline: none; border-color: var(--primary); }
textarea.form-control { resize: vertical; min-height: 110px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-hint { font-size: 12px; color: var(--text-light); margin-top: 4px; }

/* ---------- Alerts ---------- */
.alert {
    padding: 13px 16px;
    border-radius: 8px;
    margin-bottom: 18px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid transparent;
}
.alert-success { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.alert-error { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.alert-info { background: #F2F6FB; color: #102C50; border-color: #D8E4F0; }

/* ---------- Login ---------- */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0A1C30 0%, #102C50 60%, #173B63 100%);
    padding: 20px;
}
.login-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
    padding: 40px;
    width: 100%;
    max-width: 400px;
}
.login-card .brand-icon {
    width: 52px; height: 52px;
    border-radius: 13px;
    background: var(--primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    margin: 0 auto 16px;
}
.login-card h1 { text-align: center; font-size: 22px; font-weight: 800; color: var(--dark); margin-bottom: 4px; }
.login-card .sub { text-align: center; color: var(--text-light); font-size: 13px; margin-bottom: 26px; }

/* ---------- Gallery manage ---------- */
.gallery-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 14px; }
.gallery-item {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    position: relative;
}
.gallery-item img { width: 100%; aspect-ratio: 16/10; object-fit: cover; }
.gallery-item .gallery-actions { display: flex; gap: 6px; padding: 8px; }

/* ---------- Search bar ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar .search-box { display: flex; gap: 8px; }
.toolbar .search-box input { min-width: 240px; }

/* ---------- Empty ---------- */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-light); }
.empty-state i { font-size: 40px; color: #cbd5e1; margin-bottom: 10px; display: block; }

/* ---------- Notification bell ---------- */
.topbar-notif { position: relative; }
.notif-bell {
    position: relative;
    width: 40px; height: 40px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--white);
    color: var(--text);
    font-size: 16px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
}
.notif-bell:hover { border-color: var(--primary); color: var(--primary); }
.notif-badge {
    position: absolute;
    top: -6px; right: -6px;
    min-width: 18px; height: 18px;
    border-radius: 9px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    align-items: center; justify-content: center;
    padding: 0 5px;
    border: 2px solid var(--white);
    box-sizing: content-box;
}
.notif-dropdown {
    position: absolute;
    right: 0; top: 48px;
    width: 320px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(1, 30, 64, 0.15);
    z-index: 60;
    display: none;
    overflow: hidden;
}
.notif-dropdown.open { display: block; }
.notif-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
}
.notif-head b { font-size: 14px; color: var(--dark); }
.notif-head a { font-size: 12px; color: var(--primary); }
.notif-list { max-height: 340px; overflow-y: auto; }
.notif-item {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    transition: background 0.12s;
    position: relative;
}
.notif-item:hover { background: #f8fafc; }
.notif-item.read { opacity: 0.65; }
.notif-item-text { flex: 1; min-width: 0; }
.notif-item-text b { display: block; font-size: 13px; color: var(--dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-item-text span { display: block; font-size: 12px; color: var(--text-light); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-item-time { font-size: 11px; color: var(--text-light); flex-shrink: 0; }
.notif-item-arrow { font-size: 10px; color: #cbd5e1; flex-shrink: 0; }
.notif-item::before {
    content: '';
    position: absolute; left: 0; top: 0; bottom: 0;
    width: 3px; background: transparent;
}
.notif-item:not(.read)::before { background: var(--primary); }
.notif-foot { padding: 10px 16px; border-top: 1px solid var(--border); text-align: center; }
.notif-foot a { font-size: 12px; color: var(--text-light); }
.notif-foot a:hover { color: var(--primary); }

@media (max-width: 576px) {
    .notif-dropdown { width: 280px; right: -70px; }
}

/* ---------- Responsive ---------- */
@media (max-width: 992px) {
    .stat-cards { grid-template-columns: repeat(2, 1fr); }
    .panel-grid, .form-row, .form-row-3 { grid-template-columns: 1fr; }
    .admin-sidebar { width: 200px; }
    .admin-main { margin-left: 200px; }
    .gallery-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
    .admin-sidebar { display: none; }
    .admin-main { margin-left: 0; }
    .stat-cards { grid-template-columns: 1fr 1fr; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .toolbar .search-box { flex-direction: column; }
    .user-info { display: none; }
    .user-dropdown-menu { width: 210px; }
}

/* Google Sign In Button */
.th-btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    box-sizing: border-box;
    padding: 11px 16px;
    background: #ffffff;
    color: #374151;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, box-shadow 0.2s, transform 0.1s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.th-btn-google:hover {
    background: #f9fafb;
    border-color: #9ca3af;
    color: #111827;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}
.th-btn-google:active {
    transform: scale(0.985);
    background: #f3f4f6;
}
.th-google-icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}
