/**
 * VQ Inventory - Custom Styles
 *
 * Corporate color palette with dark navy navbar, clean white content,
 * subtle gray sidebar for admin. Mobile-first, professional SaaS look.
 *
 * @author J.J. Johnson <visionquest716@gmail.com>
 */

/* ─── CSS Variables ───────────────────────────────────────────── */
:root {
    --primary: #1e3a5f;
    --secondary: #2c5282;
    --accent: #e53e3e;
    --bg: #f8f9fa;
    --sidebar-bg: #f1f3f5;
    --sidebar-width: 250px;
    --navbar-height: 60px;
    --text-dark: #212529;
    --text-muted: #6c757d;
    --border-color: #dee2e6;
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --card-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.12);
    --transition-speed: 0.2s;

    /* Legacy aliases for existing partials */
    --vq-primary: #1e3a5f;
    --vq-secondary: #2c5282;
    --vq-accent: #e53e3e;
    --vq-light: #f8f9fa;
    --vq-dark: #1a1a2e;
    --vq-text: #333333;
    --vq-border: #dee2e6;
}

/* ─── Base ────────────────────────────────────────────────────── */
body {
    font-family: Arial, Helvetica, sans-serif;
    background-color: var(--bg);
    color: var(--text-dark);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--secondary);
    transition: color var(--transition-speed);
}

a:hover {
    color: var(--primary);
}

/* ─── Navbar ──────────────────────────────────────────────────── */
#mainNavbar {
    background-color: var(--primary) !important;
    min-height: var(--navbar-height);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    z-index: 1040;
}

#mainNavbar .navbar-brand {
    color: #fff;
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: 0.5px;
}

#mainNavbar .nav-link {
    color: rgba(255, 255, 255, 0.85);
    font-weight: 500;
    padding: 0.5rem 0.85rem;
    border-radius: 4px;
    transition: color var(--transition-speed), background-color var(--transition-speed);
}

#mainNavbar .nav-link:hover,
#mainNavbar .nav-link.active {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.12);
}

#mainNavbar .navbar-text {
    font-size: 0.875rem;
}

#mainNavbar .dropdown-menu {
    border: 1px solid var(--border-color);
    box-shadow: var(--card-shadow-hover);
}

/* ─── App Wrapper (sidebar + content) ─────────────────────────── */
.app-wrapper {
    display: flex;
    min-height: calc(100vh - var(--navbar-height));
    padding-top: var(--navbar-height);
}

/* ─── Admin Sidebar ───────────────────────────────────────────── */
.admin-sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    padding: 1rem 0;
    overflow-y: auto;
    height: calc(100vh - var(--navbar-height));
    position: sticky;
    top: var(--navbar-height);
    transition: margin-left var(--transition-speed) ease;
    z-index: 1020;
}

.sidebar-header {
    padding: 0.5rem 1.25rem 0.75rem;
}

.sidebar-section-label {
    display: block;
    padding: 0 1.25rem;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.05em;
}

.sidebar-nav .nav-link {
    color: var(--text-dark);
    padding: 0.5rem 1.25rem;
    font-size: 0.9rem;
    border-left: 3px solid transparent;
    transition: all var(--transition-speed);
    background-color: transparent;
}

.sidebar-nav .nav-link:hover {
    background-color: rgba(30, 58, 95, 0.06);
    color: var(--primary);
    border-left-color: var(--secondary);
}

.sidebar-nav .nav-link.active {
    background-color: rgba(30, 58, 95, 0.1);
    color: var(--primary);
    font-weight: 600;
    border-left-color: var(--primary);
}

.sidebar-nav .nav-link i {
    width: 1.25rem;
    text-align: center;
}

.sidebar-divider hr {
    border-color: var(--border-color);
    opacity: 0.5;
}

.sidebar-toggle-btn {
    position: fixed;
    bottom: 1rem;
    left: 1rem;
    z-index: 1050;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--card-shadow-hover);
}

/* ─── Main Content ────────────────────────────────────────────── */
.main-content {
    flex: 1;
    min-width: 0;
    overflow-x: hidden;
}

.content-inner {
    max-width: 1400px;
}

/* ─── Cards ───────────────────────────────────────────────────── */
.card {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--card-shadow);
    transition: box-shadow var(--transition-speed);
}

.card:hover {
    box-shadow: var(--card-shadow-hover);
}

.card-header {
    background-color: #fff;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
}

