/* ==========================================================================
   Paieon Global & PDS Centralized Stylesheet
   ========================================================================== */

/* Variables & Design System Tokens */
:root {
    --bg-color: #0f172a;
    --surface-color: rgba(30, 41, 59, 0.7);
    --surface-border: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-primary: #3b82f6;
    --accent-hover: #2563eb;
    --success: #10b981;
    --danger: #ef4444;
}

/* Base resets & styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    background-image: radial-gradient(circle at top right, #1e3a8a, transparent 40%),
                      radial-gradient(circle at bottom left, #312e81, transparent 40%);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.5;
}

/* Header & Navigation */
header {
    padding: 1.5rem 2rem;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--surface-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(to right, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    color: transparent;
}

.user-nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.nav-link:hover {
    color: var(--text-primary);
}

main {
    flex: 1;
    padding: 3rem 2rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* Glass Cards */
.glass-card {
    background: var(--surface-color);
    backdrop-filter: blur(16px);
    border: 1px solid var(--surface-border);
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    font-size: 0.95rem;
}

.btn-primary {
    background-color: var(--accent-primary);
    color: white;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.6);
}

.btn-secondary {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid var(--surface-border);
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

/* Alerts / Notification Messages */
.messages {
    list-style: none;
    margin-bottom: 2rem;
}

.message {
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    background: var(--surface-color);
    border: 1px solid var(--surface-border);
    backdrop-filter: blur(12px);
    animation: slideIn 0.3s ease-out;
}

.message.success { border-left: 4px solid var(--success); }
.message.error { border-left: 4px solid var(--danger); }

/* Forms, Fields and Inputs */
.form-container, .upload-container {
    max-width: 600px;
    margin: 0 auto;
}

.form-header, .upload-header {
    margin-bottom: 2rem;
    text-align: center;
}

.form-title, .upload-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.form-subtitle, .upload-subtitle {
    color: var(--text-secondary);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--surface-border);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.form-input::placeholder {
    color: rgba(148, 163, 184, 0.5);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--surface-border);
}

.btn-submit {
    width: 100%;
}

.info-box {
    background: rgba(59, 130, 246, 0.1);
    border-left: 4px solid var(--accent-primary);
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 2rem;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.info-box strong {
    color: var(--accent-primary);
}

.help-text {
    display: block;
    font-size: 0.825rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    opacity: 0.8;
}

input[type="file"] {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--surface-border);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

input[type="file"]::-webkit-file-upload-button {
    background: var(--accent-primary);
    border: none;
    color: white;
    padding: 0.375rem 0.75rem;
    border-radius: 0.25rem;
    cursor: pointer;
    margin-right: 1rem;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.875rem;
    transition: background-color 0.2s;
}

input[type="file"]::-webkit-file-upload-button:hover {
    background: var(--accent-hover);
}

.errorlist {
    color: var(--danger);
    list-style: none;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.error-messages {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid var(--danger);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 2rem;
    color: #f87171;
    font-size: 0.95rem;
}

.error-messages ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.error-messages a,
.error-messages a:visited,
.error-messages a:hover,
.error-messages a:active {
    color: #f87171 !important;
    text-decoration: underline !important;
    font-weight: bold !important;
}

/* User Login Page Specific */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 200px);
}

.login-card {
    width: 100%;
    max-width: 400px;
    animation: fadeIn 0.5s ease-out;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.login-header p {
    color: var(--text-secondary);
}

.login-btn {
    width: 100%;
    margin-top: 1rem;
}

/* Dashboard elements */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.dashboard-title {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

/* Search and Filter Bar */
.controls-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    align-items: center;
}

.search-container {
    flex-grow: 1;
    min-width: 250px;
    position: relative;
}

.search-input {
    width: 100%;
    background: var(--surface-color);
    border: 1px solid var(--surface-border);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    backdrop-filter: blur(8px);
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
    background: rgba(30, 41, 59, 0.9);
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
    font-size: 0.9rem;
}

.filter-select {
    background: var(--surface-color);
    border: 1px solid var(--surface-border);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(8px);
    min-width: 160px;
}

.filter-select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* Tables and Lists */
.table-container {
    overflow-x: auto;
    border-radius: 1rem;
    background: var(--surface-color);
    backdrop-filter: blur(16px);
    border: 1px solid var(--surface-border);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.patient-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.95rem;
}

.patient-table th {
    padding: 1.25rem 1.5rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--surface-border);
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.patient-table th:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.02);
}

.sort-icon {
    display: inline-block;
    margin-left: 0.5rem;
    font-size: 0.8rem;
    opacity: 0.3;
    transition: opacity 0.2s ease;
}

.patient-table th:hover .sort-icon {
    opacity: 0.7;
}

.patient-table th.sort-asc .sort-icon,
.patient-table th.sort-desc .sort-icon {
    opacity: 1;
    color: var(--accent-primary);
}

.patient-table th.sort-asc .sort-icon::before { content: '▲'; }
.patient-table th.sort-desc .sort-icon::before { content: '▼'; }
.patient-table th:not(.sort-asc):not(.sort-desc) .sort-icon::before { content: '↕'; }

.patient-table td {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--surface-border);
    vertical-align: middle;
    color: var(--text-secondary);
}

.patient-table tr:last-child td {
    border-bottom: none;
}

