@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary: #165b40;
    --primary-light: #eef7f3;
    --primary-dark: #0c3d2a;
    --accent: #ca8a04;
    --accent-light: #fef9c3;
    --bg-main: #f8faf9;
    --bg-card: #ffffff;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --text-white: #ffffff;
    --border: #e5e7eb;
    
    --success: #10b981;
    --success-bg: #d1fae5;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;
    --danger: #ef4444;
    --danger-bg: #fee2e2;
    --info: #3b82f6;
    --info-bg: #dbeafe;

    --sidebar-width: 260px;
    --header-height: 70px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 20px 25px -5px rgba(22, 91, 64, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.03);
}

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

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* App Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(185deg, var(--primary-dark) 0%, #08281b 100%);
    color: var(--text-white);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 3rem;
}

.sidebar-brand-logo {
    width: 38px;
    height: 38px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.25rem;
    color: #e6f4ea;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.sidebar-brand-name {
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, #ffffff, #a7f3d0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-grow: 1;
}

.sidebar-menu-item a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    color: #94a3b8;
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: all 0.3s ease;
}

.sidebar-menu-item.active a,
.sidebar-menu-item a:hover {
    color: var(--text-white);
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-menu-item.active a {
    background: linear-gradient(135deg, var(--primary) 0%, rgba(22, 91, 64, 0.7) 100%);
    box-shadow: 0 4px 12px rgba(22, 91, 64, 0.25);
    font-weight: 600;
}

.sidebar-footer {
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.sidebar-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--primary);
    color: var(--text-white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.sidebar-user-info {
    font-size: 0.85rem;
}

.sidebar-user-name {
    font-weight: 600;
    display: block;
}

.sidebar-user-role {
    color: #64748b;
    font-size: 0.75rem;
}

.btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 0.6rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

.btn-logout:hover {
    background: #ef4444;
    color: white;
}

/* Main Content Area */
.main-content {
    margin-left: var(--sidebar-width);
    flex-grow: 1;
    padding: 2rem 2.5rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Top Header */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.top-header-title h1 {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--primary-dark);
    letter-spacing: -0.5px;
}

.top-header-title p {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: white;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.05);
    border-left: 4px solid var(--primary);
    min-width: 300px;
    animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast-success {
    border-left-color: var(--success);
}

.toast-error {
    border-left-color: var(--danger);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* KPI Widgets Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.kpi-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1.25rem;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: rgba(22, 91, 64, 0.2);
}

.kpi-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background-color: var(--primary-light);
    color: var(--primary);
}

.kpi-card-info {
    display: flex;
    flex-direction: column;
}

.kpi-card-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.2;
}

.kpi-card-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Secondary Panels */
.dashboard-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.dashboard-row-full {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

/* Glassmorphic Panel/Card */
.panel {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.panel-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Quick Search Scan Panel */
.scan-panel {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    position: relative;
    z-index: 1;
}

.scan-panel::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 150px;
    height: 100%;
    background-image: radial-gradient(circle, rgba(255,255,255,0.05) 10%, transparent 10.1%);
    background-size: 15px 15px;
    z-index: -1;
    opacity: 0.6;
}

.scan-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: white;
}

.scan-desc {
    font-size: 0.875rem;
    color: #a7f3d0;
    margin-bottom: 1.5rem;
}

.scan-input-group {
    position: relative;
    display: flex;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: var(--radius-md);
    padding: 0.25rem;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.scan-input-group:focus-within {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.15);
}

.scan-input-icon {
    display: flex;
    align-items: center;
    padding: 0 1rem;
    color: #a7f3d0;
    font-size: 1.25rem;
}

.scan-input {
    background: transparent;
    border: none;
    outline: none;
    color: white;
    font-size: 1rem;
    font-family: inherit;
    flex-grow: 1;
    padding: 0.75rem 0.25rem;
}

.scan-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.btn-scan {
    background: var(--accent);
    color: var(--text-white);
    border: none;
    padding: 0 1.5rem;
    font-weight: 700;
    font-size: 0.875rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-scan:hover {
    background: #b45309;
}

/* Interactive tables */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.table-custom {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.9rem;
}

.table-custom th {
    background-color: var(--primary-light);
    color: var(--primary-dark);
    padding: 1rem;
    font-weight: 700;
    border-bottom: 2px solid var(--border);
}

.table-custom td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
}