/* ─── Entity Cards (grid view) ────────────────────────────────── */
.entity-card {
    border-left: 4px solid var(--primary);
    border-radius: 8px;
    transition: all var(--transition-speed);
    cursor: pointer;
}

.entity-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--card-shadow-hover);
    border-left-color: var(--accent);
}

.entity-card .entity-name {
    font-weight: 600;
    font-size: 1rem;
    color: var(--primary);
}

.entity-card .entity-type {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.entity-card .entity-location {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.entity-card .entity-thumb {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
}

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

.table thead th {
    background-color: var(--primary);
    color: #fff;
    font-weight: 600;
    border: none;
    white-space: nowrap;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: rgba(30, 58, 95, 0.03);
}

.table-hover > tbody > tr:hover > * {
    background-color: rgba(30, 58, 95, 0.07);
}

.table td {
    vertical-align: middle;
}

/* ─── Status Badges ───────────────────────────────────────────── */
.badge-status-active,
.badge-active {
    background-color: #28a745;
    color: #fff;
}

.badge-status-inactive,
.badge-inactive {
    background-color: #6c757d;
    color: #fff;
}

.badge-status-retired,
.badge-retired {
    background-color: #8B4513;
    color: #fff;
}

.badge-status-consumed,
.badge-consumed {
    background-color: #fd7e14;
    color: #fff;
}

.badge-status-maintenance {
    background-color: #ffc107;
    color: #212529;
}

.badge-status-reserved {
    background-color: var(--secondary);
    color: #fff;
}

/* ─── Buttons ─────────────────────────────────────────────────── */
.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: #162d4a;
    border-color: #162d4a;
}

.btn-secondary {
    background-color: var(--secondary);
    border-color: var(--secondary);
}

.btn-secondary:hover,
.btn-secondary:focus {
    background-color: #234a72;
    border-color: #234a72;
}

.btn-accent {
    background-color: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn-accent:hover,
.btn-accent:focus {
    background-color: #c53030;
    border-color: #c53030;
    color: #fff;
}

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}

.btn-outline-primary:hover {
    background-color: var(--primary);
    color: #fff;
}

/* ─── Forms ───────────────────────────────────────────────────── */
.form-label {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-dark);
    margin-bottom: 0.35rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--secondary);
    box-shadow: 0 0 0 0.2rem rgba(44, 82, 130, 0.2);
}

.form-control.is-invalid:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 0.2rem rgba(229, 62, 62, 0.2);
}

.form-text {
    font-size: 0.8rem;
}

/* Required field indicator */
.form-label.required::after {
    content: " *";
    color: var(--accent);
}

/* ─── Auth Pages ──────────────────────────────────────────────── */
.auth-card {
    max-width: 420px;
    margin: 3rem auto;
}

.auth-card .card-header {
    text-align: center;
    padding: 1.25rem;
    background-color: var(--primary);
    color: #fff;
    border-radius: 8px 8px 0 0 !important;
}

/* ─── Flash Messages ──────────────────────────────────────────── */
.flash-message {
    animation: flashSlideIn 0.4s ease-out;
}

.flash-message.fade-out {
    animation: flashFadeOut 0.4s ease-in forwards;
}

@keyframes flashSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes flashFadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

/* ─── Breadcrumbs ─────────────────────────────────────────────── */
.breadcrumb {
    background-color: transparent;
    padding: 0;
    font-size: 0.85rem;
}

.breadcrumb-item a {
    color: var(--secondary);
    text-decoration: none;
}

.breadcrumb-item a:hover {
    color: var(--primary);
    text-decoration: underline;
}

.breadcrumb-item.active {
    color: var(--text-muted);
}

/* ─── Error Pages ─────────────────────────────────────────────── */
.error-icon i {
    opacity: 0.8;
}

/* ─── Search / Filter Bar ─────────────────────────────────────── */
.search-bar {
    position: relative;
    max-width: 500px;
}

.search-bar .form-control {
    padding-left: 2.5rem;
}

.search-bar .search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    z-index: 5;
}

/* ─── Dashboard Stats Cards ───────────────────────────────────── */
.stat-card {
    border: none;
    border-left: 4px solid var(--primary);
    border-radius: 10px;
    box-shadow: var(--card-shadow);
    transition: all var(--transition-speed);
}

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

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ─── Empty State ─────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
}

.empty-state .empty-icon {
    font-size: 4rem;
    color: var(--border-color);
    margin-bottom: 1rem;
}

