/* ============================================================
   EggyNet Platform — Custom Styles
   Bootstrap 5.3 augmentation
============================================================ */

/* ── CSS Variables ── */
:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 0px;
    --sidebar-bg: #1a1d23;
    --sidebar-border: rgba(255,255,255,0.07);
    --sidebar-text: rgba(255,255,255,0.75);
    --sidebar-text-muted: rgba(255,255,255,0.4);
    --sidebar-active-bg: rgba(79,70,229,0.3);
    --sidebar-active-border: #6366f1;
    --sidebar-hover-bg: rgba(255,255,255,0.06);
    --brand-gradient: linear-gradient(135deg, #4f46e5, #7c3aed);
    --card-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --card-hover-shadow: 0 4px 12px rgba(0,0,0,0.12), 0 2px 4px rgba(0,0,0,0.08);
    --top-navbar-height: 60px;
}

/* ── Layout ── */
* { box-sizing: border-box; }

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #f5f6fa;
    color: #1f2937;
    min-height: 100vh;
}

.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
}

.sidebar-collapsed {
    width: 0;
    overflow: hidden;
}

/* Purple sidebar for Data Collectors and Managers */
.sidebar-member {
    --sidebar-bg: #3b1f6e;
    --sidebar-border: rgba(255,255,255,0.1);
    --sidebar-text: rgba(255,255,255,0.82);
    --sidebar-text-muted: rgba(255,255,255,0.45);
    --sidebar-active-bg: rgba(167,139,250,0.25);
    --sidebar-active-border: #a78bfa;
    --sidebar-hover-bg: rgba(255,255,255,0.08);
    background: var(--sidebar-bg);
}

.sidebar-member .org-badge {
    background: rgba(167,139,250,0.2);
    border-color: rgba(167,139,250,0.35);
    color: #ddd6fe;
}

/* Sidebar Brand */
.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--sidebar-border);
    min-height: 64px;
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.brand-icon {
    font-size: 1.5rem;
    line-height: 1;
}

.brand-text {
    font-size: 1.125rem;
    font-weight: 700;
    color: #ffffff;
    white-space: nowrap;
    letter-spacing: -0.3px;
}

.sidebar-toggle {
    padding: 4px 6px !important;
    opacity: 0.5;
    transition: opacity 0.2s;
}
.sidebar-toggle:hover { opacity: 1; }

/* Org Badge */
.sidebar-org {
    padding: 8px 12px;
    border-bottom: 1px solid var(--sidebar-border);
}

.org-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: rgba(79,70,229,0.25);
    border: 1px solid rgba(99,102,241,0.35);
    border-radius: 8px;
    color: #a5b4fc;
    font-size: 0.8rem;
    font-weight: 500;
}

.org-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Sidebar Nav */
.sidebar-nav {
    list-style: none;
    padding: 8px 8px;
    margin: 0;
    flex: 1;
}

.nav-section-label {
    color: var(--sidebar-text-muted);
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 12px 10px 4px;
}

.nav-item .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 450;
    transition: background 0.15s, color 0.15s;
    border-left: 3px solid transparent;
    white-space: nowrap;
}

.nav-item .nav-link i {
    font-size: 1rem;
    flex-shrink: 0;
    width: 18px;
    text-align: center;
}

.nav-item .nav-link:hover {
    background: var(--sidebar-hover-bg);
    color: #ffffff;
}

.nav-item .nav-link.active {
    background: var(--sidebar-active-bg);
    color: #ffffff;
    border-left-color: var(--sidebar-active-border);
    font-weight: 600;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--sidebar-border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 8px;
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--brand-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.user-details {
    overflow: hidden;
}

.user-name {
    color: #ffffff;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    color: var(--sidebar-text-muted);
    font-size: 0.7rem;
    white-space: nowrap;
}

/* ── Main Content ── */
.main-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── Top Navbar ── */
.top-navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: var(--top-navbar-height);
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 50;
    flex-shrink: 0;
}