.table-custom tr:last-child td {
    border-bottom: none;
}

.table-custom tr {
    transition: background-color 0.2s ease;
}

.table-custom tbody tr:hover {
    background-color: #f3fdf9;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 50px;
    text-transform: uppercase;
}

.badge-success {
    background-color: var(--success-bg);
    color: #065f46;
}

.badge-warning {
    background-color: var(--warning-bg);
    color: #92400e;
}

.badge-danger {
    background-color: var(--danger-bg);
    color: #991b1b;
}

.badge-info {
    background-color: var(--info-bg);
    color: #1e40af;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: #f3f4f6;
    color: #4b5563;
    border-color: #d1d5db;
}

.btn-secondary:hover {
    background-color: #e5e7eb;
}

.btn-danger {
    background-color: #fee2e2;
    color: #b91c1c;
    border-color: #fca5a5;
}

.btn-danger:hover {
    background-color: #f87171;
    color: white;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
    border-radius: 6px;
}

/* Pagination container */
.pagination-wrapper {
    margin-top: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

/* Bootstrap 5 Pagination Custom Styles */
.pagination-wrapper ul.pagination {
    display: flex;
    list-style: none;
    gap: 0.35rem;
    padding: 0;
    margin: 0;
}

.pagination-wrapper .page-item .page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: all 0.2s ease;
}

.pagination-wrapper .page-item .page-link:hover {
    background-color: var(--primary-light);
    color: var(--primary-dark);
    border-color: var(--primary);
}

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

.pagination-wrapper .page-item.disabled .page-link {
    color: var(--text-muted);
    background-color: #f3f4f6;
    border-color: var(--border);
    cursor: not-allowed;
    opacity: 0.6;
}

/* Constrain any SVG icons inside Laravel's Bootstrap paginator */
.pagination-wrapper .page-link svg {
    width: 16px !important;
    height: 16px !important;
    display: inline-block;
    vertical-align: middle;
}

/* Modal Popup Dialog */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 61, 46, 0.4);
    backdrop-filter: blur(4px);
}

.modal-content {
    background: white;
    width: 90%;
    max-width: 580px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 10;
    overflow: hidden;
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    padding: 1.25rem 1.5rem;
    background: var(--primary-light);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--primary-dark);
}

.modal-header h3 {
    font-weight: 700;
    font-size: 1.15rem;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--primary-dark);
    cursor: pointer;
    line-height: 1;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Distribution Details Widgets inside Modal */
.allocation-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
    background: var(--bg-main);
    padding: 1rem;
    border-radius: var(--radius-sm);
    border: 1px dashed var(--primary);
}

.allocation-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    border-bottom: 1px solid rgba(22,91,64,0.08);
    padding-bottom: 0.35rem;
}

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

.allocation-item-label {
    color: var(--text-muted);
}

.allocation-item-value {
    font-weight: 700;
    color: var(--primary-dark);
}

/* Filter controls bar */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    background: var(--bg-card);
    padding: 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.form-control {
    font-family: inherit;
    font-size: 0.85rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid #d1d5db;
    outline: none;
    background-color: white;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.filter-bar input[type="text"] {
    flex-grow: 1;
    min-width: 200px;
}

/* Login Form Styles */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-dark) 0%, #0c1815 100%);
    padding: 1.5rem;
}

.login-card {
    background: white;
    width: 100%;
    max-width: 420px;
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    padding: 2.5rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: 16px;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 1.75rem;
    font-weight: 800;
    margin-bottom: 1rem;
    border: 1px solid rgba(22, 91, 64, 0.15);
}

.login-header h2 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary-dark);
}

.login-header p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.login-form-group {
    margin-bottom: 1.25rem;
}

.login-form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.login-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid #d1d5db;
    outline: none;
    font-family: inherit;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.login-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.btn-login {
    width: 100%;
    padding: 0.85rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 1rem;
}

.btn-login:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(22, 91, 64, 0.2);
}

.login-remember {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* QR Scanner Webcam Panel */
.scanner-webcam-container {
    background: #000;
    border-radius: var(--radius-md);
    overflow: hidden;
    aspect-ratio: 4/3;
    width: 100%;
    max-width: 320px;
    margin: 1rem auto;
    position: relative;
    border: 2px solid var(--primary);
}

#reader {
    width: 100%;
}
