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

:root {
    --bg-main: #0f172a;
    --bg-surface: #1e293b;
    --bg-surface-hover: #334155;
    --border-color: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --primary: #3b82f6;
    --primary-glow: rgba(59, 130, 246, 0.35);
    
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.35);
    
    --warning: #f59e0b;
    --warning-glow: rgba(245, 158, 11, 0.3);
    
    --error: #ef4444;
    --error-glow: rgba(239, 68, 68, 0.35);
    
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    --border-radius-lg: 16px;
    --border-radius-md: 10px;
    --border-radius-sm: 6px;
    
    --transition-smooth: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    line-height: 1.5;
}

/* Glassmorphism Header */
header {
    background: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-section img {
    height: 40px;
    width: 40px;
    border-radius: var(--border-radius-sm);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.2);
}

.logo-title h1 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    background: linear-gradient(135deg, #60a5fa, #3b82f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-title p {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.status-bar {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    padding: 0.4rem 0.8rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: var(--transition-smooth);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-badge.online .status-indicator {
    background-color: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.status-badge.offline .status-indicator {
    background-color: var(--warning);
    box-shadow: 0 0 8px var(--warning);
}

.operator-badge {
    cursor: pointer;
    transition: var(--transition-smooth);
}

.operator-badge:hover {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
    color: var(--text-primary);
}

/* Container */
main {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 2rem auto;
    padding: 0 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Glassmorphic Grid and Cards */
.form-card {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 2rem;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    position: relative;
    overflow: hidden;
}

.form-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--success));
}

.form-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.form-title-row h2 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Barcode inputs styling */
.inputs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    position: relative;
}

.input-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.input-container {
    position: relative;
    display: flex;
    align-items: center;
}

.input-container input {
    width: 100%;
    background-color: rgba(15, 23, 42, 0.8);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 0.75rem 2.5rem 0.75rem 2.5rem;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 500;
    outline: none;
    transition: var(--transition-smooth);
}

.input-container i.input-icon {
    position: absolute;
    left: 1rem;
    color: var(--text-muted);
    font-size: 1rem;
    pointer-events: none;
    transition: var(--transition-smooth);
}

/* Scan Glow Effects */
.input-container input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 15px var(--primary-glow);
}

.input-container input:focus + i.input-icon {
    color: var(--primary);
}

/* Scanning Feedback Border Animation */
.scan-success input {
    border-color: var(--success) !important;
    box-shadow: 0 0 15px var(--success-glow) !important;
}
.scan-success i.input-icon {
    color: var(--success) !important;
}

.scan-error input {
    border-color: var(--error) !important;
    box-shadow: 0 0 15px var(--error-glow) !important;
}
.scan-error i.input-icon {
    color: var(--error) !important;
}

/* Loader in Input */
.scan-loading input {
    background-image: linear-gradient(90deg, rgba(15, 23, 42, 0.8) 0px, rgba(30, 41, 59, 0.5) 40px, rgba(15, 23, 42, 0.8) 80px);
    background-size: 600px 100%;
    animation: placeholderShimmer 1.6s infinite linear;
}

@keyframes placeholderShimmer {
    0% { background-position: -300px 0; }
    100% { background-position: 300px 0; }
}

/* Metadata Grid (Read-Only Fields) */
.metadata-card {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 1.25rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.25rem;
    transition: var(--transition-smooth);
}

.metadata-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.metadata-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.metadata-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    word-break: break-word;
}

.metadata-value.empty {
    color: var(--text-muted);
    font-style: italic;
    font-weight: 400;
}

/* Action Rows */
.actions-row {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
    margin-top: 0.5rem;
}

button {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius-md);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition-smooth);
}

.btn-primary {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.45);
}

.btn-primary:disabled {
    background: var(--bg-surface-hover);
    color: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

/* Warning alert box */
.alert-box {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid var(--warning);
    padding: 1rem;
    border-radius: var(--border-radius-md);
    color: var(--warning);
    font-size: 0.85rem;
    animation: slideIn 0.3s ease-out;
}

.alert-box.error {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--error);
    color: var(--error);
}

/* Table Card */
.table-card {
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.table-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.table-header-row h3 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 600;
}

.table-wrapper {
    overflow-x: auto;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-color);
}

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

th {
    background-color: rgba(15, 23, 42, 0.8);
    color: var(--text-secondary);
    font-weight: 600;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

tr {
    background-color: rgba(30, 41, 59, 0.2);
    transition: var(--transition-smooth);
}

tr:hover {
    background-color: rgba(30, 41, 59, 0.5);
}

/* Badges */
.badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-edited {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.4);
}

.badge-offline {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.4);
}

.badge-location {
    font-family: monospace;
    font-size: 0.8rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
}

.badge-location.new {
    border-color: var(--success);
    color: var(--success);
    background: rgba(16, 185, 129, 0.1);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition-smooth);
}

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

.modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    width: 90%;
    max-width: 500px;
    padding: 2rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-header h3 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Keyframes */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive tweaks */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    .status-bar {
        justify-content: space-between;
    }
    .inputs-grid {
        grid-template-columns: 1fr;
    }
}

/* Camera Scan Button inside Input */
.btn-camera-scan {
    position: absolute;
    right: 0.5rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem;
    font-size: 1.1rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}
.btn-camera-scan:hover {
    color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
}

/* Scanner Modal Specifics */
.scanner-modal-content {
    max-width: 500px;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.scanner-modal-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    position: relative;
    padding-top: 0.5rem;
}

#cameraScanner {
    width: 100%;
    max-width: 400px;
    aspect-ratio: 1;
    border-radius: var(--border-radius-md);
    overflow: hidden;
    border: 2px dashed var(--primary);
    background: #000000;
    position: relative;
}

/* Style the internal video inside cameraScanner */
#cameraScanner video {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
}

.scanner-tip {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-align: center;
}

.btn-close-scanner {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.75rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: var(--border-radius-sm);
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.btn-close-scanner:hover {
    color: var(--error);
    background: rgba(239, 68, 68, 0.1);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 9999;
    pointer-events: none;
}

.toast {
    background: rgba(30, 41, 59, 0.95);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: var(--border-radius-md);
    padding: 1rem 1.5rem;
    color: var(--text-primary);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    font-weight: 500;
    pointer-events: auto;
    animation: toastSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1), toastFadeOut 0.3s ease-in forwards 3.5s;
    max-width: 350px;
    position: relative;
    overflow: hidden;
}

.toast.success {
    border-left: 4px solid var(--success);
}
.toast.success i {
    color: var(--success);
    font-size: 1.1rem;
}

.toast.error {
    border-left: 4px solid var(--error);
}
.toast.error i {
    color: var(--error);
    font-size: 1.1rem;
}

@keyframes toastSlideIn {
    from {
        transform: translateY(-20px) scale(0.9);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

@keyframes toastFadeOut {
    to {
        transform: translateY(-10px) scale(0.9);
        opacity: 0;
    }
}