/* User dropdown button */
.user-dropdown-btn {
    background: transparent;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 6px 12px 6px 8px;
    font-size: 0.875rem;
    color: #374151;
    transition: background 0.15s;
}

.user-dropdown-btn:hover {
    background: #f3f4f6;
    color: #111827;
}

.nav-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--brand-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    flex-shrink: 0;
}

/* ── Flash Messages ── */
.flash-container .alert {
    border-radius: 10px;
    border: none;
    font-size: 0.9rem;
}

/* ── Page Content ── */
.page-content {
    flex: 1;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #111827;
    letter-spacing: -0.3px;
}

/* ── Stat Cards ── */
.stat-card {
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    transition: box-shadow 0.2s, transform 0.18s;
    overflow: hidden;
    position: relative;
    background: #fff;
}

.stat-card:hover {
    box-shadow: 0 8px 24px rgba(0,0,0,0.11), 0 2px 6px rgba(0,0,0,0.07);
    transform: translateY(-3px);
}

/* Colored top accent per card type */
.stat-card.accent-primary  { border-top: 4px solid #4f46e5; }
.stat-card.accent-success  { border-top: 4px solid #10b981; }
.stat-card.accent-info     { border-top: 4px solid #3b82f6; }
.stat-card.accent-warning  { border-top: 4px solid #f59e0b; }

.stat-card .card-body {
    padding: 1.25rem 1.25rem 1rem;
    position: relative;
    overflow: hidden;
}

/* Ghost icon watermark in the background */
.stat-bg-icon {
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 4.5rem;
    opacity: 0.07;
    pointer-events: none;
    line-height: 1;
}

.stat-value {
    font-size: 2.1rem;
    font-weight: 800;
    color: #111827;
    line-height: 1.1;
    margin: 6px 0 4px;
    letter-spacing: -0.5px;
}

.stat-label {
    font-size: 0.72rem;
    color: #6b7280;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-sub {
    font-size: 0.78rem;
    color: #9ca3af;
    margin-top: 2px;
}

/* Legacy small icon box (kept for admin dashboard cards) */
.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.25rem;
}

/* ── General Cards ── */
.card {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
}

.card-header {
    background: #ffffff;
    border-bottom: 1px solid #f3f4f6;
    padding: 14px 16px;
    font-weight: 600;
    border-radius: 12px 12px 0 0;
}

/* ── Status Badges ── */
.badge-status-active {
    background: #dcfce7;
    color: #166534;
    font-weight: 600;
}

.badge-status-inactive {
    background: #f3f4f6;
    color: #6b7280;
    font-weight: 600;
}

.badge-status-suspended {
    background: #fee2e2;
    color: #991b1b;
    font-weight: 600;
}

.badge-status-pending {
    background: #fef3c7;
    color: #92400e;
    font-weight: 600;
}

/* ── Status Dot (inline) ── */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
}

.status-dot.status-available { background: #28a745; }
.status-dot.status-assigned { background: #007bff; }
.status-dot.status-maintenance { background: #ffc107; }
.status-dot.status-retired { background: #6c757d; }
.status-dot.status-active { background: #28a745; }
.status-dot.status-inactive { background: #6c757d; }
.status-dot.status-suspended { background: #dc3545; }

/* ── Avatar Sizes ── */
.avatar-xs {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--brand-gradient);
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    flex-shrink: 0;
}

.avatar-sm {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--brand-gradient);
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}

.avatar-md {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--brand-gradient);
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 700;
    flex-shrink: 0;
}

/* ── Upload Drop Zone ── */
.upload-drop-zone {
    border: 2.5px dashed #d1d5db;
    border-radius: 16px;
    background: #f9fafb;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.upload-drop-zone:hover,
.upload-drop-zone.drag-over {
    border-color: #6366f1;
    background: rgba(99,102,241,0.05);
}

.upload-drop-zone.drag-over .drop-zone-content {
    opacity: 0.7;
}

/* File Upload Item */
.upload-file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 8px;
    background: #fff;
}

.upload-file-item .file-icon {
    font-size: 1.5rem;
    color: #6b7280;
    flex-shrink: 0;
}

.upload-file-item .file-info {
    flex: 1;
    min-width: 0;
}

.upload-file-item .file-name {
    font-weight: 500;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.upload-file-item .file-size {
    font-size: 0.75rem;
    color: #9ca3af;
}

.upload-progress-bar {
    height: 4px;
    border-radius: 2px;
    background: #e5e7eb;
    overflow: hidden;
    margin-top: 6px;
}

.upload-progress-fill {
    height: 100%;
    border-radius: 2px;
    background: linear-gradient(90deg, #4f46e5, #7c3aed);
    transition: width 0.3s;
}

.upload-status-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

/* ── Equipment Cards ── */
.equipment-card {
    border-radius: 12px;
    transition: box-shadow 0.2s, transform 0.2s;
}

.equipment-card:hover {
    box-shadow: var(--card-hover-shadow);
    transform: translateY(-2px);
}

.equipment-icon {
    width: 38px;
    height: 38px;
    background: #f3f4f6;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.assigned-to {
    border-radius: 8px;
}

/* ── Permission Toggles ── */
.permission-table .form-check-input {
    cursor: pointer;
    width: 2em;
    height: 1em;
}

.permission-table .form-check-input:checked {
    background-color: #4f46e5;
    border-color: #4f46e5;
}

.permission-toggle:focus {
    box-shadow: 0 0 0 0.2rem rgba(79,70,229,0.25);
}

/* ── Breadcrumb ── */
.breadcrumb {
    font-size: 0.85rem;
}

.breadcrumb-item a {
    color: #6b7280;
    text-decoration: none;
}

.breadcrumb-item a:hover {
    color: #4f46e5;
}

/* ── Tables ── */
.table {
    font-size: 0.875rem;
}

.table > :not(caption) > * > * {
    padding: 12px 8px;
    vertical-align: middle;
}

.table-hover > tbody > tr:hover > * {
    background: #f9fafb;
}

/* ── Scrollbar ── */
.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
}

/* ── Progress Bar ── */
.progress {
    background: #e5e7eb;
}

/* ── Utility ── */
.font-monospace { font-family: 'SF Mono', 'Fira Code', 'Courier New', monospace; }
.text-gradient { background: var(--brand-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

/* ── Forms ── */
.form-control:focus,
.form-select:focus {
    border-color: #a5b4fc;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

.input-group-text {
    background: #f9fafb;
    border-color: #d1d5db;
}

/* ── Buttons ── */
.btn-primary {
    background: var(--brand-gradient);
    border: none;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79,70,229,0.35);
    filter: brightness(1.05);
}

.btn-primary:active {
    transform: translateY(0);
}

/* ── Dropdown ── */
.dropdown-menu {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 6px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.dropdown-item {
    border-radius: 6px;
    font-size: 0.875rem;
    padding: 8px 12px;
    transition: background 0.1s;
}

.dropdown-item:hover {
    background: #f3f4f6;
}

/* ── Modals ── */
.modal-content {
    border: none;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal-header {
    border-bottom: 1px solid #f3f4f6;
    padding: 16px 20px;
}

.modal-footer {
    border-top: 1px solid #f3f4f6;
    padding: 12px 20px;
}

/* ── Responsive ── */
@media (max-width: 767.98px) {
    .sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        z-index: 1050;
        box-shadow: 4px 0 20px rgba(0,0,0,0.3);
        transition: left 0.25s ease;
    }

    .sidebar.sidebar-open {
        left: 0;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1040;
    }

    .sidebar-overlay.active {
        display: block;
    }

    .main-content {
        width: 100%;
    }

    .hamburger-btn {
        display: flex !important;
    }

    .page-content {
        padding: 16px !important;
    }

    .top-navbar {
        padding: 0 12px;
    }
}

@media (min-width: 768px) {
    .hamburger-btn {
        display: none !important;
    }
}

@media (max-width: 575.98px) {
    .stat-value {
        font-size: 1.5rem;
    }
}
