/* ─── Tube Sales Platform - Mobile-first CSS ─── */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
}

/* ─── Nav ─── */
.nav {
    background: var(--gray-900);
    color: white;
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    max-width: 1200px;
    margin: 0 auto;
}

.nav-brand {
    font-size: 18px;
    font-weight: 700;
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-toggle {
    display: block;
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    min-width: 44px;
    min-height: 44px;
}

.nav-links {
    display: none;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    background: var(--gray-900);
    padding: 8px 16px 16px;
    border-top: 1px solid var(--gray-700);
}

.nav-links.open { display: block; }

.nav-links a {
    display: block;
    color: var(--gray-300);
    text-decoration: none;
    padding: 12px 8px;
    font-size: 16px;
    min-height: 44px;
    display: flex;
    align-items: center;
}

.nav-links a:hover, .nav-links a.active { color: white; }

/* ─── Main ─── */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 16px;
}

/* ─── Flash messages ─── */
.flash {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
}

.flash-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.flash-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.flash-warning { background: #fefce8; color: #854d0e; border: 1px solid #fef08a; }

/* ─── Cards ─── */
.card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 16px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--gray-700);
}

/* ─── Stats grid ─── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    text-align: center;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 12px;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    min-height: 44px;
    min-width: 44px;
    transition: background 0.2s;
    gap: 6px;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-outline {
    background: white;
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}
.btn-outline:hover { background: var(--gray-100); }
.btn-block { display: flex; width: 100%; }
.btn-sm { padding: 8px 12px; font-size: 13px; min-height: 36px; }

/* ─── SKU Code ─── */
.sku-badge {
    display: inline-block;
    background: var(--gray-900);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SF Mono', 'Menlo', 'Courier New', monospace;
    letter-spacing: 0.5px;
    vertical-align: middle;
    margin-right: 4px;
}

.sku-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.sku-code-large {
    display: inline-block;
    background: var(--gray-900);
    color: white;
    font-size: 18px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 6px;
    font-family: 'SF Mono', 'Menlo', 'Courier New', monospace;
    letter-spacing: 1px;
}

/* ─── Forms ─── */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 16px; /* 16px voorkomt zoom op iPhone */
    background: white;
    color: var(--gray-900);
    -webkit-appearance: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-textarea {
    min-height: 120px;
    resize: vertical;
}

/* ─── Upload zone ─── */
.upload-zone {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    padding: 32px 16px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    margin-bottom: 16px;
}

.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.05);
}

.upload-zone-icon {
    font-size: 48px;
    margin-bottom: 8px;
}

.upload-zone-text {
    font-size: 14px;
    color: var(--gray-500);
}

.upload-zone-text strong {
    color: var(--primary);
}

/* ─── Photo grid ─── */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.photo-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--gray-100);
}

.photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-delete {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0,0,0,0.6);
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.photo-primary {
    position: absolute;
    bottom: 4px;
    left: 4px;
    background: var(--primary);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
}

/* ─── Preview thumbnails (upload) ─── */
.preview-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--gray-100);
}

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

.preview-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(220,38,38,0.8);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 14px;
    cursor: pointer;
}

/* ─── Tube cards (overzicht) ─── */
.tube-list {
    display: grid;
    gap: 12px;
}

.tube-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
}

.tube-card-img {
    width: 100px;
    min-height: 100px;
    background: var(--gray-200);
    flex-shrink: 0;
}

.tube-card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tube-card-body {
    padding: 12px;
    flex: 1;
    min-width: 0;
}

.tube-card-title {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tube-card-meta {
    font-size: 13px;
    color: var(--gray-500);
}

.tube-card-price {
    font-weight: 700;
    color: var(--success);
    font-size: 16px;
    margin-top: 4px;
}

/* ─── Status badge ─── */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-draft { background: var(--gray-200); color: var(--gray-700); }
.badge-identified { background: #dbeafe; color: #1e40af; }
.badge-listed { background: #dcfce7; color: #166534; }
.badge-sold { background: #fef3c7; color: #92400e; }
.badge-active { background: #dcfce7; color: #166534; }
.badge-ended { background: var(--gray-200); color: var(--gray-700); }

/* ─── AI result ─── */
.ai-result {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}

.ai-result-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid #e0f2fe;
    font-size: 14px;
}

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

.ai-result-label {
    color: var(--gray-500);
    font-weight: 500;
}

.ai-result-value {
    font-weight: 600;
    text-align: right;
}

.confidence-high { color: var(--success); }
.confidence-medium { color: var(--warning); }
.confidence-low { color: var(--danger); }

/* ─── Listing table (mobile: card layout) ─── */
.listing-cards {
    display: grid;
    gap: 12px;
}

.listing-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 12px;
}

.listing-card-header {
    display: flex;
    gap: 12px;
    margin-bottom: 8px;
}

.listing-card-thumb {
    width: 60px;
    height: 60px;
    border-radius: 6px;
    object-fit: cover;
    background: var(--gray-200);
}

.listing-card-info { flex: 1; min-width: 0; }

.listing-card-title {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.listing-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

/* ─── Orders ─── */
.order-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 12px;
    margin-bottom: 12px;
}

.order-card-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 14px;
}

/* ─── Settings ─── */
.setting-item {
    padding: 16px 0;
    border-bottom: 1px solid var(--gray-200);
}

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

.setting-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-dot-green { background: var(--success); }
.status-dot-red { background: var(--danger); }
.status-dot-yellow { background: var(--warning); }

/* ─── Empty state ─── */
.empty-state {
    text-align: center;
    padding: 48px 16px;
    color: var(--gray-500);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.empty-state-text {
    font-size: 16px;
    margin-bottom: 16px;
}

/* ─── Confirm dialog ─── */
.btn-confirm {
    position: relative;
}

/* ─── Loading spinner ─── */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--gray-300);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

.loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 12px;
    z-index: 200;
    font-size: 16px;
    color: var(--gray-700);
}

.loading-overlay .loading {
    width: 40px;
    height: 40px;
    border-width: 3px;
}

/* ─── Tablet+ (768px) ─── */
@media (min-width: 768px) {
    .nav-toggle { display: none; }

    .nav-links {
        display: flex !important;
        position: static;
        background: none;
        padding: 0;
        border: none;
        gap: 4px;
    }

    .nav-links a {
        padding: 8px 12px;
        border-radius: 6px;
        font-size: 14px;
    }

    .container { padding: 24px; }

    .stats-grid { grid-template-columns: repeat(3, 1fr); }

    .photo-grid { grid-template-columns: repeat(3, 1fr); }

    .preview-grid { grid-template-columns: repeat(5, 1fr); }

    .tube-card-img { width: 140px; }

    .page-title { font-size: 28px; }
}

/* ─── Desktop (1024px) ─── */
@media (min-width: 1024px) {
    .photo-grid { grid-template-columns: repeat(4, 1fr); }

    .tube-detail-layout {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 24px;
    }
}
