/**
 * Sticky Actions Panel (Left Side Menu)
 * Desktop-only vertical menu that expands on hover
 *
 * @package Utleiekalk_FINN
 * @since 0.30.9
 */

/* =================================================================
   STICKY NOTIFICATION (Top Left)
   ================================================================= */

.sticky-notification {
    position: fixed;
    top: 80px;
    left: 0;
    z-index: 9999;
    display: flex;
    align-items: flex-start;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.sticky-notification > * {
    pointer-events: auto;
}

/* Collapsed state - slide out to the left (only tab visible) */
.sticky-notification.collapsed {
    transform: translateX(-100%);
}

.sticky-notification.collapsed .notification-content {
    display: none;
}

/* Tab (always visible - clickable handle) */
.notification-tab {
    width: 6px;
    min-height: 60px;
    background: linear-gradient(135deg, #09B87D 0%, #078f63 100%);
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: width 0.3s ease, background 0.3s ease, min-height 0.3s ease;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
}

/* When collapsed, make tab larger and easier to click */
.sticky-notification.collapsed .notification-tab {
    width: 20px;
    min-height: 60px;
    padding: 8px 4px;
    position: absolute;
    right: -20px;
}

.notification-tab:hover {
    width: 8px;
    background: linear-gradient(135deg, #0ac992 0%, #089973 100%);
}

.sticky-notification.collapsed .notification-tab:hover {
    width: 24px;
}

/* Tab icon (hidden when expanded, visible when collapsed) */
.tab-icon {
    display: none;
}

.sticky-notification.collapsed .tab-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    font-size: 8px;
    font-weight: bold;
    color: #09B87D;
}

.sticky-notification.collapsed .tab-icon::before {
    content: '›';
    display: block;
}

/* Content area */
.notification-content {
    max-width: 400px;
    min-width: 320px;
    background: white;
    border-radius: 8px 0 0 8px;
    box-shadow: -2px 2px 12px rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

/* Notice styles (success, warning, error) */
.notification-content .notice {
    margin: 0;
    padding: 16px 20px;
    border-radius: 8px 0 0 8px;
    border-left: 4px solid;
}

.notification-content .notice p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
}

.notification-content .notice strong {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
}

/* Success */
.notification-content .notice.success {
    background: #f0fdf4;
    border-left-color: #10b981;
    color: #065f46;
}

/* Warning */
.notification-content .notice.warning {
    background: #fffbeb;
    border-left-color: #f59e0b;
    color: #92400e;
}

/* Error */
.notification-content .notice.error {
    background: #fef2f2;
    border-left-color: #ef4444;
    color: #991b1b;
}

/* Info */
.notification-content .notice.info {
    background: #eff6ff;
    border-left-color: #3b82f6;
    color: #1e40af;
}

/* Responsive */
@media screen and (max-width: 768px) {
    .sticky-notification {
        top: 10px;
    }

    .notification-content {
        min-width: 280px;
        max-width: calc(100vw - 20px);
    }
}

/* =================================================================
   STICKY ACTIONS PANEL (Left Side - Desktop Only)
   ================================================================= */

/* Only show on desktop */
@media screen and (min-width: 769px) {
    .sticky-actions-panel {
        position: fixed;
        left: 0;
        top: 200px;
        z-index: 9998;
        display: flex;
        flex-direction: column;
        gap: 0;
        width: 50px;
        transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        pointer-events: none;
    }

    .sticky-actions-panel:hover {
        width: 230px;
    }

    .sticky-actions-panel > * {
        pointer-events: auto;
    }

    /* Individual action items */
    .sticky-action-item {
        position: relative;
        height: 50px;
        display: flex;
        align-items: center;
        overflow: hidden;
        background: white;
        border-bottom: 1px solid #e5e7eb;
        box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
    }

    .sticky-action-item:first-child {
        border-radius: 0 8px 0 0;
    }

    .sticky-action-item:last-child {
        border-radius: 0 0 8px 0;
        border-bottom: none;
    }

    /* Icon - always visible, slides right on hover */
    .sticky-action-item .action-icon {
        position: absolute;
        left: 0;
        width: 50px;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        pointer-events: none;
        z-index: 2;
    }

    .sticky-action-item .action-icon svg {
        width: 20px;
        height: 20px;
        color: #09B87D;
    }

    /* Move icon to the right and shrink width when panel is hovered */
    .sticky-actions-panel:hover .sticky-action-item .action-icon {
        left: 8px;
        width: 36px;
    }

    /* Button - text hidden by default, visible on hover */
    .sticky-action-item .action-button {
        width: 230px;
        height: 100%;
        border: none;
        border-radius: 0;
        text-align: left;
        padding-left: 20px !important;
        padding-right: 16px !important;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
        opacity: 0;
        transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), padding-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        white-space: nowrap;
        font-size: 14px;
        font-weight: 500;
        background: white !important;
        color: #111827 !important;
    }

    /* Show button text when panel is hovered and move it to the right */
    .sticky-actions-panel:hover .sticky-action-item .action-button {
        opacity: 1;
        padding-left: 52px !important;
    }

    /* Button hover effects - only apply to panel item background */
    .sticky-action-item:hover {
        background: #f9fafb;
    }
}

/* Hide on mobile/tablet */
@media screen and (max-width: 768px) {
    .sticky-actions-panel {
        display: none;
    }
}

/* =================================================================
   KALKULATOR MODAL (Calculator Pop-up)
   ================================================================= */

.kalkulator-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100000;
    align-items: center;
    justify-content: center;
}

