@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* Footer Layout */
.footer-content {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    justify-content: space-between !important;
    align-items: center !important;
    width: 100%;
    padding: 0 2rem;
}

:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --success-color: #48bb78;
    --warning-color: #ed8936;
    --error-color: #f56565;
    --text-primary: #2d3748;
    --text-secondary: #718096;
    --border-color: #e2e8f0;
    --background: #f7fafc;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

.loading-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
}

.loading-container p {
    color: white;
    margin-top: 20px;
    font-size: 18px;
    font-weight: 500;
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

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

    100% {
        transform: rotate(360deg);
    }
}

#blazor-error-ui {
    background: var(--error-color);
    color: white;
    padding: 1rem;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: none;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
}

.main-layout {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 1.5rem 2rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
    flex: 1;
}

.card {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    margin-bottom: 2rem;
}

.card-header {
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
}

.card-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-body {
    color: var(--text-secondary);
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.info-item {
    display: flex;
    flex-direction: column;
}

.info-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.info-value {
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 500;
}

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

.table thead {
    background: var(--background);
}

.table th {
    text-align: left;
    padding: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.875rem;
    letter-spacing: 0.05em;
}

.table td {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-primary);
}

.table tr:hover {
    background: var(--background);
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
}

.badge-success {
    background: #c6f6d5;
    color: #22543d;
}

.badge-warning {
    background: #feebc8;
    color: #744210;
}

.badge-error {
    background: #fed7d7;
    color: #742a2a;
}

.badge-info {
    background: #bee3f8;
    color: #2c5282;
}

