/* Unified Input Styles */

/* Primary task switcher */
.segmented-control-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

.segmented-control {
    display: flex;
    align-items: center;
    width: min(100%, 480px);
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 12px;
    background: linear-gradient(180deg, #dfe3e9 0%, #edf0f4 100%);
    box-shadow:
        inset 0 2px 5px rgba(15, 23, 42, 0.13),
        0 1px 0 rgba(255, 255, 255, 0.7);
    padding: 4px;
    position: relative;
}

.segmented-slider {
    position: absolute;
    height: calc(100% - 8px);
    width: calc((100% - 8px) / 3);
    border: 1px solid rgba(15, 23, 42, 0.12);
    background: var(--control-surface);
    border-radius: 10px;
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.1),
        0 4px 9px rgba(15, 23, 42, 0.11),
        var(--control-highlight);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    left: 4px;
    top: 4px;
    pointer-events: none;
}

.segment {
    position: relative;
    z-index: 1;
    flex: 1;
    min-width: 0;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: none;
    background: transparent;
    color: #6b7280;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.18s ease, transform 0.18s ease;
    transform: translateY(0);
}

.segment:active {
    transform: translateY(1px);
}

.segment.active {
    color: var(--color-primary-dark);
}

.segment:focus-visible {
    border-radius: 9px;
    outline: 2px solid var(--color-primary);
    outline-offset: -2px;
}

@media (hover: hover) and (pointer: fine) {
    .segment:hover {
        color: var(--color-primary);
    }
}

.input-navigation[data-active-job="biompin"] .segmented-slider {
    transform: translateX(100%);
}

.input-navigation[data-active-job="history"] .segmented-slider {
    transform: translateX(200%);
}

