/* CSS Variables & Theme */
:root {
    --bg-color: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #a1a1a6;
    --accent-color: #007aff;
    /* Apple Blue-ish */
    --accent-hover: #0056b3;
    --success-color: #34c759;
    --error-color: #ff3b30;
    --warning-color: #ffcc00;

    --glass-bg: rgba(30, 30, 30, 0.6);
    --glass-border: rgba(255, 255, 255, 0.1);
    --blur-amount: 20px;

    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 8px;

    --transition-speed: 0.3s;
}

/* Reset & Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
    /* Prevent body scroll, manage in containers */
}

input,
button {
    font-family: inherit;
    border: none;
    outline: none;
}

button {
    cursor: pointer;
    user-select: none;
}

/* App Container */
#app {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    max-width: 600px;
    /* Tablet/Desktop constraint for mobile feel */
    margin: 0 auto;
    background: radial-gradient(circle at top right, #1a1a1a 0%, #0d0d0d 60%);
}

/* Glassmorphism Utility */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--blur-amount));
    -webkit-backdrop-filter: blur(var(--blur-amount));
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}

/* Header */
header {
    padding: 20px;
    z-index: 100;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    border-bottom: 1px solid var(--glass-border);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h1 {
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.icon-logo {
    color: var(--accent-color);
    font-size: 1.5rem;
}

/* Main Content */
main {
    flex: 1;
    position: relative;
    overflow-y: auto;
    padding-top: 80px;
    /* Space for header */
}

.view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 20px;
    display: flex;
    flex-direction: column;
    transition: opacity var(--transition-speed) ease, transform var(--transition-speed) ease;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.98);
}

.view.active {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
    z-index: 10;
}

.view.hidden {
    display: none;
    /* Helpful for screen readers / interactions */
}

/* Landing View */
#view-landing {
    justify-content: center;
    align-items: center;
    text-align: center;
    padding-bottom: 100px;
}

.hero h2 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #fff 0%, #a1a1a6 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 40px;
}

.search-bar {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.08);
    /* Slightly lighter */
    margin-bottom: 24px;
    width: 100%;
    transition: border-color 0.2s;
}

.search-bar:focus-within {
    border-color: var(--accent-color);
}

.search-bar input {
    background: transparent;
    color: #fff;
    flex: 1;
    margin: 0 10px;
    font-size: 1rem;
}

.search-bar .search-icon {
    color: var(--text-secondary);
}

.action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    width: 100%;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 20px;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: transform 0.1s, background 0.2s;
}

.action-btn:active {
    transform: scale(0.96);
    background: rgba(40, 40, 40, 0.8);
}

.action-btn span:first-child {
    font-size: 2rem;
    margin-bottom: 8px;
    color: var(--accent-color);
}

/* Camera View */
#view-camera {
    padding: 0;
    background: #000;
}

.camera-container {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

#video-feed {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-overlay {
    position: absolute;
    bottom: 40px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

#btn-close-camera {
    position: absolute;
    top: 40px;
    /* Adjust for safe area if needed */
    right: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
}

.capture-btn {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: transparent;
    border: 4px solid #fff;
    position: relative;
    transition: transform 0.1s, opacity 0.2s;
    cursor: pointer;
}

.capture-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background: #fff;
    border-radius: 50%;
    border: 2px solid #000;
    /* Contrast ring */
    transition: transform 0.2s;
}

.capture-btn:active::after {
    transform: translate(-50%, -50%) scale(0.9);
}

/* Preview View */
#view-preview {
    padding: 0;
    background: #000;
}

.preview-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

#img-preview {
    flex: 1;
    object-fit: contain;
    background: #000;
}

.preview-actions {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
}

.primary-btn {
    background: var(--accent-color);
    color: #fff;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 1rem;
    transition: background 0.2s;
}

.primary-btn:active {
    background: var(--accent-hover);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-weight: 500;
    transition: background 0.2s;
}

.secondary-btn:active {
    background: rgba(255, 255, 255, 0.2);
}

.text-btn {
    background: transparent;
    color: var(--text-primary);
    padding: 12px;
    font-weight: 500;
}

/* Results View */
#view-results {
    justify-content: flex-end;
    /* Bottom sheet style */
    padding-bottom: 0;
}

.results-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.result-card {
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
    border-top: 1px solid var(--glass-border);
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.result-header {
    display: flex;
    align-items: center;
    margin-bottom: 16px;
}

.status-icon {
    font-size: 2rem;
    margin-right: 12px;
}

.result-body {
    margin-bottom: 24px;
}

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 12px;
    text-transform: uppercase;
}

.status-allowed {
    background: rgba(52, 199, 89, 0.2);
    color: var(--success-color);
}

.status-prohibited {
    background: rgba(255, 59, 48, 0.2);
    color: var(--error-color);
}

.status-warning {
    background: rgba(255, 204, 0, 0.2);
    color: var(--warning-color);
}

#result-description {
    color: var(--text-secondary);
    line-height: 1.6;
}

.result-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.result-actions button {
    width: 100%;
}

.text-link {
    color: var(--text-secondary);
    text-decoration: underline;
    font-size: 0.9rem;
}

/* Loading */
.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: var(--accent-color);
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    width: 90%;
    max-width: 400px;
    border-radius: var(--radius-lg);
    padding: 24px;
    transform: scale(0.95);
    transition: transform 0.3s;
}

.modal.active .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-body input {
    width: 100%;
    padding: 12px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    margin-top: 8px;
    border: 1px solid transparent;
}

.modal-body input:focus {
    border-color: var(--accent-color);
}

.helper-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 8px;
}

.modal-footer {
    margin-top: 24px;
    display: flex;
    justify-content: flex-end;
}

.icon-btn {
    background: transparent;
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.hidden {
    display: none !important;
}

/* Footer */
footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    margin: 0 20px 20px 20px;
    border-radius: var(--radius-md);
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

footer a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
}

footer .disclaimer {
    font-size: 0.75rem;
    opacity: 0.8;
}