/* BioScan - Main Design System (Vanilla CSS) */

:root {
    --bg-dark: #0a0d10;
    --bg-card: rgba(20, 26, 33, 0.75);
    --bg-card-solid: #141a21;
    --border-color: rgba(43, 58, 74, 0.6);
    --border-color-glow: rgba(0, 230, 118, 0.3);
    
    /* Elegant vibrant colors */
    --primary: #10b981; /* Emerald green */
    --primary-glow: rgba(16, 185, 129, 0.2);
    --primary-dark: #059669;
    --accent: #06b6d4; /* Cyan */
    --accent-glow: rgba(6, 182, 212, 0.2);
    --warning: #f59e0b; /* Amber */
    --danger: #ef4444; /* Tomato Red */
    --danger-glow: rgba(239, 68, 68, 0.2);
    --success: #10b981;
    
    /* Neutral colors */
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-dark: #4b5563;
    
    /* Design tokens */
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --shadow-main: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset and Global Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: 'Outfit', sans-serif;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    overflow-x: hidden;
}

/* Container limits app to mobile width but centers it on desktop */
.app-container {
    width: 100%;
    max-width: 480px;
    background-color: var(--bg-dark);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative;
    box-shadow: 0 0 40px rgba(0,0,0,0.5);
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
}

/* Header Component */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 20px;
    background-color: rgba(10, 13, 16, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 15px var(--primary-glow);
}

.brand h1 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(120deg, #ffffff, #a7f3d0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Cloud Connection Pill */
.sync-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 100px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.sync-status:hover {
    background: rgba(255, 255, 255, 0.1);
}

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

.status-dot.offline { background-color: var(--danger); box-shadow: 0 0 8px var(--danger); }
.status-dot.syncing { background-color: var(--warning); box-shadow: 0 0 8px var(--warning); animation: pulse 1s infinite alternate; }
.status-dot.online { background-color: var(--primary); box-shadow: 0 0 8px var(--primary); }

@keyframes pulse {
    0% { opacity: 0.4; }
    100% { opacity: 1; }
}

/* Main Content Area */
.app-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    padding-bottom: 90px; /* Space for bottom nav */
}

/* Screen Transitions */
.app-screen {
    display: none;
    animation: fadeIn 0.4s ease-out;
}

.app-screen.active {
    display: block;
}

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

/* Cards & Styling */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 20px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: var(--shadow-main);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.card-header h2, .card-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: white;
}

.badge {
    font-size: 11px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    padding: 2px 8px;
    border-radius: 5px;
    color: var(--text-muted);
}

/* Scanner Layout & Viewfinder Styling */
.scanner-card {
    background: var(--bg-card-solid);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-main);
}

.scanner-header {
    text-align: center;
    margin-bottom: 16px;
}

.scanner-header h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 4px;
}

.scanner-header p {
    font-size: 13px;
    color: var(--text-muted);
}

/* Viewfinder Overlay animations */
.viewfinder-container {
    position: relative;
    aspect-ratio: 4/3;
    border-radius: var(--radius-md);
    overflow: hidden;
    background-color: #000;
    margin-bottom: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

#reader {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Hide standard HTML5 Qrcode UI details we override */
#reader video {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
}

#reader__dashboard, #reader__header_message {
    display: none !important;
}

.viewfinder-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
    display: none; /* Shown dynamically when active */
}

/* Viewfinder Corner Brackets */
.corner {
    position: absolute;
    width: 24px;
    height: 24px;
    border: 3px solid var(--primary);
}

.top-left { top: 30px; left: 40px; border-right: none; border-bottom: none; border-top-left-radius: 8px;}
.top-right { top: 30px; right: 40px; border-left: none; border-bottom: none; border-top-right-radius: 8px;}
.bottom-left { bottom: 30px; left: 40px; border-right: none; border-top: none; border-bottom-left-radius: 8px;}
.bottom-right { bottom: 30px; right: 40px; border-left: none; border-top: none; border-bottom-right-radius: 8px;}

/* Laser Line Scanning Effect */
.laser-line {
    position: absolute;
    top: 30px;
    left: 40px;
    right: 40px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
    box-shadow: 0 0 8px var(--primary);
    animation: scan 2.5s infinite ease-in-out;
}