/* Primary file picker */
.upload-file-mark {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    margin: 0 auto 1.1rem;
    border: 1px solid rgba(102, 126, 234, 0.18);
    border-radius: 15px;
    background: linear-gradient(145deg, #ffffff 0%, #eef2ff 100%);
    box-shadow:
        0 8px 20px rgba(79, 70, 229, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.upload-file-mark .drag-drop-icon {
    margin: 0;
    font-size: 1.65rem;
}

.browse-files-btn {
    min-height: 44px;
    padding: 0.58rem 1.2rem !important;
    border: 1px solid rgba(102, 126, 234, 0.3) !important;
    background: var(--control-surface) !important;
    box-shadow: none;
    color: #5267d8 !important;
    font-size: 0.925rem !important;
    font-weight: 600;
    transition: var(--control-transition);
    cursor: pointer;
}

.split-file-picker {
    display: inline-flex;
    position: relative;
    border-radius: 11px;
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.08),
        0 3px 8px rgba(79, 70, 229, 0.09),
        var(--control-highlight);
    transition: var(--control-transition);
    transform: translateY(0);
}

.split-file-picker .browse-files-btn {
    margin: 0 !important;
    box-shadow: none;
    transform: none;
}

.split-file-picker:has(.browse-files-btn:active) {
    box-shadow: var(--control-shadow-pressed);
    transform: translateY(1px);
}

.split-file-picker:has(.input-alternatives-menu.show) {
    z-index: 20;
}

.split-file-primary {
    border-radius: 11px 0 0 11px !important;
    border-right: 0 !important;
}

.split-file-primary:focus {
    border-color: rgba(102, 126, 234, 0.45) !important;
    background: #f8faff !important;
    color: var(--color-primary-dark) !important;
}

.split-file-toggle {
    width: 44px;
    padding: 0.58rem 0.72rem !important;
    border-left: 1px solid rgba(102, 126, 234, 0.2) !important;
    border-radius: 0 11px 11px 0 !important;
    background: linear-gradient(180deg, #f8f9ff 0%, #edf0ff 100%) !important;
}

.split-file-toggle:focus,
.split-file-toggle.show {
    border-color: rgba(102, 126, 234, 0.42) !important;
    background: #e9edff !important;
    color: var(--color-primary-dark) !important;
}

@media (hover: hover) and (pointer: fine) {
    .split-file-picker:hover,
    .split-file-picker:focus-within {
        box-shadow:
            0 2px 3px rgba(15, 23, 42, 0.08),
            0 3px 8px rgba(79, 70, 229, 0.11),
            var(--control-highlight);
        transform: translateY(-1px);
    }

    .split-file-primary:hover {
        border-color: rgba(102, 126, 234, 0.45) !important;
        background: #f8faff !important;
        color: var(--color-primary-dark) !important;
    }

    .split-file-toggle:hover {
        border-color: rgba(102, 126, 234, 0.42) !important;
        background: #e9edff !important;
        color: var(--color-primary-dark) !important;
    }
}

.input-alternatives-menu {
    min-width: 235px;
    margin-top: 0.55rem !important;
    padding: 0.45rem;
    border: 1px solid rgba(102, 126, 234, 0.16);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow:
        0 16px 36px rgba(15, 23, 42, 0.13),
        0 3px 8px rgba(79, 70, 229, 0.08);
}

.input-alternative-action {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-height: 42px;
    padding: 0.55rem 0.7rem;
    border-radius: 9px;
    border: 1px solid transparent;
    background: transparent;
    box-shadow: none;
    color: #475569;
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--control-transition);
    transform: translateY(0);
}

.input-alternative-action:focus,
.input-alternative-action:active {
    border-color: rgba(102, 126, 234, 0.16);
    background: linear-gradient(180deg, #f7f8ff 0%, #eef2ff 100%);
    color: var(--color-primary);
}

.input-alternative-action:active {
    box-shadow: inset 0 2px 4px rgba(79, 70, 229, 0.1);
    transform: translateY(1px);
}

@media (hover: hover) and (pointer: fine) {
    .input-alternative-action:hover {
        border-color: rgba(102, 126, 234, 0.16);
        background: linear-gradient(180deg, #f7f8ff 0%, #eef2ff 100%);
        box-shadow:
            0 2px 5px rgba(79, 70, 229, 0.08),
            inset 0 1px 0 rgba(255, 255, 255, 0.72);
        color: var(--color-primary);
        transform: translateY(-1px);
    }
}

.input-alternative-action i {
    width: 1rem;
    text-align: center;
}

/* Drag and drop areas */
.drag-drop-area {
    border: 1px solid rgba(102, 126, 234, 0.14);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    text-align: center;
    transition:
        background 0.22s ease,
        border-color 0.22s ease;
    cursor: pointer;
    background: linear-gradient(145deg, #fafbff 0%, #f4f6ff 100%);
}

@media (hover: hover) and (pointer: fine) {
    .drag-drop-area:hover {
        border-color: rgba(102, 126, 234, 0.28);
        background: linear-gradient(145deg, #f8faff 0%, #eef2ff 100%);
    }
}

.drag-drop-area.drag-over {
    border-color: var(--color-primary);
    background: linear-gradient(145deg, #f1f4ff 0%, #e8edff 100%);
}

.drag-drop-icon {
    font-size: 2.5rem;
    color: var(--color-primary);
    display: block;
}

/* File preview */
.file-preview {
    background: rgba(102, 126, 234, 0.05);
    border-radius: var(--border-radius-md);
    padding: 1rem;
    margin-top: 1rem;
}

.file-preview h6 {
    font-weight: 500; /* Medium weight instead of default 600 */
}

/* File preview text container - prevent button overflow */
.file-preview-text {
    min-width: 0; /* Allow text to shrink below natural width */
}

.file-preview-text h6 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* File preview remove button - prevent shrinking */
#uploadRemoveFile {
    flex-shrink: 0; /* Prevent button from being squeezed */
}

/* BiomPIN input styling */
#biompinInput {
    font-family: var(--biompin-font-family);
    font-weight: 600;
    letter-spacing: 0;
}

#biompinInput::placeholder {
    font-weight: 400;
    letter-spacing: normal;
}

/* BiomPIN option switch */
.biompin-option {
    background: rgba(102, 126, 234, 0.05);
    border-radius: var(--border-radius-md);
    padding: 1rem;
}

.form-check-input:checked {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
}

/* Process button states */
#processBtn {
    font-weight: 600;
    padding: 0.75rem;
    position: relative;
}

#processBtn:disabled {
    cursor: not-allowed;
}

#processBtn .processing-spinner {
    visibility: hidden;
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

#processBtn .processing-spinner .spinner-border {
    width: 1rem;
    height: 1rem;
    border-width: 0.15em;
}

#processBtn.processing .btn-text {
    visibility: hidden;
}

#processBtn.processing .processing-spinner {
    visibility: visible;
}

.onboarding-trigger-wrapper {
    display: flex;
    justify-content: center;
    padding-top: 1rem;
}

.onboarding-trigger {
    padding: 0.1rem 0.35rem;
    border: 0;
    background: transparent;
    color: #94a3b8;
    font-size: 0.68rem;
    font-weight: 500;
    line-height: 1.4;
    text-decoration: none;
}

