/* ==========================================================================
   ViteVendu AI - Stylesheet (Sober, Light & Fast)
   Inspired by Le Bon Coin brand identity
   ========================================================================== */

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

:root {
    --primary-orange: #FF6E14;
    --primary-orange-hover: #E25B0E;
    --accent-blue: #002F6C; /* Le Bon Coin dark blue for main text/headers */
    --light-blue: #E8F0FE;
    --border-blue: #ADC9FA;
    --bg-main: #F4F6F7;
    --bg-card: #FFFFFF;
    --text-main: #1A1A1A;
    --text-muted: #666666;
    --text-light: #FFFFFF;
    --border-color: #E2E8F0;
    
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
    
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
}

/* Reset & Base Elements */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    font-size: 16px;
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

/* Mobile Container Layout */
.app-container {
    width: 100%;
    max-width: 480px;
    background-color: var(--bg-card);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.05);
}

/* Header */
header {
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-text {
    font-family: 'Outfit', sans-serif;
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--primary-orange);
    letter-spacing: -0.5px;
}

.logo-sub {
    color: var(--accent-blue);
    font-weight: 600;
}

.settings-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    transition: var(--transition-fast);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-btn:hover {
    background-color: var(--bg-main);
    color: var(--text-main);
}

/* Main Content Area */
main {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding-bottom: 80px; /* Space for navbar */
}

/* Typography Helpers */
h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent-blue);
    margin-bottom: 8px;
}

p.subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

/* Cards & Sections */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-normal);
}

.card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border-blue);
}

/* Camera & Upload Area */
.camera-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--border-color);
    border-radius: 16px;
    padding: 40px 20px;
    background-color: var(--bg-main);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    min-height: 240px;
    transition: var(--transition-normal);
}

.camera-area:hover, .camera-area.drag-over {
    border-color: var(--primary-orange);
    background-color: #FFF9F5;
}

.camera-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
}

.camera-icon-bg {
    width: 64px;
    height: 64px;
    background-color: var(--bg-card);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    color: var(--primary-orange);
    font-size: 24px;
}

.camera-text-primary {
    font-weight: 600;
    color: var(--accent-blue);
    font-size: 1rem;
}

.camera-text-secondary {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Live Viewfinder / Image Preview */
.image-preview-container {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    display: none;
}

.image-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Live Camera View */
.webcam-view {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    object-fit: cover;
    display: none;
}

/* Scanner Animation Overlay */
.scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.1);
    display: none;
    z-index: 5;
    pointer-events: none;
}

.scanner-line {
    position: absolute;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(180deg, rgba(173, 201, 250, 0) 0%, rgba(173, 201, 250, 1) 50%, rgba(173, 201, 250, 0) 100%);
    box-shadow: 0 0 10px rgba(173, 201, 250, 0.8), 0 0 20px var(--primary-orange);
    animation: scan 2s linear infinite;
}

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

/* Form Elements */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent-blue);
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition-fast);
    background-color: var(--bg-card);
}

.form-input:focus {
    border-color: var(--primary-orange);
    box-shadow: 0 0 0 3px rgba(255, 110, 20, 0.15);
}

select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px;
    padding-right: 40px;
}

/* Custom Image Capture Hidden Inputs */
#file-input {
    display: none;
}

/* Buttons */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    user-select: none;
}

.btn-primary {
    background-color: var(--primary-orange);
    color: var(--text-light);
}

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

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

.btn-secondary:hover {
    background-color: var(--border-color);
}

.btn-ghost {
    background: none;
    color: var(--primary-orange);
    border: 1px solid var(--primary-orange);
}

.btn-ghost:hover {
    background-color: rgba(255, 110, 20, 0.05);
}

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

/* Ad Preview Card Styles (Optimized for Le Bon Coin) */
.ad-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.ad-price {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--primary-orange);
}

.ad-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--accent-blue);
    line-height: 1.3;
}

.ad-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.ad-badge {
    background-color: var(--light-blue);
    color: var(--accent-blue);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid var(--border-blue);
}

.ad-description-container {
    background-color: var(--bg-main);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
}

.ad-description-text {
    font-size: 0.9rem;
    color: var(--text-main);
    white-space: pre-wrap; /* Preserves line breaks */
    font-family: inherit;
}

.action-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* History Items */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-item {
    display: flex;
    gap: 12px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.history-item:hover {
    border-color: var(--border-blue);
    background-color: var(--bg-main);
}

.history-img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    background-color: var(--border-color);
}

.history-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
}

.history-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--accent-blue);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.history-price {
    font-weight: 700;
    color: var(--primary-orange);
}

/* Settings Modal & Panel */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    display: none;
    align-items: flex-end;
    justify-content: center;
    z-index: 110;
}

.modal-content {
    background-color: var(--bg-card);
    width: 100%;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    padding: 24px 16px;
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.1);
    transform: translateY(100%);
    transition: transform var(--transition-normal) cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active {
    display: flex;
}

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

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

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 20px;
    color: var(--text-muted);
}

/* Bottom Navigation Bar */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: 64px;
    background-color: var(--bg-card);
    border-top: 1px solid var(--border-color);
    display: grid;
    grid-template-columns: 1fr 1fr;
    z-index: 90;
}

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

.nav-item.active {
    color: var(--primary-orange);
    font-weight: 600;
}

.nav-icon {
    font-size: 20px;
}

/* App Views Switcher */
.app-view {
    display: none;
    flex-direction: column;
    gap: 16px;
    animation: fadeIn 0.2s ease-out;
}

.app-view.active {
    display: flex;
}

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

/* Loading Ring for Actions */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s ease-in-out infinite;
}

.btn-secondary .spinner {
    border-color: rgba(0, 0, 0, 0.1);
    border-top-color: var(--primary-orange);
}

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

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background-color: rgba(26, 26, 26, 0.9);
    color: var(--text-light);
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s, transform 0.25s;
    z-index: 200;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
