/* ============================================
   HoutVeilig - Meldingsapp Houtbranche
   CSS Stylesheet
   ============================================ */

/* === Reset & Base === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #2E7D32;
    --primary-dark: #1B5E20;
    --primary-light: #4CAF50;
    --accent: #FF8F00;
    --accent-dark: #E65100;
    --danger: #D32F2F;
    --danger-light: #FFCDD2;
    --warning: #F57F17;
    --warning-light: #FFF9C4;
    --success: #2E7D32;
    --success-light: #C8E6C9;
    --bg: #F5F5F5;
    --bg-card: #FFFFFF;
    --text: #212121;
    --text-secondary: #757575;
    --text-light: #FFFFFF;
    --border: #E0E0E0;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.15);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.2s ease;
    --safe-top: env(safe-area-inset-top);
    --safe-bottom: env(safe-area-inset-bottom);
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

.hidden {
    display: none !important;
}

/* === Splash Screen === */
.splash-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.splash-screen.fade-out {
    opacity: 0;
    visibility: hidden;
}

.splash-content {
    text-align: center;
    color: white;
}

.splash-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: bounce 1s ease infinite;
}

.splash-content h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.splash-content p {
    font-size: 1rem;
    opacity: 0.8;
    margin-bottom: 2rem;
}

.splash-loader {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    margin: 0 auto;
    animation: spin 0.8s linear infinite;
}

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

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* === App Header === */
.app-header {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: white;
    padding: calc(var(--safe-top) + 12px) 16px 12px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.header-content {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 600px;
    margin: 0 auto;
}

.header-logo {
    font-size: 2rem;
}

.header-text h1 {
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1.2;
}

.header-subtitle {
    font-size: 0.75rem;
    opacity: 0.85;
}

.header-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    text-align: right;
}

.user-name {
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.2;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-email {
    font-size: 0.6rem;
    opacity: 0.75;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-logout {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 8px;
    padding: 6px 8px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: var(--transition);
    color: white;
    line-height: 1;
}

.btn-logout:hover {
    background: rgba(255,255,255,0.25);
}

/* === Tab Navigation === */
.tab-nav {
    display: flex;
    background: white;
    border-bottom: 2px solid var(--border);
    position: sticky;
    top: 64px;
    z-index: 99;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.tab-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 8px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.tab-btn.active {
    color: var(--primary);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 10%;
    right: 10%;
    height: 3px;
    background: var(--primary);
    border-radius: 3px 3px 0 0;
}

.tab-icon {
    font-size: 1.3rem;
}

.tab-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* === Tab Content === */
.tab-content {
    display: none;
    padding: 16px;
    padding-bottom: calc(var(--safe-bottom) + 24px);
    max-width: 600px;
    margin: 0 auto;
}

.tab-content.active {
    display: block;
}

/* === Form Sections === */
.form-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 16px;
}

.section-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    font-size: 0.85rem;
    font-weight: 700;
    flex-shrink: 0;
}

/* === Melding Type Grid === */
.melding-type-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.type-card {
    cursor: pointer;
}

.type-card input[type="radio"] {
    display: none;
}

.type-card-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 8px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    transition: var(--transition);
    text-align: center;
}

.type-card input:checked + .type-card-content {
    border-color: var(--primary);
    background: var(--success-light);
    box-shadow: 0 0 0 1px var(--primary);
}

.type-icon {
    font-size: 1.8rem;
}

.type-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.2;
}

/* === Foto Section === */
.foto-preview-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.foto-preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: var(--shadow);
}

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

.foto-preview-item .foto-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    background: rgba(211, 47, 47, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.foto-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 8px;
}

.foto-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
}

/* === Form Inputs === */
.form-group {
    margin-bottom: 16px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    color: var(--text);
    background: white;
    transition: var(--transition);
    -webkit-appearance: none;
    appearance: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.15);
}

.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23757575' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

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

.form-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* === Locatie Section === */
.locatie-section {
    text-align: center;
}

.locatie-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: var(--warning-light);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
}

.locatie-status.success {
    background: var(--success-light);
}

.locatie-status.error {
    background: var(--danger-light);
}

.locatie-icon {
    font-size: 1.3rem;
}

.locatie-text {
    font-size: 0.85rem;
    font-weight: 500;
}

.locatie-info {
    text-align: left;
    padding: 12px;
    background: #F9FBE7;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
}

.locatie-detail {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 0.85rem;
}

.detail-label {
    color: var(--text-secondary);
}