.patient-table tr {
    transition: background-color 0.2s ease;
}

.patient-table tr:hover {
    background-color: rgba(255, 255, 255, 0.04);
}

.patient-name-cell {
    font-weight: 600;
    color: var(--text-primary);
}

.action-link {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.action-link:hover {
    color: var(--accent-hover);
    transform: translateX(4px);
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-text {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

/* Status Badges */
.status-badge {
    padding: 0.35rem 0.85rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.status-badge::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.status-active { 
    background: rgba(16, 185, 129, 0.1); 
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.2);
}
.status-active::before { background: #10b981; }

.status-inactive { 
    background: rgba(148, 163, 184, 0.1); 
    color: #94a3b8;
    border: 1px solid rgba(148, 163, 184, 0.2);
}
.status-inactive::before { background: #94a3b8; }

.status-badge.pending {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-badge.running {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.status-badge.succeeded {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge.failed {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.status-badge.not-extractable {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Patient & Wound Detail Layouts */
.patient-profile {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 3rem;
}

.profile-info {
    display: flex;
    gap: 2rem;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.profile-item strong {
    color: var(--text-primary);
    display: block;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.wounds-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
}

.wound-card {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.wound-header {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--surface-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.handler-list {
    list-style: none;
    margin-bottom: 1.5rem;
    flex-grow: 1;
}

.handler-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.handler-role {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
}

.assign-form {
    display: flex;
    gap: 0.5rem;
    margin-top: auto;
    border-top: 1px solid var(--surface-border);
    padding-top: 1rem;
}

.assign-select {
    flex-grow: 1;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--surface-border);
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: 0.5rem;
    font-family: inherit;
    font-size: 0.9rem;
}

.assign-select option {
    background-color: var(--bg-color);
}

.wound-detail-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 2rem;
}

.info-card {
    padding: 1.5rem;
}

.info-label {
    font-size: 0.875rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    display: block;
}

.info-value {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-primary);
    word-break: break-all;
}

.handlers-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.handlers-table th, .handlers-table td {
    text-align: left;
    padding: 1rem;
    border-bottom: 1px solid var(--surface-border);
}

.handlers-table th {
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-transform: uppercase;
}

/* Job Processing Details */
.job-container {
    max-width: 800px;
    margin: 0 auto;
}

.job-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 2rem;
    text-align: center;
    background: linear-gradient(to right, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    color: transparent;
}

.status-card {
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid var(--surface-border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.status-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.95rem;
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 150px;
}

.detail-value {
    color: var(--text-primary);
    word-break: break-all;
}

.upload-info {
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid var(--surface-border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.upload-info h3 {
    margin-bottom: 1rem;
    font-size: 1.2rem;
    color: var(--text-primary);
}

.upload-detail {
    margin: 0.5rem 0;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.upload-detail code {
    background: rgba(15, 23, 42, 0.6);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    border: 1px solid var(--surface-border);
    font-family: monospace;
}

.warning-box {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 0.75rem;
    padding: 1.25rem 1.5rem;
    margin-bottom: 2rem;
    color: #fde68a;
    font-size: 0.95rem;
}

.warning-box h4 {
    margin-bottom: 0.5rem;
    color: #fbbf24;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.warning-box ul {
    margin: 0.75rem 0 0 1.25rem;
}

.warning-box ul li {
    margin: 0.25rem 0;
}

.error-box {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 0.75rem;
    padding: 1.25rem 1.5rem;
    margin-bottom: 2rem;
    color: #fca5a5;
    font-size: 0.95rem;
}

.error-box h4 {
    margin-bottom: 0.5rem;
    color: #f87171;
}

.result-section {
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid var(--surface-border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.result-section h3 {
    margin-bottom: 1.25rem;
    font-size: 1.25rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--surface-border);
    padding-bottom: 0.5rem;
}

.result-fields {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--surface-border);
    border-radius: 0.5rem;
    padding: 1.25rem;
    font-size: 0.95rem;
}

.result-field {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.result-field:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.result-field-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.result-field-value {
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    word-break: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
}

.result-field-value.field-empty {
    opacity: 0.4;
}

.empty-field-placeholder {
    font-style: italic;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.meta-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.meta-item {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--surface-border);
    padding: 0.75rem;
    border-radius: 0.5rem;
}

.meta-label {
    font-weight: 600;
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    vertical-align: middle;
    margin-right: 0.5rem;
}

.action-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.action-buttons .btn {
    flex: 1;
}

.confidence-meter {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.confidence-bar {
    flex: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.confidence-fill {
    height: 100%;
    background: var(--success);
    width: 0%;
    transition: width 0.5s ease-out;
}

.confidence-value {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
    min-width: 2.5rem;
}

/* Therapy Plan History */
.plan-history-list {
    border: 1px solid var(--surface-border);
    border-radius: 0.5rem;
    overflow: hidden;
}

.plan-history-item {
    padding: 1rem;
    border-bottom: 1px solid var(--surface-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.plan-history-item:last-child {
    border-bottom: none;
}

.plan-history-date {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

.plan-history-detail {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.plan-history-status-wrap {
    margin-left: 0.5rem;
    flex-shrink: 0;
}

.plan-history-status {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.plan-history-empty {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Animations */
@keyframes slideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
