/* backend/src/main/resources/static/css/app.css */

:root {
    --sam-sidebar-width: 268px;
    --sam-navbar-height: 64px;
    --sam-bg: #f1f5f9;
    --sam-surface: #ffffff;
    --sam-sidebar-bg: #0b1220;
    --sam-sidebar-surface: #131c31;
    --sam-sidebar-hover: rgba(148, 163, 184, 0.12);
    --sam-sidebar-active: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
    --sam-border: #e2e8f0;
    --sam-text: #0f172a;
    --sam-muted: #64748b;
    --sam-primary: #2563eb;
    --sam-primary-dark: #1d4ed8;
    --sam-indigo: #4f46e5;
    --sam-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --sam-shadow: 0 4px 12px -2px rgba(15, 23, 42, 0.06), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
    --sam-shadow-lg: 0 20px 45px -12px rgba(15, 23, 42, 0.22);
}

body {
    background-color: var(--sam-bg);
    font-family: "Be Vietnam Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    color: var(--sam-text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    letter-spacing: -0.005em;
}

/* ---------- Shell Layout ---------- */
.sam-navbar {
    height: var(--sam-navbar-height);
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--sam-border);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
    z-index: 1030;
}

.sam-brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 0.7rem;
    background: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.28);
    flex-shrink: 0;
}

.sam-logo-img {
    width: 40px;
    height: 40px;
    border-radius: 0.65rem;
    background: #ffffff;
    padding: 2px;
    object-fit: contain;
    border: 1px solid rgba(37, 99, 235, 0.16);
    box-shadow: 0 3px 10px rgba(15, 23, 42, 0.1);
    flex-shrink: 0;
}

.sam-logo-img-lg {
    width: 54px;
    height: 54px;
    border-radius: 0.9rem;
    padding: 4px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.35);
}

.sam-wrapper {
    display: flex;
    padding-top: var(--sam-navbar-height);
    min-height: 100vh;
}

.sam-sidebar {
    width: var(--sam-sidebar-width);
    background: var(--sam-sidebar-bg);
    color: #cbd5e1;
    position: fixed;
    top: var(--sam-navbar-height);
    bottom: 0;
    left: 0;
    overflow-y: auto;
    padding: 1rem 0.85rem 2rem;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    z-index: 1020;
}

.sam-sidebar::-webkit-scrollbar {
    width: 6px;
}

.sam-sidebar::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.25);
    border-radius: 999px;
}

.sam-sidebar .nav-section-title,
.sam-sidebar-offcanvas .nav-section-title {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
    padding: 1rem 0.75rem 0.4rem;
}