.empty-state h4 {
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ─── Pagination ──────────────────────────────────────────────── */
.page-link {
    color: var(--primary);
}

.page-item.active .page-link {
    background-color: var(--primary);
    border-color: var(--primary);
}

.page-link:hover {
    color: var(--secondary);
}

/* ─── Footer ──────────────────────────────────────────────────── */
.site-footer {
    background-color: #fff;
    border-top: 1px solid var(--border-color);
    font-size: 0.85rem;
    margin-top: auto;
}

.site-footer a:hover {
    color: var(--primary) !important;
}

/* Legacy footer support */
footer.bg-dark {
    border-top: 3px solid var(--primary);
}

/* ─── Utility ─────────────────────────────────────────────────── */
.text-primary {
    color: var(--primary) !important;
}

.bg-primary {
    background-color: var(--primary) !important;
}

.text-accent {
    color: var(--accent) !important;
}

.border-primary {
    border-color: var(--primary) !important;
}

.cursor-pointer {
    cursor: pointer;
}

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

/* ─── Mobile Responsive ──────────────────────────────────────── */
@media (max-width: 991.98px) {
    .admin-sidebar {
        position: fixed;
        left: 0;
        top: var(--navbar-height);
        height: calc(100vh - var(--navbar-height));
        margin-left: calc(-1 * var(--sidebar-width));
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
        z-index: 1030;
        background-color: #fff;
    }

    .admin-sidebar.show {
        margin-left: 0;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: var(--navbar-height);
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 1025;
    }

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

    .main-content {
        width: 100%;
    }

    .content-inner {
        padding: 1rem !important;
    }

    /* Stack forms on mobile */
    .form-row-desktop {
        flex-direction: column;
    }

    /* Full-width tables with horizontal scroll */
    .table-responsive-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 575.98px) {
    .entity-card .entity-thumb {
        width: 45px;
        height: 45px;
    }

    .stat-card .stat-value {
        font-size: 1.35rem;
    }

    h1, .h1 {
        font-size: 1.5rem;
    }

    h2, .h2 {
        font-size: 1.25rem;
    }

    .table-responsive {
        font-size: 0.875rem;
    }
}

/* ─── Hero Banner ────────────────────────────────────────────── */
.hero-banner {
    position: relative;
    overflow: hidden;
    background: linear-gradient(145deg, #0f2439 0%, var(--primary) 35%, var(--secondary) 70%, #1a4a7a 100%);
    padding: 6rem 0 5rem;
    margin-top: -1rem;
    text-align: center;
    color: #fff;
    min-height: 520px;
    display: flex;
    align-items: center;
}

/* Subtle dot grid overlay */
.hero-grid {
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px);
    background-size: 32px 32px;
    z-index: 1;
}

/* Animated glow orbs */
.hero-glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.3;
    z-index: 1;
}

.hero-glow--1 {
    width: 500px;
    height: 500px;
    background: var(--accent);
    top: -15%;
    right: -8%;
    animation: heroFloat 8s ease-in-out infinite;
}

.hero-glow--2 {
    width: 400px;
    height: 400px;
    background: #4a90d9;
    bottom: -20%;
    left: -5%;
    animation: heroFloat 10s ease-in-out infinite reverse;
}

.hero-glow--3 {
    width: 300px;
    height: 300px;
    background: #38b2ac;
    top: 40%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0.15;
    animation: heroFloat 12s ease-in-out infinite 2s;
}

/* Geometric accent shapes */
.hero-shape--1 {
    position: absolute;
    width: 200px;
    height: 200px;
    border: 2px solid rgba(255, 255, 255, 0.06);
    border-radius: 24px;
    top: 10%;
    left: 8%;
    transform: rotate(35deg);
    z-index: 1;
    animation: heroRotateSlow 20s linear infinite;
}

.hero-shape--2 {
    position: absolute;
    width: 140px;
    height: 140px;
    border: 2px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    bottom: 12%;
    right: 10%;
    transform: rotate(-20deg);
    z-index: 1;
    animation: heroRotateSlow 25s linear infinite reverse;
}

.hero-shape--ring {
    position: absolute;
    width: 350px;
    height: 350px;
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
}

.hero-shape--ring::after {
    content: '';
    position: absolute;
    inset: 30px;
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 50%;
}

/* Horizontal scanline sweep */
.hero-scanline {
    position: absolute;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.08) 50%, transparent 100%);
    z-index: 1;
    animation: heroScanline 6s ease-in-out infinite;
}

