/**
 * Form Components
 * All form-related styling: inputs, buttons, grid system, etc.
 */

/* Main wrapper - FULL WIDTH on desktop for software-like feel */
.utleiekalk-finn-wrapper {
    max-width: 100%;
    width: 100%;
    margin: 0 auto 34px;
    padding: 0 20px;
    font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
    color: var(--uk-text);
    box-sizing: border-box;
}

.utleiekalk-finn-form {
    display: grid;
    gap: var(--uk-gap);
    max-width: 1600px;
    margin: 0 auto;
}

/* Actions bar (top buttons) */
.uk-actions {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    align-items: center;
    background: #fff;
    border: 1px solid var(--uk-border);
    border-radius: 14px;
    padding: 10px 12px;
    box-shadow: 0 4px 14px rgba(0,0,0,.06);
    margin-bottom: 16px;
    overflow-x: auto;
}

.uk-actions .cases-toggle {
    margin-left: auto;
    flex-shrink: 0;
    white-space: nowrap;
}

/* Smaller font size for buttons to fit more on one line */
.uk-actions .uk-btn {
    font-size: 13px;
    padding: 8px 14px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Buttons */
.uk-btn {
    appearance: none;
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    line-height: 1;
    transition: .2s;
}

.uk-btn:active {
    transform: translateY(1px);
}

.uk-primary {
    background: var(--uk-primary);
    color: #fff;
    box-shadow: 0 8px 20px rgba(9,184,125,.25);
}

.uk-secondary {
    background: #0b1220;
    color: #fff;
}

.uk-ghost {
    background: #fff;
    color: #0b1220;
    border-color: var(--uk-border);
}

.uk-danger {
    background: #e11d48;
    color: #fff;
}

.uk-accent {
    background: var(--uk-accent);
    color: #111;
}

/* Grid system */
.uk-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 28px;
    row-gap: 32px;
}

.col-12 { grid-column: span 12; }
.col-8 { grid-column: span 8; }
.col-6 { grid-column: span 6; }
.col-4 { grid-column: span 4; }
.col-3 { grid-column: span 3; }

@media (max-width: 900px) {
    .col-8, .col-6 { grid-column: span 12; }
    .col-4 { grid-column: span 6; }
    .col-3 { grid-column: span 6; }
}

@media (max-width: 600px) {
    .col-4, .col-3 { grid-column: span 12; }
}

/* Form fields */
.uk-field label {
    display: block;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .3px;
    margin-bottom: 10px;
    text-transform: uppercase;
    color: #0b1220;
}

.uk-input,
.uk-number,
.uk-url,
.uk-select {
    width: 100%;
    padding: 14px 14px;
    border-radius: 12px;
    border: 1px solid var(--uk-border);
    background: #fff;
    font-size: 15px;
    transition: border-color .2s, box-shadow .2s;
}

.uk-input:focus,
.uk-number:focus,
.uk-url:focus,
.uk-select:focus {
    outline: none;
    border-color: var(--uk-primary);
    box-shadow: var(--uk-focus);
}

.uk-help {
    display: block;
    margin-top: 8px;
    font-size: 12px;
    color: var(--uk-muted);
}

/* Range sliders */
.uk-range-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.uk-range-wrap input[type="range"] {
    flex: 1;
    accent-color: var(--uk-primary);
    height: 6px;
    border-radius: 999px;
    /* Background is set dynamically by JavaScript to show progress */
}

.uk-range-out {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--uk-border);
    padding: 6px 10px;
    border-radius: 10px;
    background: #fff;
}

.uk-range-out input {
    width: 72px;
    border: none;
    outline: none;
    font-size: 14px;
}

/* Dynamic rows (expenses, oppussing, etc.) */
.extra-row {
    display: grid;
    grid-template-columns: 1.5fr 1fr .9fr auto;
    gap: 14px;
    align-items: center;
}