.sam-sidebar .nav-link,
.sam-sidebar-offcanvas .nav-link {
    color: #94a3b8;
    border-radius: 0.6rem;
    padding: 0.6rem 0.8rem;
    margin-bottom: 0.18rem;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    font-size: 0.89rem;
    font-weight: 500;
    transition: background-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.sam-sidebar .nav-link i,
.sam-sidebar-offcanvas .nav-link i {
    font-size: 1.05rem;
    width: 1.25rem;
    text-align: center;
    opacity: 0.88;
}

.sam-sidebar .nav-link:hover,
.sam-sidebar-offcanvas .nav-link:hover {
    background: var(--sam-sidebar-hover);
    color: #f8fafc;
}

.sam-sidebar .nav-link.active,
.sam-sidebar-offcanvas .nav-link.active {
    background: var(--sam-sidebar-active);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 6px 14px -3px rgba(37, 99, 235, 0.45);
}

.sam-sidebar .nav-link.active i,
.sam-sidebar-offcanvas .nav-link.active i {
    opacity: 1;
}

.sam-sidebar-offcanvas {
    background: var(--sam-sidebar-bg);
    color: #cbd5e1;
    width: 280px !important;
}

.sam-sidebar-offcanvas .sam-sidebar-inner {
    padding: 0.5rem 0.85rem 2rem;
}

.sam-main {
    flex: 1;
    margin-left: var(--sam-sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sam-content {
    flex: 1;
    padding: 1.5rem 1.75rem;
}

.sam-footer {
    border-top: 1px solid var(--sam-border);
    background: #ffffff;
    padding: 0.85rem 1.75rem;
    font-size: 0.82rem;
    color: var(--sam-muted);
}

@media (max-width: 991.98px) {
    .sam-sidebar {
        display: none;
    }
    .sam-main {
        margin-left: 0;
    }
    .sam-content {
        padding: 1rem;
    }
    .sam-footer {
        padding: 0.85rem 1rem;
    }
}

/* ---------- Professional Button System ---------- */
.btn {
    border-radius: 0.55rem;
    font-weight: 500;
    letter-spacing: -0.005em;
    transition: all 0.16s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
}

.btn:not(:disabled):not(.disabled):hover {
    transform: translateY(-1px);
}

.btn:not(:disabled):not(.disabled):active {
    transform: translateY(0);
}

.btn-sm {
    border-radius: 0.48rem;
    padding: 0.36rem 0.72rem;
    font-size: 0.82rem;
}

.btn-lg {
    border-radius: 0.65rem;
    padding: 0.7rem 1.25rem;
    font-weight: 600;
}

.btn-primary {
    background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
    border-color: #2563eb;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.26);
}

.btn-primary:hover,
.btn-primary:focus-visible {
    background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
    border-color: #1d4ed8;
    box-shadow: 0 5px 12px rgba(37, 99, 235, 0.34);
}

.btn-success {
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
    border-color: #16a34a;
    box-shadow: 0 2px 6px rgba(22, 163, 74, 0.24);
}

.btn-success:hover,
.btn-success:focus-visible {
    background: linear-gradient(135deg, #15803d 0%, #166534 100%);
    border-color: #15803d;
    box-shadow: 0 5px 12px rgba(22, 163, 74, 0.32);
}

.btn-danger {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    border-color: #dc2626;
    box-shadow: 0 2px 6px rgba(220, 38, 38, 0.24);
}

.btn-danger:hover,
.btn-danger:focus-visible {
    background: linear-gradient(135deg, #b91c1c 0%, #991b1b 100%);
    border-color: #b91c1c;
    box-shadow: 0 5px 12px rgba(220, 38, 38, 0.32);
}

.btn-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    border-color: #f59e0b;
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.26);
}

.btn-warning:hover,
.btn-warning:focus-visible {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    border-color: #d97706;
    color: #ffffff;
    box-shadow: 0 5px 12px rgba(245, 158, 11, 0.34);
}

.btn-dark {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border-color: #0f172a;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.22);
}

.btn-dark:hover,
.btn-dark:focus-visible {
    background: #0f172a;
    border-color: #0f172a;
    box-shadow: 0 5px 12px rgba(15, 23, 42, 0.3);
}

.btn-outline-primary {
    color: #2563eb;
    border-color: #bfdbfe;
    background-color: #eff6ff;
}

.btn-outline-primary:hover {
    color: #ffffff;
    background-color: #2563eb;
    border-color: #2563eb;
}

.btn-outline-danger {
    color: #dc2626;
    border-color: #fecaca;
    background-color: #fef2f2;
}

.btn-outline-danger:hover {
    color: #ffffff;
    background-color: #dc2626;
    border-color: #dc2626;
}

.btn-outline-success {
    color: #15803d;
    border-color: #bbf7d0;
    background-color: #f0fdf4;
}

.btn-outline-success:hover {
    color: #ffffff;
    background-color: #16a34a;
    border-color: #16a34a;
}

.btn-outline-warning {
    color: #b45309;
    border-color: #fde68a;
    background-color: #fffbeb;
}

.btn-outline-warning:hover {
    color: #ffffff;
    background-color: #d97706;
    border-color: #d97706;
}

.btn-outline-secondary {
    color: #475569;
    border-color: #cbd5e1;
    background-color: #ffffff;
}

.btn-outline-secondary:hover {
    color: #0f172a;
    background-color: #f1f5f9;
    border-color: #94a3b8;
}

.btn-outline-info {
    color: #0369a1;
    border-color: #bae6fd;
    background-color: #f0f9ff;
}

.btn-outline-info:hover {
    color: #ffffff;
    background-color: #0284c7;
    border-color: #0284c7;
}

.btn-outline-dark {
    color: #1e293b;
    border-color: #cbd5e1;
    background-color: #f8fafc;
}

.btn-outline-dark:hover {
    color: #ffffff;
    background-color: #0f172a;
    border-color: #0f172a;
}

.btn-light {
    background-color: #f8fafc;
    border-color: #e2e8f0;
    color: #1e293b;
}

.btn-light:hover {
    background-color: #f1f5f9;
    border-color: #cbd5e1;
}

/* Compact icon-only table action buttons */
.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 0.5rem;
}

.input-group .btn:hover,
.btn-group .btn:hover {
    transform: none;
}

.btn-group .btn {
    border-radius: 0;
}

.btn-group > .btn:first-child {
    border-top-left-radius: 0.5rem;
    border-bottom-left-radius: 0.5rem;
}

.btn-group > .btn:last-child {
    border-top-right-radius: 0.5rem;
    border-bottom-right-radius: 0.5rem;
}

.btn-link {
    display: inline-flex;
    align-items: center;
}

.btn-link:hover {
    transform: none;
}

/* ---------- Cards & KPI ---------- */
.card {
    border: 1px solid var(--sam-border);
    border-radius: 0.85rem;
    background: var(--sam-surface);
    box-shadow: var(--sam-shadow);
    overflow: hidden;
}

.card-header {
    background-color: #ffffff;
    border-bottom: 1px solid #f1f5f9;
    padding: 0.95rem 1.25rem;
    font-weight: 600;
    font-size: 0.94rem;
    color: #0f172a;
}

.card-footer {
    border-top: 1px solid #f1f5f9;
}

.kpi-card {
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 22px -6px rgba(15, 23, 42, 0.1);
}

.kpi-card .h4,
.kpi-card .h3 {
    font-variant-numeric: tabular-nums;
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 0.8rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    flex-shrink: 0;
}

/* ---------- Forms & Inputs ---------- */
.form-control,
.form-select {
    border-color: #cbd5e1;
    border-radius: 0.55rem;
    color: #0f172a;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3.5px rgba(37, 99, 235, 0.14);
}

.input-group-text {
    border-color: #cbd5e1;
    border-radius: 0.55rem;
    background-color: #f8fafc;
    color: #64748b;
}

/* ---------- Alerts ---------- */
.alert {
    border-radius: 0.7rem;
    border: 1px solid transparent;
    border-left-width: 4px;
    box-shadow: var(--sam-shadow-sm);
}

.alert-success {
    border-left-color: #16a34a;
}

.alert-danger {
    border-left-color: #dc2626;
}

.alert-warning {
    border-left-color: #f59e0b;
}

.alert-info {
    border-left-color: #2563eb;
}

/* ---------- Tables & Badges ---------- */
.table > thead > tr > th {
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #475569;
    background-color: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 0.8rem 0.9rem;
    white-space: nowrap;
}

.table > tbody > tr > td {
    vertical-align: middle;
    padding: 0.75rem 0.9rem;
    border-color: #f1f5f9;
}

.table-hover > tbody > tr:hover > * {
    --bs-table-bg-state: #f8fafc;
}

.badge {
    font-weight: 600;
    padding: 0.38em 0.68em;
    border-radius: 0.45rem;
    letter-spacing: 0.005em;
}

.asset-thumb {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 0.55rem;
    border: 1px solid var(--sam-border);
}

.health-badge {
    font-weight: 600;
    padding: 0.4em 0.7em;
}

/* ---------- Dropdowns & Notifications ---------- */
.dropdown-menu {
    border: 1px solid var(--sam-border);
    border-radius: 0.75rem;
    box-shadow: 0 14px 32px -6px rgba(15, 23, 42, 0.14);
    padding: 0.35rem;
}

.dropdown-item {
    border-radius: 0.5rem;
    font-size: 0.88rem;
}

.sam-notif-dropdown {
    width: 356px;
    max-width: 92vw;
}

.sam-notif-list {
    max-height: 360px;
    overflow-y: auto;
}

.sam-notif-item {
    border-bottom: 1px solid #f1f5f9;
    border-radius: 0;
    white-space: normal;
    padding: 0.7rem 0.95rem;
}

.sam-notif-item.unread {
    background-color: #eff6ff;
}

.sam-notif-item:last-child {
    border-bottom: none;
}

/* ---------- Modals & Global Confirmation Modal ---------- */
.modal-backdrop.show {
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    background-color: rgba(15, 23, 42, 0.55);
}

.modal-content {
    border: none;
    border-radius: 1rem;
    box-shadow: var(--sam-shadow-lg);
    overflow: hidden;
}

.modal-header {
    border-bottom: 1px solid #f1f5f9;
    padding: 1.1rem 1.35rem;
}

.modal-body {
    padding: 1.25rem 1.35rem;
}

.modal-footer {
    border-top: 1px solid #f1f5f9;
    background-color: #f8fafc;
    padding: 0.9rem 1.35rem;
}

.sam-confirm-icon {
    width: 60px;
    height: 60px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.65rem;
    margin: 0 auto 1rem;
}

.sam-confirm-icon.variant-danger {
    background: #fee2e2;
    color: #dc2626;
    box-shadow: 0 0 0 8px rgba(220, 38, 38, 0.08);
}

.sam-confirm-icon.variant-warning {
    background: #fef3c7;
    color: #d97706;
    box-shadow: 0 0 0 8px rgba(245, 158, 11, 0.1);
}

.sam-confirm-icon.variant-success {
    background: #dcfce7;
    color: #16a34a;
    box-shadow: 0 0 0 8px rgba(22, 163, 74, 0.08);
}

.sam-confirm-icon.variant-primary {
    background: #dbeafe;
    color: #2563eb;
    box-shadow: 0 0 0 8px rgba(37, 99, 235, 0.08);
}

/* ---------- Professional Split-Screen Login Page ---------- */
.sam-login-body {
    min-height: 100vh;
    background: #0b1220;
    margin: 0;
}

.sam-login-wrapper {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.15fr 1fr;
}

.sam-login-hero {
    position: relative;
    overflow: hidden;
    background: radial-gradient(circle at 18% 20%, rgba(59, 130, 246, 0.32), transparent 45%),
                radial-gradient(circle at 82% 80%, rgba(99, 102, 241, 0.28), transparent 45%),
                linear-gradient(155deg, #0b1220 0%, #132245 52%, #1d3a8a 100%);
    color: #f8fafc;
    padding: 3rem 3.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.sam-login-hero::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(255, 255, 255, 0.09) 1px, transparent 1px);
    background-size: 26px 26px;
    pointer-events: none;
}

.sam-login-hero-content {
    position: relative;
    z-index: 1;
    max-width: 520px;
}

.sam-login-feature {
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(8px);
    border-radius: 0.85rem;
    padding: 0.95rem 1.1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.9rem;
}

.sam-login-feature-icon {
    width: 40px;
    height: 40px;
    border-radius: 0.65rem;
    background: rgba(59, 130, 246, 0.22);
    color: #93c5fd;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    flex-shrink: 0;
}

.sam-login-panel {
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 2rem;
}

.sam-login-box {
    width: 100%;
    max-width: 410px;
}

.sam-login-input-group .form-control {
    padding-top: 0.68rem;
    padding-bottom: 0.68rem;
    font-size: 0.94rem;
}

.sam-login-input-group .input-group-text {
    background: #f8fafc;
    padding-left: 0.9rem;
    padding-right: 0.9rem;
}

.sam-demo-card {
    border: 1px solid #e2e8f0;
    border-radius: 0.65rem;
    padding: 0.55rem 0.8rem;
    background: #f8fafc;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: left;
    width: 100%;
}

.sam-demo-card:hover {
    border-color: #93c5fd;
    background: #eff6ff;
    transform: translateY(-1px);
}

@media (max-width: 991.98px) {
    .sam-login-wrapper {
        grid-template-columns: 1fr;
        background: linear-gradient(155deg, #0b1220 0%, #1d3a8a 100%);
        padding: 1.5rem 1rem;
        align-items: center;
    }
    .sam-login-hero {
        display: none;
    }
    .sam-login-panel {
        border-radius: 1.1rem;
        box-shadow: 0 24px 50px rgba(15, 23, 42, 0.4);
        max-width: 450px;
        width: 100%;
        margin: 0 auto;
        padding: 2rem 1.5rem;
    }
}

/* ---------- Mobile-first QR Scan Utilities ---------- */
.scan-action-btn {
    padding: 0.85rem 1.25rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 0.65rem;
}

.qr-scanner-stage {
    width: 100%;
    max-width: 360px;
    margin: 0 auto;
}

.qr-scanner-box {
    position: relative;
    width: 100%;
    max-width: 360px;
    margin: 0 auto;
    border-radius: 1rem;
    overflow: hidden;
    background: #0b1220;
    border: 2px solid #cbd5e1;
    box-shadow: 0 14px 32px -10px rgba(15, 23, 42, 0.28);
}

.qr-scanner-box.is-active {
    border-color: #2563eb;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14), 0 14px 32px -10px rgba(15, 23, 42, 0.3);
}

.qr-scanner-box > div {
    width: 100% !important;
}

.qr-scanner-box video {
    width: 100% !important;
    height: clamp(280px, 76vw, 356px) !important;
    object-fit: cover !important;
    display: block !important;
    transition: transform 0.2s ease;
}

.qr-scanner-box.is-zoomed video {
    transform: scale(1.75);
}

.qr-scanner-box canvas {
    max-width: 100% !important;
    height: auto !important;
    display: block;
    margin: 0 auto;
}

.qr-scanner-box img[alt="Info icon"] {
    display: none !important;
}

.qr-scanner-placeholder {
    width: 100%;
    max-width: 360px;
    min-height: 240px;
    margin: 0 auto;
    border-radius: 1rem;
    border: 2px dashed #cbd5e1;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.75rem 1.25rem;
    text-align: center;
    color: #64748b;
}

.qr-scanner-placeholder-icon {
    width: 64px;
    height: 64px;
    border-radius: 1rem;
    background: #eff6ff;
    color: #2563eb;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    margin-bottom: 0.85rem;
    box-shadow: 0 6px 16px -4px rgba(37, 99, 235, 0.2);
}

/* ---------- Print ---------- */
@media print {
    .sam-navbar,
    .sam-sidebar,
    .sam-footer,
    .no-print {
        display: none !important;
    }
    .sam-main {
        margin-left: 0 !important;
    }
    .sam-wrapper {
        padding-top: 0 !important;
    }
}
