/* --- RESET & VARIABLES --- */
:root {
    /* NEW BRAND COLOR: Indigo 700 (Deep Industrial Blue) */
    --primary: #4338ca; 
    --dark: #1e293b;
    --light: #f8fafc;
    --gray: #94a3b8;
    --danger: #ef4444;
    --success: #22c55e;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { background-color: var(--light); color: var(--dark); padding-bottom: 220px; }

/* Ensure Nav Bar is always visible (remove any mobile-only restrictions if they exist) */
.nav-bar { 
    position: fixed; bottom: 0; left: 0; width: 100%; 
    background: white; border-top: 1px solid #e2e8f0; 
    display: flex; justify-content: space-around; padding: 0.8rem 0; 
    z-index: 1000; 
}

a { text-decoration: none; color: inherit; }

/* --- HEADER & BRAND --- */
header { 
    background: white; 
    padding: 1rem; 
    position: sticky; 
    top: 0; 
    z-index: 1000; 
    box-shadow: var(--shadow); 
    display: flex; 
    align-items: center; 
    justify-content: center; /* Center alignment for Mobile */
    flex-wrap: wrap;         /* Allows stacking */
}

/* NEW BRAND STYLING */
.brand { 
    font-weight: 900; 
    font-size: 1.2rem; 
    color: var(--dark); 
    font-family: 'Arial Black', sans-serif; 
    letter-spacing: -1px; 
    text-transform: none; 
    
    /* MOBILE CENTERING MAGIC */
    width: 100%;           /* Force it to take full row */
    text-align: center;    /* Center the text */
}

/* SEARCH BAR STYLING */
.search-bar { 
    width: 100%;          /* Full width on mobile */
    margin-top: 1rem;     /* Space between Logo and Search */
    margin-left: 0;       
}

.search-bar input { 
    width: 100%; 
    padding: 0.8rem 1rem; 
    border-radius: 20px; 
    border: 1px solid #cbd5e1; 
    background: var(--light); 
    font-size: 1rem;
}

.page-title { font-weight: bold; font-size: 1.1rem; } 

/* --- DESKTOP ADJUSTMENTS (Screens wider than 1024px) --- */
@media (min-width: 1024px) {
    header {
        flex-wrap: nowrap; 
        justify-content: space-between; /* Revert to space-between */
        padding: 0.8rem 2rem;
    }

    .brand {
        width: auto;        /* Shrink back to content size */
        text-align: left;   /* Left align */
        margin-right: auto; /* Push everything else to the right */
    }

    .search-bar {
        width: auto;       
        flex-grow: 1;      
        margin-top: 0;     
        margin-left: 2rem; 
        margin-right: 2rem;
        max-width: 600px;  
    }
}

.search-bar { flex-grow: 1; margin-left: 1rem; }
.search-bar input { width: 100%; padding: 0.5rem 1rem; border-radius: 20px; border: 1px solid var(--gray); background: var(--light); }
.page-title { font-weight: bold; font-size: 1.1rem; } 

/* --- LAYOUT UTILS --- */
main { padding: 1rem; max-width: 1200px; margin: 0 auto; }
.container-sm { max-width: 800px; margin: 0 auto; } 
.section-title { margin: 1.5rem 0 1rem; font-size: 1.1rem; color: var(--gray); text-transform: uppercase; letter-spacing: 1px; }

/* --- BUTTONS --- */
.btn { display: inline-block; padding: 12px 24px; border-radius: 8px; font-weight: bold; cursor: pointer; border: none; text-align: center; width: 100%; font-size: 1rem; transition: 0.2s; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: #3730a3; /* Darker shade for hover */ }
.btn-outline { background: transparent; border: 2px solid var(--gray); color: var(--gray); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; width: auto; }

/* --- MAP & GRID (HOME) --- */
#map { height: 350px; width: 100%; z-index: 1; display: none; border-bottom: 1px solid #ddd; }
.gear-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.gear-card { background: white; border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: row; cursor: pointer; transition: transform 0.2s; }
.gear-card:hover { transform: translateY(-2px); }
.card-img { width: 100px; height: 100px; background-color: #ddd; object-fit: cover; }
.card-details { padding: 0.8rem; flex-grow: 1; display: flex; flex-direction: column; justify-content: center; }
.card-title { font-weight: bold; font-size: 1rem; }
.card-dist { color: var(--primary); font-size: 0.85rem; font-weight: 600; }
.card-owner { font-size: 0.8rem; color: var(--gray); margin-top: 4px; }
.status-badge { display: inline-block; font-size: 0.7rem; padding: 2px 8px; border-radius: 4px; background: #dcfce7; color: #166534; width: fit-content; margin-top: auto; }

/* --- MODAL --- */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); z-index: 2000; display: none; align-items: center; justify-content: center; }
.modal-content { background: white; width: 90%; max-width: 500px; border-radius: 16px; padding: 1.5rem; box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1); position: relative; animation: slideUp 0.3s ease-out; }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.close-btn { position: absolute; top: 1rem; right: 1rem; background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--gray); }
.modal-header-img { width: 100%; height: 200px; object-fit: cover; border-radius: 8px; margin-bottom: 1rem; background: #eee; }
.modal-title { font-size: 1.5rem; font-weight: 800; margin-bottom: 0.2rem; }
.modal-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; color: var(--gray); font-size: 0.9rem; }
.modal-desc { line-height: 1.5; color: #475569; margin-bottom: 1.5rem; }

/* --- INVENTORY LIST & FORMS --- */
.form-group { margin-bottom: 1.5rem; }
.form-label { display: block; margin-bottom: 0.5rem; font-weight: 600; color: var(--dark); }
.form-input, .form-select, .form-textarea { width: 100%; padding: 0.8rem; border: 1px solid #cbd5e1; border-radius: 8px; background: white; font-size: 1rem; }
.form-textarea { resize: vertical; min-height: 100px; }
.image-upload-box { border: 2px dashed var(--gray); border-radius: 12px; padding: 2rem; text-align: center; color: var(--gray); cursor: pointer; background: white; }
.inventory-item { background: white; border-radius: 12px; padding: 1rem; margin-bottom: 1rem; box-shadow: var(--shadow); display: flex; align-items: center; justify-content: space-between; }
.inv-info h4 { margin-bottom: 0.2rem; }
.inv-status { font-size: 0.8rem; color: var(--gray); }
.inv-actions { display: flex; gap: 0.5rem; }

/* --- PROFILE --- */
.profile-header { text-align: center; padding: 2rem 1rem; background: white; margin-bottom: 1rem; border-bottom: 1px solid #e2e8f0; }
.avatar-large { width: 100px; height: 100px; border-radius: 50%; background: #ddd; margin: 0 auto 1rem; object-fit: cover; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 2rem; }
.stat-card { background: white; padding: 1.5rem; border-radius: 12px; text-align: center; box-shadow: var(--shadow); }
.stat-val { font-size: 2rem; font-weight: 800; color: var(--primary); }
.stat-label { font-size: 0.85rem; color: var(--gray); text-transform: uppercase; }

/* --- NAV BAR --- */
.nav-bar { position: fixed; bottom: 0; left: 0; width: 100%; background: white; border-top: 1px solid #e2e8f0; display: flex; justify-content: space-around; padding: 0.8rem 0; z-index: 1000; }
.nav-item { text-align: center; font-size: 0.75rem; color: var(--gray); cursor: pointer; text-decoration: none; }
.nav-item.active { color: var(--primary); font-weight: bold; }
.nav-icon { font-size: 1.2rem; display: block; margin-bottom: 2px; }

/* --- RESPONSIVE --- */
.desktop-only { display: none !important; }

@media (min-width: 600px) {
    .gear-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
    main { max-width: 1200px; margin: 0 auto; }
    .gear-grid { grid-template-columns: repeat(4, 1fr); }
    .gear-card { flex-direction: column; }
    .card-img { width: 100%; height: 180px; }

    /* Nav Logic */
    .mobile-only { display: none !important; } 
    .desktop-only { display: flex !important; }

    /* Desktop Nav Styling */
    .nav-bar.desktop-only { position: static; width: auto; border: none; padding: 0; margin-left: 2rem; background: transparent; }
    .nav-bar.desktop-only .nav-item { display: inline-block; margin-left: 2rem; font-size: 1rem; }
    .nav-bar.desktop-only .nav-icon { display: none; }
}

/* --- RED NOTIFICATION DOT SYSTEM --- */

/* 1. RESET: Kill any accidental dots on the inner icon or before elements */
/* This ensures you never get "Double Dots" */
.nav-item::before, 
.nav-icon::before, 
.nav-icon::after {
    content: none !important;
    display: none !important;
}

/* 2. ANCHOR: Ensure the container is ready for the dot */
.nav-item {
    position: relative; 
}

/* 3. THE ONE TRUE DOT: Applied only when 'has-unread' is active */
.nav-item.has-unread::after {
    content: '';
    position: absolute;
    top: 5px;      
    right: 25%;    /* Centered relative to the column width */
    width: 10px;
    height: 10px;
    background-color: var(--danger, #ef4444);
    border-radius: 50%;
    border: 2px solid white; 
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    display: block;
    z-index: 10;
    pointer-events: none; /* Let clicks pass through */
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}

/* 4. CLEANUP: Hide the old manual badge class to prevent conflicts */
.nav-badge { display: none !important; }


/* FILTER CHIPS BAR */
.filter-bar {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 10px 1rem;
    white-space: nowrap;
    background: white;
    border-bottom: 1px solid #eee;
    /* Hide scrollbar for clean look */
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}
.filter-bar::-webkit-scrollbar { display: none; } /* Chrome/Safari */

.filter-chip {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--dark);
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.filter-chip:hover { background: #e2e8f0; }

.filter-chip.active {
    background: var(--dark);
    color: white;
    border-color: var(--dark);
}