/**
 * Rental Calculator UI Improvements
 * Professional and clean UI enhancements with better spacing and hierarchy
 */

/* ==========================================
   IMPROVED SPACING
   ========================================== */

/* Card spacing */
.uk-card {
    margin-bottom: var(--spacing-2xl) !important;
}

/* Section header spacing */
.uk-step {
    margin-bottom: var(--spacing-lg) !important;
}

/* Field spacing within sections */
.uk-field {
    margin-bottom: var(--spacing-lg);
}

.uk-field:last-child {
    margin-bottom: 0;
}

/* Grid improvements */
.uk-grid {
    gap: var(--uk-gap) !important;
    row-gap: var(--uk-gap-rows) !important;
}

/* Divider spacing */
.divider {
    margin: var(--spacing-lg) 0;
}

/* ==========================================
   TYPOGRAPHY IMPROVEMENTS
   ========================================== */

/* Reduce font-weight for better hierarchy */
.uk-step .uk-step-title {
    font-weight: 700 !important;
}

.seg-btn {
    font-weight: 700 !important;
}

.metric-title {
    font-weight: 700 !important;
}

.metric-value {
    font-weight: 700 !important;
}

/* Form labels */
label.uk-label,
.uk-label {
    font-weight: 600 !important;
}

/* Modal headers */
.notater-modal-header h3,
.lagrede-modal-header h3,
.feedback-modal-header h3 {
    font-weight: 700 !important;
}

/* ==========================================
   COMPONENT-SPECIFIC CLASSES
   ========================================== */

/* Toggle field wrapper */
.toggle-field-wrapper {
    margin-top: var(--spacing-md);
}

/* Toggle label */
.toggle-label {
    display: block;
    cursor: pointer;
    user-select: none;
}

/* Toggle title */
.toggle-title {
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 12px;
}

/* Toggle help text */
.toggle-help {
    margin-top: 2px;
}

/* Mode switcher content */
.mode-content {
    margin-top: var(--spacing-lg);
}

/* Field group for related inputs */
.field-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

/* Dynamic cost lists */
.dynamic-cost-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Cost row */
.cost-row {
    display: flex;
    gap: 10px;
}

/* Cost row with header */
.cost-row-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Grid with custom row gap */
.grid-row-gap-sm {
    row-gap: var(--spacing-md) !important;
}

.grid-row-gap-md {
    row-gap: var(--spacing-lg) !important;
}

/* Hidden elements */
.hidden {
    display: none !important;
}

/* Margin utilities */
.margin-0 {
    margin: 0 !important;
}

.margin-top-0 {
    margin-top: 0 !important;
}

.margin-top-sm {
    margin-top: 40px !important; /* Increased spacing between "Utgifter til oppussing" and "Verdi etter oppussing" */
}

/* More specific targeting for Verdi etter oppussing section */
label[for="oppussing_verdi_etter"],
label[for="oppussing_maneder"] {
    /* Add padding above both labels to keep them on the same row */
    padding-top: 40px !important;
}

.margin-top-md {
    margin-top: var(--spacing-md) !important;
}

.margin-top-lg {
    margin-top: var(--spacing-lg) !important;
}

.margin-bottom-md {
    margin-bottom: var(--spacing-md) !important;
}

.margin-bottom-lg {
    margin-bottom: var(--spacing-lg) !important;
}

/* Details/dropdown styling */
details.uk-card {
    margin-top: var(--spacing-lg) !important;
}

details summary {
    cursor: pointer;
    font-weight: 600;
    list-style: none;
}

details summary::-webkit-details-marker {
    display: none;
}

details .metrics {
    margin-top: var(--spacing-md);
}

/* Full width button */
.width-full {
    width: 100%;
}

/* Display utilities */
.display-none {
    display: none !important;
}

.display-block {
    display: block;
}

/* ==========================================
   IMPROVED VISUAL HIERARCHY
   ========================================== */

