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

:root {
    --primary: #642368;
    --primary-light: #8b3791;
    --primary-bg: #f9f0fa;
    --success: #16a34a;
    --success-bg: #f0fdf4;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --warning: #f59e0b;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.5;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
}

/* === APP SHELL === */
.app {
    max-width: 600px;
    margin: 0 auto;
    padding-bottom: 2rem;
}

.app-header {
    background: var(--primary);
    color: white;
    padding: 1.25rem 1.25rem 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.app-header .subtitle {
    font-size: 0.875rem;
    opacity: 0.8;
    margin-top: 0.125rem;
}

/* Save indicator */
.save-indicator {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    opacity: 0.8;
    transition: opacity 0.3s;
}

.save-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    display: inline-block;
}

.save-indicator.saving .save-dot {
    background: var(--warning);
    animation: pulse 1s infinite;
}

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

/* === PROGRESS === */
.progress-bar {
    height: 3px;
    background: rgba(255,255,255,0.2);
    position: sticky;
    top: 0;
    z-index: 99;
}

.progress-fill {
    height: 100%;
    background: #a855b8;
    transition: width 0.3s ease;
    width: 25%;
}

.progress-steps {
    display: flex;
    background: white;
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 98;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.progress-steps .step {
    flex: 1;
    padding: 0.75rem 0.5rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--gray-400);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.progress-steps .step.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.progress-steps .step.completed {
    color: var(--success);
}

/* === FORM SECTIONS === */
.form-section {
    display: none;
    padding: 1.25rem;
    animation: fadeIn 0.25s ease;
}

.form-section.active {
    display: block;
}

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

.section-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 0.25rem;
}

.section-desc {
    font-size: 0.875rem;
    color: var(--gray-500);
    margin-bottom: 1.25rem;
}

.subsection-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.75rem;
}

.divider {
    border: none;
    border-top: 1px solid var(--gray-200);
    margin: 1.25rem 0;
}

/* === FIELDS === */
.field {
    margin-bottom: 1rem;
}

.field label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.375rem;
}

.req {
    color: var(--danger);
}

.field input[type="text"],
.field input[type="email"],
.field input[type="tel"],
.field input[type="number"],
.field select,
.field textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius-sm);
    background: white;
    color: var(--gray-800);
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.field select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(100, 35, 104, 0.15);
}

.field input.error,
.field select.error {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.field textarea {
    resize: vertical;
    min-height: 60px;
}

.field-help {
    display: block;
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 0.375rem;
    line-height: 1.4;
}

.field-row {
    display: flex;
    gap: 0.75rem;
}

.flex-1 {
    flex: 1;
}

/* === CHECKBOXES === */
.checkbox-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.75rem;
    background: white;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--gray-700);
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
    -webkit-user-select: none;
}

.checkbox-item:active {
    background: var(--gray-50);
}

.checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    flex-shrink: 0;
}

.checkbox-item:has(input:checked) {
    border-color: var(--primary-light);
    background: var(--primary-bg);
    color: var(--primary);
}

/* === TOGGLE GROUP (Ja/Nei) === */
.toggle-group {
    display: flex;
    gap: 0.75rem;
}

.toggle-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem;
    background: white;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
    -webkit-user-select: none;
}

.toggle-option input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.toggle-label {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--gray-600);
}

.toggle-option:has(input:checked) {
    border-color: var(--primary-light);
    background: var(--primary-bg);
}

.toggle-option:has(input:checked) .toggle-label {
    color: var(--primary);
}

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}

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

.btn-primary:active {
    background: #4a1a4e;
    transform: scale(0.98);
}

.btn-secondary {
    background: white;
    color: var(--gray-600);
    border: 1.5px solid var(--gray-300);
}

.btn-secondary:active {
    background: var(--gray-50);
}

.btn-submit {
    width: 100%;
    padding: 1rem;
    font-size: 1.0625rem;
    background: var(--success);
    color: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}

.btn-submit:active {
    background: #15803d;
    transform: scale(0.98);
}