/* Floating dot cluster (top-right) */
.hero-dots {
    position: absolute;
    width: 120px;
    height: 120px;
    top: 15%;
    right: 15%;
    z-index: 1;
    background-image:
        radial-gradient(rgba(255, 255, 255, 0.25) 2px, transparent 2px),
        radial-gradient(rgba(255, 255, 255, 0.15) 2px, transparent 2px);
    background-size: 20px 20px;
    background-position: 0 0, 10px 10px;
    opacity: 0.5;
    animation: heroFloat 7s ease-in-out infinite 1s;
}

/* Content z-index */
.hero-content {
    z-index: 2;
}

/* Status badge pill */
.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    animation: heroFadeUp 0.6s ease-out both;
}

.hero-badge__dot {
    width: 6px;
    height: 6px;
    background: #38b2ac;
    border-radius: 50%;
    animation: heroPulse 2s ease-in-out infinite;
}

/* Title */
.hero-title {
    font-size: 3.25rem;
    font-weight: 800;
    line-height: 1.15;
    margin-bottom: 1.25rem;
    letter-spacing: -0.02em;
    animation: heroFadeUp 0.6s ease-out 0.15s both;
}

.hero-title--accent {
    background: linear-gradient(135deg, #e53e3e 0%, #fc8181 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Subtitle */
.hero-subtitle {
    font-size: 1.15rem;
    max-width: 600px;
    color: rgba(255, 255, 255, 0.75);
    line-height: 1.7;
    margin-bottom: 2rem;
    animation: heroFadeUp 0.6s ease-out 0.3s both;
}

/* Hero buttons */
.btn-hero-primary {
    background: var(--accent);
    border: 2px solid var(--accent);
    color: #fff;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.25s ease;
    animation: heroFadeUp 0.6s ease-out 0.45s both;
}

.btn-hero-primary:hover {
    background: #c53030;
    border-color: #c53030;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(229, 62, 62, 0.35);
}

.btn-hero-outline {
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.35);
    color: #fff;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.25s ease;
    animation: heroFadeUp 0.6s ease-out 0.45s both;
}

.btn-hero-outline:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.6);
    color: #fff;
    transform: translateY(-2px);
}

/* Stats row */
.hero-stats {
    display: inline-flex;
    align-items: center;
    gap: 2rem;
    padding: 1.25rem 2.5rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    backdrop-filter: blur(8px);
    animation: heroFadeUp 0.6s ease-out 0.6s both;
}

.hero-stat {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.hero-stat__value {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
}

.hero-stat__label {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.hero-stat__divider {
    width: 1px;
    height: 36px;
    background: rgba(255, 255, 255, 0.15);
}

/* Animations */
@keyframes heroFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

@keyframes heroRotateSlow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes heroScanline {
    0% { top: 0; opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { top: 100%; opacity: 0; }
}

@keyframes heroPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.5); }
}

@keyframes heroFadeUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Hero mobile adjustments */
@media (max-width: 991.98px) {
    .hero-banner {
        padding: 4rem 0 3.5rem;
        min-height: auto;
    }

    .hero-title {
        font-size: 2.25rem;
    }

    .hero-dots,
    .hero-shape--1,
    .hero-shape--2 {
        display: none;
    }
}

@media (max-width: 575.98px) {
    .hero-banner {
        padding: 3rem 0 2.5rem;
    }

    .hero-title {
        font-size: 1.75rem;
    }

    .hero-subtitle {
        font-size: 1rem;
    }

    .hero-stats {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem 1.5rem;
    }

    .hero-stat__divider {
        width: 60px;
        height: 1px;
    }

    .hero-shape--ring {
        width: 200px;
        height: 200px;
    }
}

/* ─── Print Styles ────────────────────────────────────────────── */
@media print {
    .admin-sidebar,
    .sidebar-toggle-btn,
    #mainNavbar,
    .site-footer,
    footer.bg-dark,
    .btn,
    .flash-message,
    .breadcrumb {
        display: none !important;
    }

    .app-wrapper {
        padding-top: 0;
    }

    .main-content {
        width: 100%;
    }

    .content-inner {
        padding: 0 !important;
    }

    body {
        background: #fff;
        color: #000;
        font-size: 12pt;
    }

    .card {
        border: 1px solid #ccc;
        box-shadow: none;
        break-inside: avoid;
    }

    .table thead th {
        background-color: #eee !important;
        color: #000 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    a[href]::after {
        content: none;
    }
}