@keyframes scan {
    0% { top: 30px; opacity: 0.3; }
    50% { top: calc(100% - 30px); opacity: 1; }
    100% { top: 30px; opacity: 0.3; }
}

.scanner-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: var(--text-muted);
    z-index: 3;
    background-color: #0c0f12;
}

.scanner-placeholder svg {
    opacity: 0.3;
}

.scanner-controls {
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
}

.control-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--text-muted);
}

.control-actions {
    display: flex;
    gap: 10px;
}

.control-actions button {
    flex: 1;
}

/* Simulation Input Panel */
.sim-card {
    background: linear-gradient(135deg, rgba(23, 29, 36, 0.4), rgba(6, 182, 212, 0.05));
}

.input-group {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

/* Form Styles */
.form-group {
    margin-bottom: 16px;
    width: 100%;
}

.form-group-row {
    display: flex;
    gap: 12px;
}

.form-group-row .form-group {
    flex: 1;
}

label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-muted);
}

.form-control, .form-select {
    width: 100%;
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: white;
    padding: 12px 14px;
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: var(--transition);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    background-color: rgba(255, 255, 255, 0.06);
    box-shadow: 0 0 10px var(--primary-glow);
}

.form-select option {
    background-color: var(--bg-card-solid);
    color: white;
}

.form-help {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    display: block;
}

/* Buttons */
.btn {
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
    border-radius: var(--radius-md);
}

.btn-primary {
    background-color: var(--primary);
    color: #061c0a;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    box-shadow: 0 0 15px var(--primary-glow);
}

.btn-secondary {
    background-color: rgba(255, 255, 255, 0.08);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

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

.btn-danger:hover {
    background-color: #dc2626;
    box-shadow: 0 0 12px var(--danger-glow);
}

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

.btn-accent:hover {
    background-color: #0891b2;
    box-shadow: 0 0 12px var(--accent-glow);
}

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

.btn-outline:hover {
    background-color: rgba(255, 255, 255, 0.04);
    border-color: var(--text-muted);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Bottom Nav Component */
.app-nav {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70px;
    display: flex;
    background-color: rgba(10, 13, 16, 0.9);
    border-top: 1px solid var(--border-color);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: 10;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.nav-item svg {
    transition: var(--transition);
}

.nav-item:hover, .nav-item.active {
    color: var(--primary);
}

.nav-item.active svg {
    color: var(--primary);
    transform: translateY(-2px);
    filter: drop-shadow(0 0 6px var(--primary-glow));
}

/* Modals */
.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(5, 7, 9, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 20;
    display: none;
    align-items: flex-end; /* Slides from bottom for mobile-native feel */
    animation: fadeInModal 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeInModal {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    width: 100%;
    background: var(--bg-card-solid);
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
    border-top: 1px solid var(--border-color);
    padding: 24px;
    position: relative;
    max-height: 90%;
    display: flex;
    flex-direction: column;
    animation: slideUpModal 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 -10px 40px rgba(0,0,0,0.6);
}

@keyframes slideUpModal {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 28px;
    color: var(--text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}

.modal-close:hover {
    color: white;
    background-color: rgba(255,255,255,0.05);
}

.modal-header-section {
    margin-bottom: 20px;
}

.modal-header-section h2 {
    font-size: 20px;
    font-weight: 700;
}

.modal-header-section .subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

.modal-header-section.text-center {
    text-align: center;
}

.modal-body-section {
    flex: 1;
}

.modal-body-section.scrollable {
    overflow-y: auto;
    padding-right: 4px;
    margin-bottom: 16px;
}

.modal-footer-section {
    display: flex;
    gap: 12px;
    margin-top: 10px;
    border-top: 1px solid var(--border-color);
    padding-top: 18px;
}

.modal-footer-section button {
    flex: 1;
}

/* Crop Icon circular badge */
.crop-icon-banner {
    font-size: 40px;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.15) 0%, transparent 70%);
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    border: 1px solid rgba(16, 185, 129, 0.1);
}

.barcode-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background-color: rgba(6, 182, 212, 0.1);
    color: var(--accent);
    border: 1px solid rgba(6, 182, 212, 0.2);
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 600;
    margin-top: 8px;
    letter-spacing: 0.5px;
}

/* Progress Circular Meter */
.progress-showcase {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}

.progress-ring-container {
    position: relative;
    width: 160px;
    height: 160px;
}

.progress-ring {
    transform: rotate(-90deg);
}

.progress-text-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.days-number {
    font-size: 38px;
    font-weight: 800;
    line-height: 1;
    color: white;
    text-shadow: 0 0 15px rgba(255,255,255,0.2);
}

.days-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    margin-top: 2px;
}

/* Growth Stats Grid */
.growth-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

.stat-box {
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.04);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
}

