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

:root {
    --bg-main: #0b0f19;
    --bg-card: rgba(20, 26, 46, 0.65);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(99, 102, 241, 0.4);
    
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-glow: rgba(99, 102, 241, 0.35);
    
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.2);
    
    --danger: #ef4444;
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --font-outfit: 'Outfit', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: radial-gradient(circle at 50% 0%, #1e1b4b 0%, var(--bg-main) 100%);
    color: var(--text-primary);
    font-family: var(--font-outfit);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 1rem 0.75rem;
    overflow-x: hidden;
}

.container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    animation: fadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

/* Header Section */
header {
    text-align: center;
    margin-bottom: 0.25rem;
    padding: 0.5rem 0;
}

.logo-container {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.logo-icon {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, #818cf8, var(--primary));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 15px var(--primary-glow);
    color: #fff;
    font-size: 1.35rem;
}

header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    background: linear-gradient(to right, #ffffff, #c7d2fe);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.4rem;
    line-height: 1.4;
    padding: 0 0.5rem;
}

/* Layout Grid */
.layout-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
}

@media (min-width: 768px) {
    .layout-grid {
        grid-template-columns: 1.1fr 1.9fr;
        gap: 1.5rem;
    }
}

/* Cards styling */
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 1.25rem;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (min-width: 768px) {
    .glass-card {
        padding: 2rem;
        border-radius: 24px;
    }
}

.glass-card:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

.card-title {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #fff;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.card-title svg {
    color: var(--primary);
}

/* Search Box Container */
.search-container {
    position: relative;
    width: 100%;
    margin-bottom: 1rem;
}

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

.search-input-wrapper svg {
    position: absolute;
    left: 1rem;
    color: var(--text-secondary);
    pointer-events: none;
    transition: color 0.3s;
}

.search-input {
    width: 100%;
    padding: 0.85rem 1rem 0.85rem 2.75rem;
    background: rgba(15, 23, 42, 0.8);
    border: 1.5px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-family: var(--font-outfit);
    font-size: 0.95rem;
    outline: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: rgba(15, 23, 42, 0.95);
}

.search-input:focus + svg {
    color: var(--primary);
}

/* Autocomplete Results */
.search-results {
    position: absolute;
    top: calc(100% + 0.35rem);
    left: 0;
    right: 0;
    background: #0f172a;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 10px 30px rgba(0,0,0,0.6);
    display: none;
    animation: slideDown 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.result-item {
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    transition: background 0.2s;
}

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

.result-item:hover {
    background: rgba(99, 102, 241, 0.12);
}

.result-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    max-width: 75%;
}

.result-name {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.badge {
    padding: 0.2rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-active {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-inactive {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Selected Employee Display */
.selected-employee-card {
    background: rgba(99, 102, 241, 0.06);
    border: 1px dashed rgba(99, 102, 241, 0.3);
    border-radius: 14px;
    padding: 1rem;
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    position: relative;
    overflow: hidden;
}

.selected-employee-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary);
}

.selected-employee-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    font-weight: 600;
}

.selected-employee-name {
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    line-height: 1.3;
}

.selected-employee-id {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Camera Viewer Viewport */
.camera-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #090d16;
    border-radius: 16px;
    overflow: hidden;
    border: 1.5px solid var(--border-color);
    box-shadow: inset 0 0 30px rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

#camera-video, #photo-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#photo-preview {
    display: none;
}

.mirrored {
    transform: scaleX(-1);
}

/* Floating Switch Camera button */
.btn-switch-cam-floating {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    display: none; /* Controlled by JS device detection */
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 15;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px rgba(0,0,0,0.4);
}

.btn-switch-cam-floating:hover {
    background: rgba(99, 102, 241, 0.85);
    border-color: var(--primary);
    transform: scale(1.05);
}

.btn-switch-cam-floating:active {
    transform: scale(0.95);
}

/* Scanning line overlay */
.scanning-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2.5px;
    background: linear-gradient(to right, transparent, var(--primary), transparent);
    animation: scan 3s linear infinite;
    pointer-events: none;
    z-index: 10;
    box-shadow: 0 0 6px var(--primary);
}

@keyframes scan {
    0% { top: 0%; }
    50% { top: 100%; }
    100% { top: 0%; }
}

.camera-placeholder {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
    padding: 1.5rem;
    z-index: 5;
}

.camera-placeholder svg {
    color: var(--text-muted);
    animation: pulseIcon 2.5s infinite;
}

/* Controls Panel */
.controls-panel {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

.btn-row {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

@media (min-width: 480px) {
    .btn-row {
        flex-direction: row;
        width: 100%;
    }
    .btn-row .btn {
        flex: 1;
    }
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem 1.25rem;
    border-radius: 12px;
    font-family: var(--font-outfit);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    border: 1px solid transparent;
    min-height: 48px; /* Safe touch target for mobile devices */
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-primary {
    background: linear-gradient(135deg, #818cf8, var(--primary));
    color: #fff;
    box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
}

.btn-secondary {
    background: rgba(30, 41, 59, 0.75);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(51, 65, 85, 0.85);
}

.btn-success {
    background: linear-gradient(135deg, #34d399, var(--success));
    color: #fff;
    box-shadow: 0 4px 12px var(--success-glow);
}

.btn-success:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--success), #059669);
}

/* Toast/Alert Messaging */
.alert {
    display: none;
    padding: 0.85rem 1rem;
    border-radius: 12px;
    margin-top: 1rem;
    align-items: flex-start;
    gap: 0.6rem;
    font-size: 0.85rem;
    line-height: 1.4;
    animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.alert-success {
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #a7f3d0;
}

.alert-success svg {
    color: var(--success);
    flex-shrink: 0;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.alert-danger svg {
    color: var(--danger);
    flex-shrink: 0;
}

/* Spinner */
.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Footer Section */
footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 2rem;
    padding-bottom: 1rem;
}
