/* ==================== MStarLIS - Radiology Report Portal ==================== */

:root {
    --primary: #7c3aed;
    --primary-dark: #6d28d9;
    --primary-light: #ede9fe;
    --success: #059669;
    --success-light: #d1fae5;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --info: #0891b2;
    --info-light: #cffafe;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --white: #ffffff;
    --radius: 12px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1),0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07),0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1),0 4px 6px rgba(0,0,0,0.05);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f1f5f9;
    color: var(--gray-800);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ==================== BUTTONS ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 10px;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
    width: 100%;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
    border-radius: 8px;
}

.btn-success {
    background: var(--success);
    color: white;
    width: 100%;
}
.btn-success:hover { background: #047857; }

.btn-outline {
    background: var(--white);
    border: 2px solid var(--gray-200);
    color: var(--gray-700);
}
.btn-outline:hover { border-color: var(--gray-300); background: var(--gray-50); }
.btn-outline.active {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
}

.btn-danger {
    background: var(--white);
    border: 2px solid var(--danger-light);
    color: var(--danger);
}
.btn-danger:hover { background: var(--danger-light); }

/* ==================== LOGIN PAGE ==================== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 50%, #ddd6fe 100%);
}

.login-card {
    background: var(--white);
    border-radius: 16px;
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo .icon {
    width: 56px;
    height: 56px;
    background: var(--primary);
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: white;
    margin-bottom: 0.75rem;
}

.login-logo h1 { font-size: 1.5rem; font-weight: 700; color: var(--gray-900); }
.login-logo p { font-size: 0.875rem; color: var(--gray-500); margin-top: 0.25rem; }

/* ==================== FORM ELEMENTS ==================== */
.form-group { margin-bottom: 1.25rem; }

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--gray-200);
    border-radius: 10px;
    font-size: 1rem;
    color: var(--gray-800);
    transition: all 0.2s;
    background: var(--gray-50);
    font-family: inherit;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(124,58,237,0.1);
}

/* ==================== ERROR MESSAGE ==================== */
.error-message {
    background: var(--danger-light);
    color: var(--danger);
    padding: 0.75rem 1rem;
    border-radius: 10px;
    font-size: 0.875rem;
    margin-bottom: 1rem;
    display: none;
}
.error-message.show { display: block; }

/* ==================== SPINNER ==================== */
.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.spinner-dark {
    border: 2px solid var(--gray-200);
    border-top-color: var(--primary);
}

/* ==================== HEADER ==================== */
.header {
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.header-left { display: flex; align-items: center; gap: 0.75rem; }

.header-logo {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: white;
}

.header-title { font-size: 1.125rem; font-weight: 700; color: var(--gray-900); }

.header-right { display: flex; align-items: center; gap: 1rem; }

.user-info { text-align: right; }
.user-name { font-weight: 600; font-size: 0.875rem; color: var(--gray-800); }
.user-role { font-size: 0.75rem; color: var(--gray-500); }

/* ==================== MAIN CONTENT ==================== */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* ==================== TABLE ==================== */
.table-container {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--gray-100);
}

.table-header h2 { font-size: 1.0625rem; font-weight: 700; color: var(--gray-900); }
.table-header .count { font-size: 0.8125rem; color: var(--gray-500); font-weight: 500; }

.table-responsive { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

table thead th {
    background: var(--gray-50);
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--gray-200);
    white-space: nowrap;
}

table tbody td {
    padding: 0.875rem 1rem;
    font-size: 0.875rem;
    color: var(--gray-700);
    border-bottom: 1px solid var(--gray-100);
}

table tbody tr { cursor: pointer; transition: background 0.15s; }
table tbody tr:hover { background: var(--gray-50); }
table tbody tr:last-child td { border-bottom: none; }

/* ==================== BADGES ==================== */
.badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-completed { background: var(--success-light); color: var(--success); }
.badge-pending { background: var(--warning-light); color: var(--warning); }
.badge-process { background: var(--info-light); color: var(--info); }
.badge-cancelled { background: var(--danger-light); color: var(--danger); }
.badge-draft { background: var(--primary-light); color: var(--primary); }

/* ==================== EMPTY STATE ==================== */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--gray-400);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 0.5rem; }
.empty-state p { font-size: 0.9375rem; }

/* ==================== CARDS ==================== */
.card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
    border: 1px solid var(--gray-100);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--gray-100);
}

.card-title { font-weight: 700; font-size: 1rem; color: var(--gray-900); }

/* ==================== REPORT EDITOR ==================== */
.editor-container {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
}

.editor-header h3 { font-size: 1rem; font-weight: 700; color: var(--gray-900); }

.editor-body { padding: 0; }

.editor-footer {
    display: flex;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
}

/* Quill Editor overrides */
.ql-container {
    min-height: 200px;
    font-size: 0.9375rem;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.ql-editor {
    min-height: 200px;
    max-height: 500px;
    overflow-y: auto;
}

.ql-toolbar {
    border: none !important;
    border-bottom: 1px solid var(--gray-200) !important;
    background: var(--white);
}

.ql-container {
    border: none !important;
}

/* Patient info bar */
.patient-info-bar {
    background: var(--primary-light);
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
}

.info-item .label {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
    font-weight: 600;
}

.info-item .value {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-top: 0.125rem;
}

/* Component navigation */
.component-nav {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.component-nav-item {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    border: 2px solid var(--gray-200);
    background: var(--white);
    color: var(--gray-600);
    transition: all 0.2s;
}

.component-nav-item:hover { border-color: var(--primary); color: var(--primary); }
.component-nav-item.active {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
}
.component-nav-item.saved {
    border-color: var(--success);
    background: var(--success-light);
    color: var(--success);
}

/* ==================== LOADING OVERLAY ==================== */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(255,255,255,0.8);
    z-index: 300;
    align-items: center;
    justify-content: center;
}
.loading-overlay.show { display: flex; }

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

/* ==================== TOAST ==================== */
.toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 600;
    color: white;
    z-index: 400;
    animation: slideInRight 0.3s ease;
    box-shadow: var(--shadow-lg);
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }

/* ==================== SEARCH BAR ==================== */
.search-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.search-bar input {
    flex: 1;
    padding: 0.625rem 1rem;
    border: 2px solid var(--gray-200);
    border-radius: 10px;
    font-size: 0.875rem;
    font-family: inherit;
}
.search-bar input:focus {
    outline: none;
    border-color: var(--primary);
}

/* ==================== ANIMATIONS ==================== */
@keyframes spin { to { transform: rotate(360deg); } }

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(50px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
    .login-card { padding: 1.5rem; }
    .main-content { padding: 1rem; }
    .header { padding: 0 1rem; }
    .header-title { font-size: 1rem; }
    .component-nav { flex-wrap: nowrap; overflow-x: auto; }
    .editor-footer { flex-direction: column; }
    table thead th, table tbody td { padding: 0.625rem 0.75rem; font-size: 0.8125rem; }
}

@media (max-width: 480px) {
    .patient-info-bar { grid-template-columns: 1fr 1fr; }
    .search-bar { flex-direction: column; }
}

@media print {
    .header, .ql-toolbar, .editor-footer, .component-nav, .btn { display: none !important; }
    .editor-container { box-shadow: none; border: none; }
    .ql-editor { max-height: none; overflow: visible; }
}