.onboarding-trigger:hover {
    color: var(--color-primary-dark);
    text-decoration: underline;
    text-underline-offset: 0.18rem;
}

.onboarding-trigger:focus-visible {
    border-radius: 0.25rem;
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* Alert container */
#alertContainer .alert {
    border-radius: var(--border-radius-sm);
    border: none;
}

/* Card height adjustments */
.upload-card {
    height: auto;
}

.upload-card .card-body {
    height: auto;
    overflow: hidden;
}

/* Disable Bootstrap fade to prevent height jump during tab transitions */
#inputTabContent .tab-pane.fade {
    transition: none;
    opacity: 1 !important;
}

#inputTabContent .tab-pane.fade:not(.show) {
    display: none !important;
}

/* History search bar */
.history-search-wrapper {
    position: relative;
}

.history-search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-muted);
    font-size: 0.875rem;
    pointer-events: none;
    z-index: 1;
}

#historySearchInput {
    padding-left: 2.25rem;
    font-size: 0.875rem;
}

/* History Tab Styles */
.history-container {
    /* No max-height - let content expand naturally with Load More pattern */
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 3px;
}

.history-item {
    background: linear-gradient(145deg, #ffffff 0%, #f6f7ff 100%);
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: var(--border-radius-md);
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.07),
        0 4px 10px rgba(79, 70, 229, 0.08),
        inset 3px 0 0 rgba(102, 126, 234, 0.42),
        var(--control-highlight);
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: var(--control-transition);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    position: relative;
    transform: translateY(0);
}

.history-item:active {
    background: linear-gradient(145deg, #f8f9ff 0%, #eef0fb 100%);
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.07),
        inset 0 2px 4px rgba(79, 70, 229, 0.12),
        inset 3px 0 0 rgba(79, 70, 229, 0.56);
    transform: translateY(1px);
}

/* BiomPIN - prominent first line */
.history-item-pin {
    font-family: var(--biompin-font-family);
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-primary-dark);
    letter-spacing: 0;
}

/* Second line - patient info and time */
.history-item-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.history-item-patient-info {
    color: var(--color-text-muted);
}

.history-item-time {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.8rem;
    font-weight: 500;
}

/* Time color classes */
.time-safe {
    color: #10b981; /* Green - 48-72+ hours */
}

.time-warning {
    color: #f59e0b; /* Yellow - 24-48 hours */
}

.time-urgent {
    color: #f97316; /* Orange - <24 hours */
}

.time-expired,
.time-unknown {
    color: var(--color-text-muted);
}

/* Empty state */
.history-empty {
    text-align: center;
    padding: 2rem;
    color: var(--color-text-muted);
}

.history-empty i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.3;
}

/* History item delete button */
.history-item-delete {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: var(--control-surface);
    border: 1px solid rgba(15, 23, 42, 0.14);
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.7);
    padding: 0.2rem 0.35rem;
    color: var(--color-text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    border-radius: 50%;
    opacity: 0;
    transition: var(--control-transition), opacity 0.15s ease;
    line-height: 1;
    transform: translateY(0);
}

.history-item-delete:active {
    box-shadow: var(--control-shadow-pressed);
    transform: translateY(1px);
}