.stat-box .label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 4px;
}

.stat-box .val {
    font-size: 15px;
    font-weight: 600;
    color: white;
}

/* Inventory Screen Styles */
.screen-header {
    margin-bottom: 20px;
}

.screen-header h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 12px;
}

.search-box {
    display: flex;
    align-items: center;
    background-color: rgba(255,255,255,0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    gap: 10px;
    color: var(--text-muted);
}

.search-box input {
    background: transparent;
    border: none;
    outline: none;
    color: white;
    font-family: inherit;
    font-size: 14px;
    flex: 1;
}

.crops-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Crop list item card */
.crop-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
    cursor: pointer;
}

.crop-card:hover {
    border-color: rgba(255,255,255,0.15);
    background-color: rgba(255,255,255,0.02);
}

.crop-card-icon {
    font-size: 24px;
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background-color: rgba(255,255,255,0.03);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255,255,255,0.06);
}

.crop-card-details {
    flex: 1;
}

.crop-card-details h4 {
    font-size: 16px;
    font-weight: 600;
    color: white;
    margin-bottom: 2px;
}

.crop-card-details p {
    font-size: 12px;
    color: var(--text-muted);
}

.crop-card-progress {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.crop-card-progress .days-left {
    font-size: 14px;
    font-weight: 700;
}

/* Dynamic State colors on cards */
.crop-card.state-growing { border-left: 3px solid var(--primary); }
.crop-card.state-ready { border-left: 3px solid var(--warning); }
.crop-card.state-ready .days-left { color: var(--warning); }
.crop-card.state-overdue { border-left: 3px solid var(--danger); }
.crop-card.state-overdue .days-left { color: var(--danger); }

/* Progress bar inside card */
.mini-progress-bar {
    width: 60px;
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    overflow: hidden;
}

.mini-progress-fill {
    height: 100%;
    background-color: var(--primary);
    border-radius: 10px;
}

.crop-card.state-ready .mini-progress-fill { background-color: var(--warning); }
.crop-card.state-overdue .mini-progress-fill { background-color: var(--danger); }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.6;
}

.empty-state h3 {
    color: white;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
}

.empty-state p {
    font-size: 13px;
    line-height: 1.5;
}

/* Settings UI Specifics */
.settings-desc {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 20px;
}

.settings-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.settings-actions button {
    flex: 1;
}

.connection-result {
    margin-top: 15px;
    font-size: 13px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    display: none;
}

.connection-result.success {
    display: block;
    background-color: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: #34d399;
}

.connection-result.error {
    display: block;
    background-color: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #f87171;
}

.guide-card {
    background: linear-gradient(135deg, rgba(23, 29, 36, 0.6), rgba(16, 185, 129, 0.02));
}

.setup-steps {
    padding-left: 18px;
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.7;
}

.setup-steps strong {
    color: white;
}

.filepath {
    font-family: monospace;
    background: rgba(0,0,0,0.3);
    padding: 2px 4px;
    border-radius: 4px;
    color: #38bdf8;
}

.backup-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 14px;
}

/* Toast Notification Styles */
.toast-container {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 99;
    pointer-events: none;
}

.toast {
    background-color: #1e293b;
    border: 1px solid rgba(255,255,255,0.08);
    color: white;
    padding: 12px 18px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: space-between;
    pointer-events: auto;
    animation: slideDownToast 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.toast.success { border-left: 4px solid var(--primary); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--accent); }

.toast-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    padding-left: 10px;
}

/* Color helpers */
.text-accent { color: var(--accent) !important; }
.text-center { text-align: center; }

/* Custom Scrollbar for list */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.2);
}