.btn {
    display: inline-flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: var(--background);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.alert {
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.alert-error {
    background: #fed7d7;
    color: #742a2a;
    border-left: 4px solid var(--error-color);
}

.alert-success {
    background: #c6f6d5;
    color: #22543d;
    border-left: 4px solid var(--success-color);
}

.alert-info {
    background: #bee3f8;
    color: #2c5282;
    border-left: 4px solid #4299e1;
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

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

@media (max-width: 768px) {
    .container {
        padding: 0 0.75rem;
        margin: 1rem auto;
    }

    .header {
        padding: 1rem;
    }

    .header h1 {
        font-size: 1.1rem;
        line-height: 1.4;
    }

    .header small {
        font-size: 0.75rem;
    }

    .card {
        padding: 1rem;
        border-radius: 8px;
        margin-bottom: 1rem;
    }

    .card-header {
        padding-bottom: 0.75rem;
        margin-bottom: 1rem;
    }

    .card-header h2 {
        font-size: 1.1rem;
    }

    .info-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }

    .info-label {
        font-size: 0.75rem;
    }

    .info-value {
        font-size: 0.9rem;
    }

    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }

    .d-flex.gap-2 {
        gap: 0.5rem !important;
    }

    .d-flex.flex-wrap {
        flex-wrap: wrap !important;
    }

    .table {
        font-size: 0.75rem;
    }

    .table th,
    .table td {
        padding: 0.5rem;
    }

    /* AI Image result styles */
    .fundus-content {
        flex-direction: column;
    }

    .fundus-image {
        width: 100%;
        height: auto;
        max-width: 200px;
        margin: 0 auto;
    }

    /* AI Report styles */
    .ai-report-container {
        padding: 1rem;
        font-size: 0.9rem;
    }

    .ai-report-container h2 {
        font-size: 1rem;
    }

    .hospital-nav-buttons {
        flex-direction: column !important;
        gap: 0.5rem !important;
        align-items: flex-start !important;
    }

    .unlink-full {
        display: none !important;
    }

    .unlink-mobile {
        display: inline !important;
    }
}

/* Hospital Navigation Buttons */
.hospital-nav-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-row-1 {
    display: flex;
    justify-content: flex-start;
}

.nav-row-2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.hospital-name {
    font-size: 1.1rem;
    font-weight: bold;
    color: #2c5282;
}

.btn-unlink {
    background: white;
    border: 1px solid #e53e3e;
    color: #e53e3e;
}

.btn-unlink:hover {
    background: #fed7d7;
}

.unlink-full {
    display: inline;
}

.unlink-mobile {
    display: none;
    color: #e53e3e;
    font-weight: bold;
    font-size: 1rem;
}

/* AI Medical Report Styles */
.ai-report-container {
    background: linear-gradient(135deg, #f8faff 0%, #f0f4ff 100%);
    border-radius: 12px;
    padding: 2rem;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.1);
}

.ai-report-container h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ai-report-container h2:first-child {
    margin-top: 0;
}

.ai-report-container h2::before {
    content: '';
    width: 4px;
    height: 1.25rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border-radius: 2px;
}

.ai-report-container ul {
    list-style: none;
    padding: 0;
    margin: 0.75rem 0;
}

.ai-report-container ul li {
    padding: 0.5rem 0;
    padding-left: 1.5rem;
    position: relative;
    color: var(--text-primary);
}

.ai-report-container ul li::before {
    content: '•';
    position: absolute;
    left: 0.25rem;
    color: var(--primary-color);
    font-weight: bold;
}

.ai-report-container strong {
    color: var(--text-primary);
    font-weight: 600;
}

.ai-report-container table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.ai-report-container th {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    font-weight: 600;
    text-align: left;
    padding: 0.875rem 1rem;
    font-size: 0.9rem;
}

.ai-report-container td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.ai-report-container tr:last-child td {
    border-bottom: none;
}

.ai-report-container tr:hover td {
    background: #f8faff;
}

.ai-report-container p {
    margin: 0.75rem 0;
    line-height: 1.8;
    color: var(--text-primary);
}

/* Section-specific styles */
.ai-report-container h2:nth-of-type(1)::before {
    background: #48bb78;
}

/* 基本資料 - green */
.ai-report-container h2:nth-of-type(2)::before {
    background: #4299e1;
}

/* 體格檢查 - blue */
.ai-report-container h2:nth-of-type(3)::before {
    background: #ed8936;
}

/* 診斷 - orange */
.ai-report-container h2:nth-of-type(4)::before {
    background: #9f7aea;
}

/* 用藥 - purple */
.ai-report-container h2:nth-of-type(5)::before {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
}

/* AI總結 */

/* Print-friendly styles */
@media print {
    .ai-report-container {
        background: white;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* ===== AI Image Analysis Result Styles ===== */
.fundus-result-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    margin-bottom: 1rem;
    overflow: hidden;
    transition: all 0.2s ease;
}

.fundus-result-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.fundus-result-card.referral-urgent {
    border-left: 4px solid #e53e3e;
    background: linear-gradient(90deg, rgba(229, 62, 62, 0.05) 0%, white 100%);
}

.fundus-result-card.referral-needed {
    border-left: 4px solid #ed8936;
    background: linear-gradient(90deg, rgba(237, 137, 54, 0.05) 0%, white 100%);
}

.fundus-result-card.referral-followup {
    border-left: 4px solid #4299e1;
    background: linear-gradient(90deg, rgba(66, 153, 225, 0.05) 0%, white 100%);
}

.fundus-result-card.referral-normal {
    border-left: 4px solid #48bb78;
    background: linear-gradient(90deg, rgba(72, 187, 120, 0.05) 0%, white 100%);
}

.fundus-content {
    display: flex;
    gap: 1.5rem;
    padding: 1.25rem;
}

.fundus-image-container {
    flex-shrink: 0;
    position: relative;
}

.fundus-image {
    width: 180px;
    height: 180px;
    object-fit: cover;
    border-radius: 8px;
    background: #1a1a2e;
    border: 2px solid #2d3748;
}

.fundus-image-placeholder {
    width: 180px;
    height: 180px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #2d3748;
    border-radius: 8px;
    color: #a0aec0;
}

.fundus-image-placeholder span {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.fundus-eye-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    text-align: center;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}

.fundus-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

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

.referral-badge {
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.95rem;
}

.badge-urgent {
    background: #fed7d7;
    color: #c53030;
}

.badge-refer {
    background: #feebc8;
    color: #c05621;
}

.badge-followup {
    background: #bee3f8;
    color: #2b6cb0;
}

.badge-normal {
    background: #c6f6d5;
    color: #276749;
}

.fundus-date {
    color: #718096;
    font-size: 0.9rem;
}

.fundus-details {
    flex: 1;
}

.conclusion-text {
    font-size: 1rem;
    color: #4a5568;
    margin-bottom: 0.75rem;
    line-height: 1.6;
}

.performer-info {
    font-size: 0.9rem;
    color: #718096;
    margin: 0;
}

/* Responsive */
@media (max-width: 768px) {
    .fundus-content {
        flex-direction: column;
    }

    .fundus-image-container {
        align-self: center;
    }

    .fundus-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}