.btn-submit:disabled {
    background: var(--gray-300);
    cursor: not-allowed;
    box-shadow: none;
}

.btn-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--gray-400);
    transition: all 0.15s;
}

.btn-icon:active {
    background: var(--gray-100);
}

.btn-delete-room {
    color: var(--danger);
}

.nav-buttons {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--gray-200);
}

/* === ADD ROOM BUTTON === */
.btn-add-room {
    width: 100%;
    padding: 1rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-bg);
    border: 2px dashed var(--primary-light);
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.15s;
    margin-bottom: 1rem;
}

.btn-add-room:active {
    background: #eeddf0;
    transform: scale(0.98);
}

/* === ROOM CARDS === */
.room-card {
    background: white;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.room-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1rem;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.room-header-left {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    min-width: 0;
    flex: 1;
}

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

.room-name-display {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--gray-700);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.room-header-right {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

/* === ARMATUR GROUPS === */
.armatur-group {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.armatur-group-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.75rem;
}

.armatur-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.armatur-group-header .armatur-group-title {
    margin-bottom: 0;
}

.btn-remove-armatur {
    color: var(--danger);
}

.btn-add-armatur {
    width: 100%;
    padding: 0.625rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--primary);
    background: transparent;
    border: 1.5px dashed var(--primary-light);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    margin-bottom: 1rem;
    transition: all 0.15s;
}

.btn-add-armatur:active {
    background: var(--primary-bg);
}

.btn-add-armatur[style*="display: none"],
.btn-add-armatur.hidden {
    display: none !important;
}

.room-body {
    padding: 1rem;
}

.room-card.collapsed .room-body {
    display: none;
}

.room-card.collapsed .btn-toggle-room svg {
    transform: rotate(-90deg);
}

.btn-toggle-room svg {
    transition: transform 0.2s;
}

/* === IMAGE UPLOAD === */
.image-upload {
    width: 100%;
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.image-grid:empty {
    display: none;
    margin-bottom: 0;
}

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

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

.image-thumb .remove-image {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    background: rgba(0,0,0,0.6);
    color: white;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
}

.upload-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem;
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-sm);
    background: var(--gray-50);
    color: var(--gray-500);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    width: 100%;
}

.upload-btn:active {
    background: var(--gray-100);
    border-color: var(--gray-400);
}

.file-input {
    display: none;
}

/* === SUMMARY CARD === */
.summary-card {
    background: white;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.875rem;
}

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

.summary-label {
    color: var(--gray-500);
}

.summary-value {
    font-weight: 600;
    color: var(--gray-800);
    text-align: right;
}

.submit-area {
    margin-bottom: 1.5rem;
}

.submit-help {
    text-align: center;
    font-size: 0.8125rem;
    color: var(--gray-400);
    margin-top: 0.75rem;
}

/* === SUCCESS SCREEN === */
.success-screen {
    text-align: center;
    padding: 3rem 1.5rem;
}

.success-icon {
    margin-bottom: 1.5rem;
}

.success-screen h2 {
    font-size: 1.5rem;
    color: var(--success);
    margin-bottom: 0.5rem;
}

.success-screen p {
    color: var(--gray-500);
    margin-bottom: 2rem;
}

/* === TOAST NOTIFICATIONS === */
.toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--gray-800);
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    z-index: 1000;
    transition: transform 0.3s ease;
    max-width: calc(100vw - 2rem);
}

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

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

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

/* === RESPONSIVE === */
@media (max-width: 380px) {
    .checkbox-grid {
        grid-template-columns: 1fr;
    }

    .image-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 601px) {
    .app {
        margin-top: 1rem;
        border-radius: var(--radius) var(--radius) 0 0;
        overflow: hidden;
        box-shadow: var(--shadow-md);
    }

    .app-header {
        position: relative;
        border-radius: var(--radius) var(--radius) 0 0;
    }

    .progress-steps {
        position: relative;
    }
}

/* Prevent zoom on iOS */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
    select, textarea, input[type="text"], input[type="email"], input[type="tel"], input[type="number"] {
        font-size: 16px;
    }
}