.detail-value {
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn:active {
    transform: scale(0.97);
}

.btn-icon {
    font-size: 1.1rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 3px 8px rgba(46, 125, 50, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 4px 12px rgba(46, 125, 50, 0.4);
}

.btn-secondary {
    background: white;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-camera {
    flex: 1;
    background: var(--primary);
    color: white;
}

.btn-gallery {
    flex: 1;
    background: white;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-maps {
    display: inline-flex;
    background: var(--accent);
    color: white;
    margin-top: 8px;
    font-size: 0.8rem;
    padding: 8px 16px;
}

.btn-locatie {
    background: white;
    color: var(--primary);
    border: 2px solid var(--primary);
    width: 100%;
    margin-top: 8px;
}

.btn-large {
    width: 100%;
    padding: 16px 24px;
    font-size: 1rem;
}

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

.btn-small {
    padding: 8px 12px;
    font-size: 0.75rem;
}

.verzend-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
}

/* === Overzicht === */
.overzicht-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.overzicht-header h2 {
    font-size: 1.1rem;
    color: var(--primary-dark);
}

.meldingen-lijst {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.melding-card {
    background: white;
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary);
}

.melding-card.prioriteit-laag {
    border-left-color: #4CAF50;
}
.melding-card.prioriteit-middel {
    border-left-color: #FFC107;
}
.melding-card.prioriteit-hoog {
    border-left-color: #FF9800;
}
.melding-card.prioriteit-kritiek {
    border-left-color: #D32F2F;
}

.melding-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.melding-card-type {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary-dark);
}

.melding-card-datum {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.melding-card-beschrijving {
    font-size: 0.85rem;
    color: var(--text);
    margin-bottom: 8px;
    line-height: 1.4;
}

.melding-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.melding-card-prioriteit {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
}

.prioriteit-badge-laag { background: #C8E6C9; color: #1B5E20; }
.prioriteit-badge-middel { background: #FFF9C4; color: #F57F17; }
.prioriteit-badge-hoog { background: #FFE0B2; color: #E65100; }
.prioriteit-badge-kritiek { background: #FFCDD2; color: #B71C1C; }

.melding-card-actions {
    display: flex;
    gap: 8px;
}

.melding-card-actions .btn {
    padding: 6px 12px;
    font-size: 0.75rem;
}

.empty-state {
    text-align: center;
    padding: 48px 16px;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* === Toast Notification === */
.toast {
    position: fixed;
    bottom: calc(var(--safe-bottom) + 20px);
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #323232;
    color: white;
    padding: 12px 24px;
    border-radius: 24px;
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    opacity: 0;
    transition: all 0.3s ease;
    max-width: calc(100% - 32px);
    text-align: center;
}

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

.toast.toast-success { background: var(--success); }
.toast.toast-error { background: var(--danger); }
.toast.toast-warning { background: var(--warning); }

/* === Scrollbar === */
::-webkit-scrollbar {
    width: 4px;
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

/* === Print === */
@media print {
    .app-header, .tab-nav, .foto-buttons, .verzend-buttons, .btn-locatie {
        display: none;
    }
    .tab-content { display: block !important; }
    .form-section { break-inside: avoid; box-shadow: none; border: 1px solid #ddd; }
}

/* === Larger Screens === */
@media (min-width: 768px) {
    .melding-type-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .foto-preview-grid {
        grid-template-columns: repeat(5, 1fr);
    }
    
    .user-name {
        max-width: 200px;
    }
    
    .user-email {
        max-width: 200px;
    }
}

/* === Login Screen === */
.login-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
}

.login-content {
    text-align: center;
    color: white;
    padding: 2rem;
    max-width: 400px;
    width: 100%;
}

.login-logo {
    font-size: 5rem;
    margin-bottom: 1rem;
    animation: bounce 2s ease infinite;
}

.login-content h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.login-subtitle {
    font-size: 1.1rem;
    opacity: 0.85;
    margin-bottom: 2rem;
}

.login-description {
    font-size: 0.95rem;
    opacity: 0.75;
    margin-bottom: 2.5rem;
    line-height: 1.5;
}

.btn-login {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: white;
    color: #333;
    border: none;
    border-radius: 8px;
    padding: 14px 32px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 320px;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(0,0,0,0.3);
}

.btn-login:active {
    transform: translateY(0);
}

.ms-logo {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.auth-error {
    margin-top: 1.5rem;
    background: rgba(211, 47, 47, 0.2);
    border: 1px solid rgba(211, 47, 47, 0.4);
    border-radius: 8px;
    padding: 12px 16px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    text-align: left;
    font-size: 0.85rem;
    line-height: 1.4;
}

.auth-error-icon {
    flex-shrink: 0;
    font-size: 1.1rem;
}