@media (hover: hover) and (pointer: fine) {
    .history-item:hover {
        background: linear-gradient(145deg, #ffffff 0%, #f1f3ff 100%);
        border-color: rgba(102, 126, 234, 0.38);
        box-shadow:
            0 2px 3px rgba(15, 23, 42, 0.07),
            0 4px 9px rgba(79, 70, 229, 0.12),
            inset 3px 0 0 rgba(79, 70, 229, 0.58),
            var(--control-highlight);
        transform: translateY(-1px);
        z-index: 1;
    }

    .history-item:hover .history-item-delete {
        opacity: 1;
    }

    .history-item-delete:hover {
        border-color: rgba(239, 68, 68, 0.3);
        background: linear-gradient(180deg, #ffffff 0%, #fff1f2 100%);
        box-shadow:
            0 2px 3px rgba(15, 23, 42, 0.07),
            0 4px 8px rgba(239, 68, 68, 0.12),
            var(--control-highlight);
        color: #ef4444;
        transform: translateY(-1px);
    }
}

@media (hover: none) {
    .history-item-delete {
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .segment,
    .segmented-slider,
    .split-file-picker,
    .browse-files-btn,
    .input-alternative-action,
    .history-item,
    .history-load-more,
    .history-item-delete {
        transition-duration: 0.01ms !important;
    }

    .segment:hover,
    .segment:active,
    .split-file-picker:hover,
    .split-file-picker:focus-within,
    .split-file-picker:has(.browse-files-btn:active),
    .input-alternative-action:hover,
    .input-alternative-action:active,
    .history-item:hover,
    .history-item:active,
    .history-load-more:hover,
    .history-load-more:active,
    .history-item-delete:hover,
    .history-item-delete:active {
        transform: none !important;
    }
}

/* Load more card - half height, subtle gray */
.history-load-more {
    background: var(--control-surface);
    border: 1px solid rgba(15, 23, 42, 0.14);
    border-radius: var(--border-radius-md);
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.06),
        0 3px 7px rgba(15, 23, 42, 0.07),
        var(--control-highlight);
    padding: 0.5rem 1rem; /* Half height of regular items */
    cursor: pointer;
    transition: var(--control-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    font-size: 0.875rem;
    position: relative;
    transform: translateY(0);
}

.history-load-more:active {
    box-shadow: var(--control-shadow-pressed);
    transform: translateY(1px);
}

@media (hover: hover) and (pointer: fine) {
    .history-load-more:hover {
        background: var(--control-surface-hover);
        border-color: #cbd5e1;
        box-shadow: var(--control-shadow-hover);
        transform: translateY(-1px);
        z-index: 1;
    }
}

/* Keep pressed depth authoritative when pointer hover remains active. */
.split-file-picker:has(.browse-files-btn:active),
.input-alternative-action:active,
.history-item-delete:active,
.history-load-more:active {
    box-shadow: var(--control-shadow-pressed);
    transform: translateY(1px);
}

.history-item:active {
    background: linear-gradient(145deg, #f8f9ff 0%, #eef0fb 100%);
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.07),
        inset 0 2px 4px rgba(79, 70, 229, 0.12),
        inset 3px 0 0 rgba(79, 70, 229, 0.56);
    transform: translateY(1px);
}

.history-load-more i {
    font-size: 0.75rem;
    opacity: 0.6;
}

/* Tab info hints */
.tab-info-hint {
    font-size: 0.75rem;
    color: #94a3b8;
}

/* Mobile adjustments for input tabs */
@media (max-width: 576px) {
    /* Primary task switcher */
    .segmented-control-wrapper {
        margin-bottom: 0.85rem;
    }

    .segmented-control {
        width: 100%;
    }

    .segment {
        height: 44px;
        gap: 0.35rem;
        font-size: 0.78rem;
    }

    .drag-drop-area {
        padding: 1rem;
    }

    .drag-drop-icon {
        font-size: 2rem !important;
    }

    .upload-file-mark {
        width: 48px;
        height: 48px;
        margin-bottom: 1rem;
    }

    .upload-file-mark .drag-drop-icon {
        margin: 0 !important;
        font-size: 1.5rem !important;
    }

    .browse-files-btn {
        font-size: 0.875rem !important;
        padding: 0.45rem 1rem !important;
    }

    .split-file-picker .browse-files-btn {
        padding-right: 0.55rem !important;
        padding-left: 0.55rem !important;
        font-size: 0.8rem !important;
    }

    .split-file-picker .browse-files-btn i {
        margin-right: 0.35rem !important;
    }

    .split-file-toggle {
        width: 40px;
    }

    /* File preview - more compact */
    .file-preview {
        padding: 0.75rem;
    }

    .file-preview i {
        font-size: 1.5rem !important;
    }

    .file-preview h6 {
        font-size: 0.85rem;
        margin-bottom: 0.25rem !important;
    }

    .file-preview small {
        font-size: 0.7rem;
    }

    /* File preview remove button - more compact */
    #uploadRemoveFile {
        padding: 0.25rem 0.5rem !important;
        font-size: 0.85rem;
        min-width: auto;
    }

    #uploadRemoveFile i {
        margin: 0 !important;
    }

    /* Process button - slightly smaller */
    #processBtn {
        padding: 0.65rem;
        font-size: 0.95rem;
    }

    /* History items - more compact */
    .history-item {
        padding: 0.65rem 0.85rem;
    }

    .history-item-pin {
        font-size: 0.95rem;
    }

    .history-item-info {
        font-size: 0.8rem;
    }

    .tab-info-hint { font-size: 0.7rem; }

    /* Empty states - reduced padding */
    .history-empty,
    .transcribe-empty {
        padding: 1.5rem 1rem;
    }

    .history-empty i,
    .transcribe-empty i {
        font-size: 2.5rem;
        margin-bottom: 0.75rem;
    }
}
