/* ============================================
   LongevityCreation Profile Page
   Design System Aligned - v4.0
   ============================================ */

@import url('./design-tokens.css');

/* Legacy variable mappings for compatibility */
/* Note: Uses fallback values for robustness */
:root {
    --profile-bg: var(--color-bg-alt, #F3F4F6);
    --card-bg: var(--color-bg-white, #FFFFFF);
    --text-main: var(--color-text, #111827);
    --text-sub: var(--color-text-muted, #6B7280);
    --accent: var(--color-primary, #2563EB);
    --danger: var(--color-danger, #EF4444);
    --warning: var(--color-warning, #F59E0B);
    --success: var(--color-success, #10B981);
}

/* Override body background for profile page */
body {
    background: var(--color-bg, #FAFAFA);
    font-family: var(--font-sans, 'DM Sans', sans-serif);
}

.profile-main {
    padding: 40px 32px;
    overflow-y: auto;
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

.profile-grid {
    width: 100%;
    max-width: 1200px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: minmax(320px, 1fr);
    gap: 24px;
}

.glass-grid {
    align-items: stretch;
}

.profile-card {
    border-radius: 20px;
    padding: 22px;
    display: flex;
    flex-direction: column;
    min-height: 320px;
    position: relative;
    overflow: hidden;
}

/* Specific overrides for layout */
.metrics-card {
    grid-column: 1 / -1;
    /* Span full width */
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.glass-card {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(229, 231, 235, 0.9);
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.highlight-card {
    justify-content: flex-start;
    gap: 16px;
}

/* Dashboard Card - Smart Data Extraction Layout */
.dashboard-card {
    min-height: auto;
    padding: 28px;
}

.dashboard-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    align-items: start;
}

.dashboard-left {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Mini Dropzone */
.mini-dropzone {
    border: 2px dashed #d1d5db;
    border-radius: 12px;
    padding: 24px 20px;
    text-align: center;
    background: #f9fafb;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mini-dropzone:hover,
.mini-dropzone.dragover {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}

.mini-dropzone-icon {
    color: var(--color-text-light);
    margin-bottom: 8px;
}

.mini-dropzone:hover .mini-dropzone-icon {
    color: var(--color-primary);
}

.mini-dropzone-text {
    font-size: 13px;
    color: #6b7280;
    margin: 0;
}

/* Transformation Flow Illustration */
.transform-flow {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 20px 16px;
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
    border-radius: 12px;
    margin-top: 12px;
}

.transform-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.transform-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.transform-icon.doc-icon {
    background: #fef3c7;
    color: #d97706;
}

.transform-icon.chart-icon {
    background: #d1fae5;
    color: #059669;
}

.transform-arrow {
    color: #9ca3af;
    animation: pulse-arrow 2s ease-in-out infinite;
}

@keyframes pulse-arrow {

    0%,
    100% {
        opacity: 0.5;
        transform: translateX(0);
    }

    50% {
        opacity: 1;
        transform: translateX(3px);
    }
}

.transform-label {
    font-size: 11px;
    font-weight: 500;
    color: #6b7280;
    text-align: center;
}

/* Dashboard Right - Description */
.dashboard-right {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 16px 0;
}

.dashboard-right h2 {
    font-size: 24px;
    font-weight: 600;
    color: #111827;
    margin: 0 0 12px 0;
    line-height: 1.3;
}

.dashboard-right p {
    font-size: 14px;
    line-height: 1.7;
    color: #6b7280;
    margin: 0;
}

/* Responsive */
@media (max-width: 900px) {
    .dashboard-layout {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .dashboard-right {
        order: -1;
        padding: 0;
    }
}

.profile-header {
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: flex-start;
}

.header-left {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.header-left h1,
.profile-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
}

.profile-header p {
    color: var(--text-sub);
    font-size: 14px;
    margin: 0;
}

.btn-upload {
    background: var(--text-main);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: opacity 0.2s;
}

.btn-upload:hover {
    opacity: 0.9;
}

.card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 0;
    /* Spacing handled by metrics-card gap */
}

.card-title-block h1,
.card-title-block h2 {
    margin: 4px 0 6px 0;
}

.card-title-block h1 {
    font-size: 22px;
    color: var(--text-main);
}

.card-title-block h2 {
    font-size: 18px;
    color: var(--text-main);
}

.card-title-block p {
    margin: 0;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 11px;
    color: var(--text-sub);
    margin: 0;
}

.card-content {
    margin-top: 12px;
    color: var(--text-sub);
    font-size: 13px;
}

.muted-note {
    background: rgba(248, 250, 252, 0.9);
    border: 1px dashed rgba(229, 231, 235, 0.9);
    padding: 14px;
    border-radius: 12px;
}

.records-card {
    display: flex;
    flex-direction: column;
}

.records-card .card-header h2 {
    margin: 0;
    font-size: 18px;
    color: var(--text-main);
}

.card-subtitle {
    margin-top: 4px;
    color: var(--text-sub);
    font-size: 13px;
}

.records-list {
    list-style: none;
    margin-top: 16px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    overflow-y: auto;
}

.record-item {
    padding: 16px;
    border: none;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #f8fafc;
    transition: all 0.2s ease;
}

.record-item:hover {
    background: #f1f5f9;
    transform: translateX(2px);
}

.record-info {
    flex: 1;
    min-width: 0;
}

.record-status {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    flex-shrink: 0;
}

.record-note {
    margin-top: 8px;
    font-size: 12px;
    padding: 8px 12px;
    border-radius: 8px;
    border: none;
    background: #e0f2fe;
    color: #0369a1;
}

.record-note-error {
    color: #b91c1c;
    background: #fee2e2;
}

.record-note-muted {
    background: #f1f5f9;
    color: #64748b;
}

.record-retry-btn {
    background: #111827;
    color: #fff;
    border: none;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.record-retry-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

.record-retry-btn:not(:disabled):hover {
    background: #1f2937;
    transform: translateY(-1px);
}

.record-delete-btn {
    background: transparent;
    border: 1px solid #e5e7eb;
    color: #9ca3af;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.record-delete-btn:hover {
    background: #fee2e2;
    border-color: #fecaca;
    color: #dc2626;
}

.record-delete-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.records-list li {
    list-style: none;
}

.record-title {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.record-meta {
    font-size: 12px;
    color: #94a3b8;
}

.records-empty {
    padding: 24px 16px;
    color: #94a3b8;
    background: #f8fafc;
    border: 2px dashed #e2e8f0;
    border-radius: 12px;
    text-align: center;
    font-size: 13px;
}

/* Status Badge Improvements */
.status-badge {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: capitalize;
}

.status-badge.normal {
    background: #d1fae5;
    color: #065f46;
}

.status-badge.low {
    background: #fef3c7;
    color: #92400e;
}

.status-badge.high {
    background: #fee2e2;
    color: #991b1b;
}

/* NEW LAYOUT FOR METRICS */
.metrics-layout {
    display: flex;
    gap: 20px;
    flex: 1;
    min-height: 280px;
    /* Ensure enough height */
}

.metrics-chart-column {
    flex: 1;
    min-width: 0;
    /* Allow flex item to shrink below content size if needed */
    display: flex;
    flex-direction: column;
}

.metrics-sidebar-column {
    width: 220px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    border-left: 1px solid rgba(229, 231, 235, 0.5);
    padding-left: 20px;
}

.metrics-chip-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    flex: 1;
    padding: 2px;
    scrollbar-width: thin;
    scrollbar-color: rgba(156, 163, 175, 0.5) transparent;
    max-height: 320px;
    /* Prevent infinite growth */
}

/* Custom Scrollbar for Chip List */
.metrics-chip-list::-webkit-scrollbar {
    width: 4px;
    /* Vertical scrollbar width */
}

.metrics-chip-list::-webkit-scrollbar-track {
    background: transparent;
}

.metrics-chip-list::-webkit-scrollbar-thumb {
    background-color: rgba(156, 163, 175, 0.5);
    border-radius: 3px;
}

.metrics-chip-list::-webkit-scrollbar-thumb:hover {
    background-color: rgba(107, 114, 128, 0.8);
}

.metric-chip {
    padding: 10px 14px;
    border: none;
    border-radius: 10px;
    background: #f1f5f9;
    /* Lighter background for list items */
    color: var(--text-main);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: left;
    width: 100%;
    box-sizing: border-box;
    font-weight: 500;
}

.metric-chip:hover {
    background: #e2e8f0;
    transform: translateX(2px);
    /* Subtle move right on hover */
}

.metric-chip.active {
    background: #0f172a;
    /* Dark active state */
    color: #fff;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
}

.metrics-chart-wrapper {
    position: relative;
    width: 100%;
    flex: 1;
    min-height: 280px;
    /* Taller chart area */
    padding: 16px;
    background: linear-gradient(135deg, #f8fbff 0%, #eef2ff 100%);
    border: 1px solid rgba(229, 231, 235, 0.9);
    border-radius: 18px;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
    z-index: 1;
}

.metrics-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-sub);
    font-weight: 600;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 14px;
}

.placeholder-card {
    align-items: center;
    justify-content: center;
    border: 1px dashed rgba(229, 231, 235, 0.8);
    background: rgba(255, 255, 255, 0.6);
    color: var(--text-sub);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.placeholder-label {
    color: var(--text-sub);
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Body Visual Card */
.body-visual-card {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 20px;
    position: relative;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.body-visual-container {
    height: 100%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.body-image {
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
    opacity: 0.9;
}

.body-overlay {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.9);
    padding: 16px;
    border-radius: 12px;
    backdrop-filter: blur(4px);
}

.body-overlay h3 {
    font-size: 16px;
    margin-bottom: 12px;
    color: var(--text-main);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 14px;
}

.stat-row span {
    color: var(--text-sub);
}

/* Metrics Column */
.metrics-column {
    display: flex;
    flex-direction: column;
    gap: 24px;
    overflow-y: auto;
}

.metric-card {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.card-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge.normal {
    background: #d1fae5;
    color: #065f46;
}

.status-badge.low {
    background: #fef3c7;
    color: #92400e;
}

.status-badge.high {
    background: #fee2e2;
    color: #991b1b;
}

.metrics-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.metric-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.metric-info {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
}

.metric-info .label {
    font-weight: 500;
    color: var(--text-sub);
}

.metric-info .value {
    font-weight: 700;
    color: var(--text-main);
}

.progress-bar {
    height: 8px;
    background: #f3f4f6;
    border-radius: 4px;
    overflow: hidden;
}

.progress {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* Results Table */
.results-table {
    width: 100%;
    border-collapse: collapse;
}

.results-table th {
    text-align: left;
    padding: 12px;
    color: var(--text-sub);
    font-size: 12px;
    font-weight: 500;
    border-bottom: 1px solid #f3f4f6;
}

.results-table td {
    padding: 16px 12px;
    font-size: 14px;
    color: var(--text-main);
    border-bottom: 1px solid #f3f4f6;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

.status-dot.normal {
    background: var(--success);
}

.status-dot.low {
    background: var(--warning);
}

.status-dot.high {
    background: var(--danger);
}

/* Sidebar nav styles now inherited from app-common.css */

/* Upload Modal Styles - Modern Clean Design */
.upload-modal-content {
    max-width: 520px;
    padding: 32px;
    border-radius: 20px;
    background: #fff;
}

.upload-header {
    text-align: center;
    margin-bottom: 28px;
}

.upload-header h2 {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-main);
    margin: 0 0 8px 0;
}

.upload-header p {
    font-size: 14px;
    color: var(--text-sub);
    margin: 0;
}

/* Dropzone */
.upload-dropzone {
    border: 2px dashed #e5e7eb;
    border-radius: 16px;
    padding: 40px 24px;
    text-align: center;
    background: #fafafa;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 20px;
}

.upload-dropzone:hover,
.upload-dropzone.dragover {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}

.dropzone-icon {
    color: var(--color-text-light);
    margin-bottom: 16px;
}

.upload-dropzone:hover .dropzone-icon {
    color: var(--color-primary);
}

.dropzone-text {
    font-size: 15px;
    font-weight: 500;
    color: #6b7280;
    margin: 0 0 4px 0;
}

.dropzone-subtext {
    font-size: 13px;
    color: #9ca3af;
    margin: 0 0 12px 0;
}

.dropzone-link {
    color: var(--color-primary);
    cursor: pointer;
    text-decoration: underline;
}

.dropzone-formats {
    font-size: 11px;
    color: #9ca3af;
    margin: 0;
}

/* Upload Methods */
.upload-methods {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.upload-method-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.upload-method-btn:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.method-icon {
    font-size: 24px;
}

.method-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.method-text strong {
    font-size: 14px;
    color: var(--text-main);
}

.method-text small {
    font-size: 12px;
    color: var(--text-sub);
}

/* QR Code View */
.qr-code-view {
    text-align: center;
}

.qr-container {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}

.qr-instructions p {
    margin: 0 0 8px 0;
    font-size: 14px;
    color: var(--text-main);
}

.qr-subtext {
    color: var(--text-sub) !important;
    font-size: 13px !important;
}

.qr-link-box {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #f3f4f6;
    padding: 10px 16px;
    border-radius: 8px;
    margin-top: 16px;
}

.qr-link-label {
    font-size: 12px;
    color: var(--text-sub);
}

.qr-link-box code {
    font-size: 12px;
    color: var(--text-main);
    font-weight: 500;
}

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--text-sub);
    font-size: 14px;
    cursor: pointer;
    margin-top: 24px;
    padding: 8px 16px;
    border-radius: 8px;
    transition: all 0.2s;
}

.btn-back:hover {
    background: #f3f4f6;
    color: var(--text-main);
}

/* Upload Progress */
.upload-progress-view {
    text-align: center;
}

.progress-animation {
    margin: 32px 0;
}

.progress-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.progress-bar-container {
    width: 100%;
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 16px;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary) 0%, var(--color-primary-hover) 100%);
    width: 0%;
    transition: width 0.3s;
    border-radius: 3px;
}

.progress-status {
    font-size: 14px;
    color: var(--text-sub);
    margin: 0;
}

/* Extracted Data View */
.extracted-data-view {
    text-align: center;
}

.extracted-data-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 24px;
    text-align: left;
}

.extracted-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: #fafafa;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
}

.extracted-item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.extracted-item-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-main);
}

.extracted-item-value {
    font-size: 13px;
    color: var(--text-sub);
}

.extracted-item-status {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.extracted-item-status.optimal {
    background: #d1fae5;
    color: #065f46;
}

.extracted-item-status.review {
    background: #fef3c7;
    color: #92400e;
}

.extracted-item-status.high {
    background: #fee2e2;
    color: #991b1b;
}

.extracted-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn-primary-lg {
    background: #111827;
    color: #fff;
    border: none;
    padding: 14px 24px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary-lg:hover {
    background: #1f2937;
}

.btn-text {
    background: none;
    border: none;
    color: var(--text-sub);
    font-size: 14px;
    cursor: pointer;
    padding: 8px;
}

.btn-text:hover {
    color: var(--text-main);
}

.btn-primary {
    background: #111827;
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: #1f2937;
}

.btn-secondary {
    background: white;
    border: 1px solid #e5e7eb;
    color: var(--text-main);
    padding: 10px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

/* Responsive */
@media (max-width: 1024px) {
    .profile-grid {
        grid-template-columns: 1fr;
    }

    .upload-options {
        grid-template-columns: 1fr;
    }
}

/* Specialized Button Overrides - Use profile theme color (green) */
#sidebarUploadBtn {
    background: var(--color-profile, #10B981) !important;
    color: #ffffff !important;
    border-color: var(--color-profile, #10B981) !important;
}

#sidebarUploadBtn:hover {
    background: #059669 !important;
    border-color: #059669 !important;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
    transform: translateY(-1px);
}

/* View All Metrics Button */
.btn-view-all {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    color: #475569;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.btn-view-all:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.btn-view-all svg {
    transition: transform 0.2s ease;
}

.btn-view-all:hover svg {
    transform: translateX(3px);
}