/* Hospital Demo - Main Stylesheet */

/* ========================================
   CSS Variables
   ======================================== */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #22c55e;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #3b82f6;

    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-color: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;

    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'SF Mono', Monaco, 'Cascadia Code', Consolas, monospace;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);

    --radius: 0.5rem;
    --radius-lg: 0.75rem;
}

/* ========================================
   Base Styles
   ======================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-color);
    background-color: var(--bg-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
    padding: 2rem 0;
}

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

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.25;
    margin-bottom: 0.5rem;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

p { margin-bottom: 1rem; }

a {
    color: var(--primary-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ========================================
   Navbar
   ======================================== */
.navbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.navbar-brand a {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-color);
}

.demo-badge {
    background: var(--primary-color);
    color: white;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius);
    font-weight: 500;
}

.navbar-menu {
    display: flex;
    gap: 1.5rem;
}

.nav-link {
    color: var(--text-color);
    font-weight: 500;
    padding: 0.5rem 0;
}

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

.navbar-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info {
    text-align: right;
}

.user-name {
    font-weight: 600;
    display: block;
}

.user-department {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.break-glass-indicator {
    background: var(--danger-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.75rem;
    font-weight: 700;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.logout-form {
    margin: 0;
}

/* ========================================
   Buttons
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}

.btn:hover {
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
}

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

.btn-secondary:hover {
    background: #475569;
}

.btn-warning {
    background: var(--warning-color);
    color: white;
}

.btn-warning:hover {
    background: #d97706;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

.btn-block {
    display: block;
    width: 100%;
}

/* ========================================
   Cards
   ======================================== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h2 {
    margin: 0;
    font-size: 1.125rem;
}

.card-body {
    padding: 1.5rem;
}

/* ========================================
   Tables
   ======================================== */
.table-container {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
}

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

.table th {
    background: #f1f5f9;
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

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

.table tr:hover {
    background: #f8fafc;
}

.sensitive-row {
    background: #fef2f2 !important;
}

.sensitive-row:hover {
    background: #fee2e2 !important;
}

/* ========================================
   Badges
   ======================================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

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

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

.badge-secondary {
    background: #e2e8f0;
    color: #475569;
}

/* ========================================
   Forms
   ======================================== */
.form-control {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text-color);
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-help {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.error-message {
    color: var(--danger-color);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.required {
    color: var(--danger-color);
}

/* ========================================
   Alerts
   ======================================== */
.alert {
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

/* ========================================
   Definition Lists
   ======================================== */
.definition-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.5rem 1rem;
}

.definition-list dt {
    font-weight: 600;
    color: var(--text-muted);
}

.definition-list dd {
    margin: 0;
}

/* ========================================
   Page-specific Styles
   ======================================== */

/* Hero Section */
.hero {
    padding: 4rem 0;
    text-align: center;
}

.hero-content h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.lead {
    font-size: 1.25rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.hero-actions {
    margin-bottom: 3rem;
}

/* Features Grid */
.demo-features {
    margin-top: 3rem;
    text-align: left;
}

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

.feature-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.feature-card h3 {
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

/* Architecture Diagram */
.architecture-note {
    margin-top: 3rem;
    text-align: center;
}

.arch-diagram {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.arch-component {
    background: var(--card-bg);
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
}

.arch-label {
    display: block;
    font-weight: 700;
    color: var(--primary-color);
}

.arch-sublabel {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.arch-arrow {
    font-size: 1.5rem;
    color: var(--text-muted);
}

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}

.login-card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 100%;
    text-align: center;
}

.login-options {
    margin: 2rem 0;
}

.login-help {
    text-align: left;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.demo-users-table {
    width: 100%;
    font-size: 0.875rem;
}

/* Filters */
.filters-card {
    background: var(--card-bg);
    padding: 1rem 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.filters-form {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.filter-group label {
    font-size: 0.875rem;
    font-weight: 500;
}

.filter-group select {
    min-width: 150px;
}

/* Results Summary */
.results-summary {
    padding: 0.75rem 0;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.authz-note {
    font-style: italic;
}

/* No Data */
.no-data {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.no-data .hint {
    margin-top: 1rem;
}

/* Patient Detail */
.page-header {
    margin-bottom: 2rem;
}

.breadcrumb {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.patient-badges {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.patient-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
}

.full-width {
    grid-column: 1 / -1;
}

.clinical-notes {
    background: #f8fafc;
    padding: 1rem;
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 0.875rem;
    white-space: pre-wrap;
    max-height: 300px;
    overflow-y: auto;
}

.restricted-badge {
    background: var(--warning-color);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius);
    font-size: 0.75rem;
    font-weight: 500;
}

/* Actions */
.actions-card {
    display: grid;
    gap: 1.5rem;
}

.action-section {
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.action-section.disabled {
    opacity: 0.6;
    background: #f8fafc;
}

.action-section h3 {
    margin-bottom: 1rem;
}

.action-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.action-form.inline {
    flex-direction: row;
    align-items: center;
}

.permission-denied {
    color: var(--text-muted);
    font-style: italic;
}

/* Authorization Info */
.authz-info-card {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-top: 2rem;
}

.authz-info-card h3 {
    color: var(--info-color);
    margin-bottom: 1rem;
}

.hint {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-style: italic;
}

.roles-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.roles-list li {
    background: var(--border-color);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-family: var(--font-mono);
}

/* Page Actions */
.page-actions {
    margin-top: 2rem;
    display: flex;
    gap: 1rem;
}

/* Access Denied */
.access-denied-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 3rem;
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
}

.access-denied-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.access-denied-details {
    text-align: left;
    margin: 2rem 0;
    padding: 1rem;
    background: #f8fafc;
    border-radius: var(--radius);
}

.break-glass-option {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

/* Break Glass */
.break-glass-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 600px;
    margin: 0 auto;
    overflow: hidden;
}

.break-glass-warning-header {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: white;
    padding: 2rem;
    text-align: center;
}

.warning-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.break-glass-warning-header h1 {
    color: white;
    margin: 0;
}

.break-glass-form-section {
    padding: 2rem;
}

.warning-message {
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.warning-message ul {
    margin: 0.5rem 0 0 1.5rem;
}

.acknowledgement label {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
    cursor: pointer;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.already-active-section {
    padding: 2rem;
}

.inline-form {
    display: inline;
}

/* Break Glass Warning */
.break-glass-warning {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

/* Error Pages */
.error-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 3rem;
    text-align: center;
    max-width: 500px;
    margin: 0 auto;
}

.error-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.error-details {
    text-align: left;
    margin: 2rem 0;
}

/* Footer */
.footer {
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    padding: 1.5rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.footer-note {
    margin-top: 0.5rem;
}

/* Responsive */
@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        gap: 1rem;
    }

    .navbar-menu {
        order: 3;
    }

    .patient-detail-grid {
        grid-template-columns: 1fr;
    }

    .filters-form {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group select {
        min-width: auto;
    }
}