@media (max-width: 820px) {
    .extra-row {
        grid-template-columns: 1fr;
    }
}

.opp-row {
    display: grid;
    grid-template-columns: 1.4fr 1fr auto;
    gap: 14px;
    align-items: center;
}

@media (max-width: 820px) {
    .opp-row {
        grid-template-columns: 1fr;
    }
}

.remove-btn {
    border-radius: 10px;
    padding: 8px 12px;
    border: none;
    background: #e11d48;
    color: #fff;
    cursor: pointer;
}

/* Notices */
.notice {
    padding: 12px 14px;
    border-radius: 12px;
    background: #EAF8F1;
    border: 1px solid #C9F0E1;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,.04);
}

/* Badge */
.badge-total {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #0fbf8d12;
    border: 1px solid #0fbf8d33;
    color: #0b7d5d;
    padding: 6px 10px;
    border-radius: 999px;
    font-weight: 800;
}

/* ========================================
   MOBILE RESPONSIVENESS - PHASE 1
   ======================================== */

@media (max-width: 900px) {
    /* Prevent horizontal overflow */
    body {
        overflow-x: clip !important;
    }

    .utleiekalk-finn-wrapper,
    .utleiekalk-shell,
    .utleiekalk-finn-form {
        max-width: 100vw !important;
        overflow-x: clip !important;
    }

    /* Responsive grid - 1 column on mobile */
    .uk-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    /* Larger touch targets (44px minimum) */
    .uk-input,
    .uk-btn,
    input[type="url"] {
        min-height: 44px;
        font-size: 16px !important; /* Prevents iOS zoom */
        padding: 12px 16px;
    }

    /* Button adjustments */
    .uk-btn {
        padding: 12px 14px;
        font-size: 14px !important;
        white-space: nowrap;
    }

    /* Actions bar mobile layout */
    .uk-actions {
        padding: 8px;
        gap: 6px;
    }

    /* Hide secondary buttons on mobile (will be in hamburger menu) */
    .uk-actions .notater-btn,
    .uk-actions .utleiekalk-clear-all,
    .uk-actions .utleiekalk-pdf-btn,
    .uk-actions .utleiekalk-feedback-btn,
    .uk-actions .flipping-clear-all,
    .uk-actions .flipping-pdf-btn,
    .uk-actions .flipping-feedback-btn,
    #notater_btn,
    #flipping_notater_btn,
    #flipping_feedback_btn,
    .utleiekalk-feedback-btn,
    .flipping-feedback-btn,
    button.notater-btn,
    button.utleiekalk-clear-all,
    button.utleiekalk-pdf-btn,
    button.utleiekalk-feedback-btn,
    button.flipping-clear-all,
    button.flipping-pdf-btn,
    button.flipping-feedback-btn {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        position: absolute !important;
        left: -9999px !important;
    }

    /* Make saved calculations dropdown full width on mobile */
    .uk-actions .uk-right {
        width: 100%;
        margin-left: 0;
        justify-content: flex-end;
        order: 10; /* Move to bottom */
    }

    .cases-toggle {
        width: 100%;
    }

    /* Larger sliders for easier touch control */
    input[type="range"] {
        height: 12px !important;
    }

    input[type="range"]::-webkit-slider-thumb {
        width: 28px !important;
        height: 28px !important;
    }

    input[type="range"]::-moz-range-thumb {
        width: 28px !important;
        height: 28px !important;
    }

    /* Range slider wrapper adjustments */
    .uk-range-wrap {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .uk-range-out {
        width: 100%;
        justify-content: center;
    }

    /* Labels more readable */
    .uk-label {
        font-size: 15px;
    }

    /* Main wrapper padding */
    .utleiekalk-finn-wrapper {
        margin: 0 0 20px;
        padding: 0 8px;
    }

    /* Section padding */
    .uk-section-body {
        padding: 16px 12px;
    }

    /* Card padding */
    .uk-card {
        padding: 16px !important;
    }
}