/* Primary metrics (monthly/yearly cashflow) */
.metric-primary {
    grid-column: span 12 !important;
    padding: var(--spacing-lg) !important;
    background: linear-gradient(135deg, #f0fdf9 0%, #ffffff 100%);
    border: 2px solid var(--uk-primary);
}

.metric-primary .metric-value {
    font-size: 24px;
}

/* Results section background */
.results-section {
    background: linear-gradient(135deg, #f0fdf9 0%, #f0f9ff 100%);
}

/* Input sections subtle background */
.input-section {
    background: var(--uk-bg-subtle);
}

/* ==========================================
   IMPROVED RESULTS LAYOUT (Flipping-style)
   ========================================== */

/* Main result container */
.uk-result-main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 28px;
    margin-bottom: 36px;
    padding-bottom: 36px;
    border-bottom: 2px solid rgba(9, 184, 125, 0.2);
}

/* Primary result (left side - large) */
.uk-result-primary {
    text-align: center;
    padding: 32px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.uk-result-label {
    font-size: 14px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.uk-result-value-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 16px 0;
}

.uk-result-value {
    font-size: 48px;
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.uk-result-value.positive {
    color: var(--uk-green);
}

.uk-result-value.negative {
    color: var(--uk-red);
}

.uk-result-sublabel {
    font-size: 13px;
    color: #64748b;
    margin-top: 8px;
}

/* Result thumb icons (SVG) */
.uk-result-thumb {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.uk-result-thumb svg {
    width: 100%;
    height: 100%;
}

.uk-result-thumb.positive svg path {
    fill: var(--uk-primary);
}

.uk-result-thumb.negative svg path {
    fill: var(--uk-red);
}

/* Secondary metrics (right side - compact list) */
.uk-result-secondary {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 24px;
    background: #f8fafc;
    border-radius: 12px;
}

.uk-metric-small {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #e2e8f0;
}

.uk-metric-small:last-child {
    border-bottom: none;
}

.uk-metric-small .label {
    font-size: 14px;
    color: #64748b;
    font-weight: 500;
}

.uk-metric-small .value {
    font-size: 16px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--uk-text);
}

.uk-metric-small .value-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Small thumb icons */
.metric-thumb-small {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.metric-thumb-small svg {
    width: 100%;
    height: 100%;
}

.metric-thumb-small.positive svg path {
    fill: var(--uk-primary);
}

.metric-thumb-small.negative svg path {
    fill: var(--uk-red);
}

/* ==========================================
   COLOR CONSISTENCY
   ========================================== */

/* Replace hardcoded colors with variables */
.avdragsfrihet-toggle,
.skatt-overskudd-toggle {
    background: var(--uk-bg-toggle) !important;
}

#hybrid_maneder_langtid,
#hybrid_maneder_langtid::-webkit-slider-runnable-track,
#hybrid_maneder_langtid::-moz-range-track {
    background: var(--uk-bg-toggle) !important;
}

/* Read-only inputs */
input[readonly],
.uk-input[readonly] {
    background: var(--uk-bg-input-readonly) !important;
}

/* Border consistency */
.uk-step.js-collapser:after {
    border-right-color: var(--uk-muted);
    border-bottom-color: var(--uk-muted);
}

/* ==========================================
   METRICS GRID IMPROVEMENTS
   ========================================== */

.metrics {
    gap: var(--spacing-lg) !important;
    row-gap: var(--spacing-lg) !important;
}

.metric {
    padding: var(--spacing-md) var(--spacing-lg) !important;
}

/* ==========================================
   RESPONSIVE IMPROVEMENTS
   ========================================== */

@media (max-width: 768px) {
    /* Maintain better proportions on mobile */
    .uk-card {
        padding: var(--spacing-lg);
        margin-bottom: var(--spacing-xl);
    }

    .uk-step {
        margin-bottom: var(--spacing-md);
    }

    .uk-field {
        margin-bottom: var(--spacing-md);
    }

    .metrics {
        gap: var(--spacing-md) !important;
    }

    /* Hide thumb icons on mobile for cash flow */
    .uk-result-thumb,
    .metric-thumb-small {
        display: none !important;
    }

    /* Color the yearly cash flow value based on the thumb's positive/negative class */
    .value-wrap:has(.metric-thumb-small.positive) .value {
        color: var(--uk-primary) !important;
    }

    .value-wrap:has(.metric-thumb-small.negative) .value {
        color: var(--uk-red) !important;
    }

    /* Fallback for monthly cash flow value coloring */
    .uk-result-value-wrap:has(.uk-result-thumb.positive) .uk-result-value {
        color: var(--uk-primary) !important;
    }

    .uk-result-value-wrap:has(.uk-result-thumb.negative) .uk-result-value {
        color: var(--uk-red) !important;
    }
}

/* Mobile responsiveness for results layout */
@media (max-width: 768px) {
    .uk-result-main {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .uk-result-primary {
        padding: 24px;
    }

    .uk-result-value {
        font-size: 36px;
    }

    .uk-result-secondary {
        padding: 16px;
    }
}