.kalkulator-modal.active {
    display: flex;
}

.kalkulator-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.kalkulator-modal-content {
    position: relative;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 95%;
    max-width: 500px;
    max-height: 95vh;
    overflow: hidden;
    animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.kalkulator-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid #e5e7eb;
}

.kalkulator-modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #111827;
}

.kalkulator-close {
    background: transparent !important;
    border: none;
    font-size: 32px;
    line-height: 1;
    color: #000 !important;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 0.15s ease, color 0.15s ease;
}

.kalkulator-close:hover {
    background: #f3f4f6;
    color: #111827;
}

.kalkulator-modal-body {
    padding: 24px;
}

.calc-display-wrapper {
    margin-bottom: 20px;
    position: relative;
}

.calc-display {
    width: 100%;
    padding: 20px;
    font-size: 32px;
    font-weight: 600;
    text-align: right;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    background: #f9fafb;
    color: #111827;
    font-family: 'SF Mono', 'Monaco', 'Courier New', monospace;
    cursor: pointer;
    transition: all 0.2s ease;
}

.calc-display:hover {
    background: #f3f4f6;
    border-color: var(--uk-primary);
}

.calc-copy-hint {
    margin-top: 8px;
    text-align: center;
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
}

.calc-copied-notification {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: var(--uk-primary);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    pointer-events: none;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.calc-copied-notification.show {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.calc-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.calc-btn {
    padding: 20px;
    font-size: 24px;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
}

.calc-btn:hover {
    transform: scale(1.05);
}

.calc-btn:active {
    transform: scale(0.95);
}

/* Number buttons */
.calc-num {
    background: #f9fafb;
    color: #111827;
}

.calc-num:hover {
    background: #f3f4f6;
}

/* Operator buttons */
.calc-op {
    background: var(--uk-primary);
    color: white;
}

.calc-op:hover {
    background: #08a06f;
}

/* Equals button */
.calc-equals {
    background: var(--uk-accent);
    color: white;
}

.calc-equals:hover {
    background: #f59e0b;
}

/* Clear button - spans 4 columns */
.calc-clear {
    grid-column: span 4;
    background: #ef4444;
    color: white;
}

.calc-clear:hover {
    background: #dc2626;
}

.kalkulator-modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .kalkulator-modal-content {
        width: 95%;
        max-width: 360px;
    }

    .calc-display {
        font-size: 28px;
        padding: 16px;
    }

    .calc-btn {
        padding: 16px;
        font-size: 20px;
    }

    .calc-buttons {
        gap: 8px;
    }
}

/* =================================================================
   LAGREDE KALKULASJONER MODAL (Saved Calculations)
   ================================================================= */

.lagrede-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100000;
    align-items: center;
    justify-content: center;
}

.lagrede-modal.active {
    display: flex;
}

.lagrede-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.lagrede-modal-content {
    position: relative;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    overflow: hidden;
    animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.lagrede-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
}

.lagrede-modal-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #111827;
}

.lagrede-close {
    background: none;
    border: none;
    font-size: 32px;
    line-height: 1;
    color: #6b7280;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 0.15s ease, color 0.15s ease;
}

.lagrede-close:hover {
    background: #f3f4f6;
    color: #111827;
}

.lagrede-modal-body {
    padding: 24px;
    max-height: calc(90vh - 80px);
    overflow-y: auto;
}

.lagrede-cases-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.lagrede-cases-list .case-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    transition: all 0.15s ease;
}

.lagrede-cases-list .case-item:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.lagrede-cases-list .case-item > div:first-child {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.lagrede-cases-list .case-item > div:first-child input {
    width: 100%;
}

.lagrede-cases-list .case-meta {
    font-size: 13px;
    color: #6b7280;
}

.lagrede-cases-list .case-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
    flex-shrink: 0;
}

.lagrede-cases-list .case-buttons button {
    white-space: nowrap;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .lagrede-modal-content {
        width: 95%;
        max-width: 500px;
    }

    .lagrede-cases-list .case-item {
        flex-direction: column;
        align-items: stretch;
    }

    .lagrede-cases-list .case-buttons {
        flex-direction: column;
    }

    .lagrede-cases-list .case-buttons button {
        width: 100%;
    }
}
