/* ============================================
   SAMi EQA - External Quality Assessment
   Procreative Diagnostics Ltd
   ============================================ */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700&family=Space+Grotesk:wght@400;500;600;700&display=swap');

/* CSS Variables */
:root {
    /* Brand Colors - derived from SAMi banner */
    --primary: #1a5f5f;
    --primary-light: #2a7f7f;
    --primary-dark: #0d4545;
    --accent: #c83c5a;
    --accent-light: #e85070;
    
    /* Neutrals */
    --dark: #1a1a2e;
    --dark-secondary: #2d2d44;
    --grey-900: #2c3e50;
    --grey-700: #4a5568;
    --grey-500: #718096;
    --grey-300: #cbd5e0;
    --grey-200: #e2e8f0;
    --grey-100: #f7fafc;
    --white: #ffffff;
    
    /* Semantic */
    --success: #38a169;
    --warning: #d69e2e;
    --error: #e53e3e;
    --info: #3182ce;
    
    /* Typography */
    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;
    
    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
    --shadow-xl: 0 20px 25px rgba(0,0,0,0.15), 0 10px 10px rgba(0,0,0,0.04);
    
    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 20px;
    --radius-full: 9999px;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    color: var(--grey-700);
    background: var(--grey-100);
    min-height: 100vh;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--dark);
    line-height: 1.3;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.125rem; }
h6 { font-size: 1rem; }

p { margin-bottom: var(--space-md); }

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

a:hover {
    color: var(--primary-light);
}

/* Layout Components */
.container {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

.container-fluid {
    width: 100%;
    padding: 0 var(--space-lg);
}

/* Header with Banner */
.site-header {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    position: relative;
    overflow: hidden;
    height: 80px;
}

.site-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('../assets/images/banner.png') center center no-repeat;
    background-size: contain;
}

.header-banner-link {
    display: block;
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 1;
}

/* Navigation */
.main-nav {
    background: var(--white);
    border-bottom: 1px solid var(--grey-200);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-list {
    display: flex;
    list-style: none;
    gap: var(--space-xs);
    padding: var(--space-sm) 0;
    margin: 0;
}

.nav-brand {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 1px;
    padding: var(--space-sm) 0;
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    color: var(--grey-700);
    font-weight: 500;
    font-size: 0.9375rem;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.nav-item a:hover {
    background: var(--grey-100);
    color: var(--primary);
}

.nav-item.active a {
    background: var(--primary);
    color: var(--white);
}

.nav-item a svg {
    width: 18px;
    height: 18px;
}

.header-content {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg) var(--space-xl);
    min-height: 70px;
}

.header-brand-centered {
    text-align: center;
    text-decoration: none;
}

.header-brand-centered .header-title {
    color: var(--white);
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0,0,0,0.4);
    letter-spacing: 0.5px;
}

.header-portal-badge {
    position: absolute;
    right: var(--space-xl);
    color: white;
    font-weight: 600;
    padding: 8px 16px;
    background: rgba(255,255,255,0.2);
    border-radius: 8px;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.header-logo {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-full);
    background: var(--white);
    padding: 4px;
    box-shadow: var(--shadow-lg);
}

.header-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.header-title {
    color: var(--white);
    font-size: 1.5rem;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.header-subtitle {
    color: rgba(255,255,255,0.85);
    font-size: 0.875rem;
    font-weight: 400;
}

/* Main Content */
.main-content {
    padding: var(--space-2xl) 0;
    min-height: calc(100vh - 200px);
}

/* Cards */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: all var(--transition-normal);
}

.card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.card-header {
    padding: var(--space-lg) var(--space-xl);
    border-bottom: 1px solid var(--grey-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 1.125rem;
}

.card-body {
    padding: var(--space-xl);
}

.card-footer {
    padding: var(--space-lg) var(--space-xl);
    border-top: 1px solid var(--grey-200);
    background: var(--grey-100);
}

/* Landing Page Portal Selection */
.portal-selection {
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: var(--space-xl);
    padding: var(--space-xl) 0;
    flex-wrap: wrap;
}

.portal-card {
    flex: 1;
    max-width: 380px;
    min-width: 280px;
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    text-align: center;
    padding: var(--space-xl) var(--space-lg);
    transition: all var(--transition-normal);
    cursor: pointer;
    border: 3px solid transparent;
    position: relative;
    overflow: hidden;
}

.portal-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
    transform: scaleX(0);
    transition: transform var(--transition-normal);
}

.portal-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-xl);
    border-color: var(--primary-light);
}

.portal-card:hover::before {
    transform: scaleX(1);
}

.portal-card.admin {
    --card-accent: var(--primary);
}

.portal-card.user {
    --card-accent: var(--accent);
}

.portal-card.user::before {
    background: linear-gradient(90deg, var(--accent) 0%, var(--accent-light) 100%);
}

.portal-card.user:hover {
    border-color: var(--accent-light);
}

.portal-icon {
    width: 70px;
    height: 70px;
    margin: 0 auto var(--space-md);
    background: linear-gradient(135deg, var(--card-accent) 0%, var(--primary-light) 100%);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 15px rgba(26, 95, 95, 0.3);
}

.portal-card.user .portal-icon {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
    box-shadow: 0 6px 15px rgba(200, 60, 90, 0.3);
}

.portal-icon svg {
    width: 36px;
    height: 36px;
    color: var(--white);
}

.portal-card h2 {
    font-size: 1.4rem;
    margin-bottom: var(--space-sm);
}

.portal-card p {
    color: var(--grey-500);
    margin-bottom: var(--space-md);
    font-size: 0.9rem;
}

.portal-features {
    list-style: none;
    text-align: left;
    padding: var(--space-md);
    background: var(--grey-100);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
}

.portal-features li {
    padding: 4px 0;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 0.875rem;
    color: var(--grey-700);
}

.portal-features li svg {
    width: 16px;
    height: 16px;
    color: var(--success);
    flex-shrink: 0;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-xl);
    font-family: var(--font-body);
    font-size: 0.9375rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.btn-lg {
    padding: var(--space-md) var(--space-2xl);
    font-size: 1rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: var(--white);
    box-shadow: 0 4px 12px rgba(26, 95, 95, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(26, 95, 95, 0.4);
    color: var(--white);
}

.btn-accent {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
    color: var(--white);
    box-shadow: 0 4px 12px rgba(200, 60, 90, 0.3);
}

.btn-accent:hover {
    background: linear-gradient(135deg, var(--accent-light) 0%, var(--accent) 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(200, 60, 90, 0.4);
    color: var(--white);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

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

.btn-ghost {
    background: transparent;
    color: var(--grey-700);
}

.btn-ghost:hover {
    background: var(--grey-100);
    color: var(--primary);
}

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

.btn-danger:hover {
    background: #c53030;
}

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

.btn-success:hover {
    background: #2f855a;
}

/* Forms */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    font-weight: 500;
    color: var(--grey-700);
    margin-bottom: var(--space-sm);
    font-size: 0.875rem;
}

.form-control {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    font-family: var(--font-body);
    font-size: 1rem;
    border: 2px solid var(--grey-300);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    background: var(--white);
}

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

.form-control::placeholder {
    color: var(--grey-500);
}

select.form-control {
    cursor: pointer;
}

/* Tables */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--grey-200);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9375rem;
}

.data-table th,
.data-table td {
    padding: var(--space-md) var(--space-lg);
    text-align: left;
    border-bottom: 1px solid var(--grey-200);
}

.data-table th {
    background: var(--grey-100);
    font-weight: 600;
    color: var(--dark);
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table tbody tr:hover {
    background: var(--grey-100);
}

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

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

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

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

.badge-danger {
    background: #fed7d7;
    color: #822727;
}

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

.badge-primary {
    background: #b2d8d8;
    color: var(--primary-dark);
}

/* Alerts */
.alert {
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.alert-success {
    background: #c6f6d5;
    color: #22543d;
    border: 1px solid #9ae6b4;
}

.alert-error {
    background: #fed7d7;
    color: #822727;
    border: 1px solid #fc8181;
}

.alert-warning {
    background: #faf089;
    color: #744210;
    border: 1px solid #f6e05e;
}

.alert-info {
    background: #bee3f8;
    color: #2a4365;
    border: 1px solid #90cdf4;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary);
}

.stat-card.accent::before {
    background: var(--accent);
}

.stat-card.success::before {
    background: var(--success);
}

.stat-card.warning::before {
    background: var(--warning);
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--dark);
    font-family: var(--font-display);
    line-height: 1;
    margin-bottom: var(--space-sm);
}

.stat-label {
    color: var(--grey-500);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Action Buttons Row */
.action-row {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

/* Footer */
.site-footer {
    background: var(--dark);
    color: var(--grey-300);
    padding: var(--space-xl) 0;
    text-align: center;
}

.footer-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-md);
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.footer-logo {
    width: 40px;
    height: 40px;
}

.footer-text {
    font-size: 0.875rem;
}

/* Page Header */
.page-header {
    margin-bottom: var(--space-2xl);
}

.page-header h1 {
    margin-bottom: var(--space-sm);
}

.page-header p {
    color: var(--grey-500);
    margin: 0;
}

.page-header .breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 0.875rem;
    color: var(--grey-500);
    margin-bottom: var(--space-md);
}

.breadcrumb a {
    color: var(--primary);
}

.breadcrumb span {
    color: var(--grey-400);
}

/* Grid System */
.grid {
    display: grid;
    gap: var(--space-lg);
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }
    
    .portal-selection {
        flex-direction: column;
        align-items: center;
    }
    
    .portal-card {
        max-width: 100%;
    }
    
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
}

/* Utilities */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--grey-500); }
.text-success { color: var(--success); }
.text-danger { color: var(--error); }
.text-primary { color: var(--primary); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--space-sm); }
.mb-2 { margin-bottom: var(--space-md); }
.mb-3 { margin-bottom: var(--space-lg); }
.mb-4 { margin-bottom: var(--space-xl); }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--space-sm); }
.mt-2 { margin-top: var(--space-md); }
.mt-3 { margin-top: var(--space-lg); }
.mt-4 { margin-top: var(--space-xl); }

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--space-sm); }
.gap-2 { gap: var(--space-md); }
.gap-3 { gap: var(--space-lg); }

/* Animation */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.4s ease forwards;
}

.fade-in-delay-1 { animation-delay: 0.1s; }
.fade-in-delay-2 { animation-delay: 0.2s; }
.fade-in-delay-3 { animation-delay: 0.3s; }

/* Empty State */
.empty-state {
    text-align: center;
    padding: var(--space-3xl);
    color: var(--grey-500);
}

.empty-state svg {
    width: 80px;
    height: 80px;
    margin-bottom: var(--space-lg);
    opacity: 0.5;
}

.empty-state h3 {
    color: var(--grey-700);
    margin-bottom: var(--space-sm);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow: auto;
    transform: scale(0.9);
    transition: transform var(--transition-normal);
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    padding: var(--space-lg) var(--space-xl);
    border-bottom: 1px solid var(--grey-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-body {
    padding: var(--space-xl);
}

.modal-footer {
    padding: var(--space-lg) var(--space-xl);
    border-top: 1px solid var(--grey-200);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-md);
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--space-sm);
    color: var(--grey-500);
    transition: color var(--transition-fast);
}

.modal-close:hover {
    color: var(--dark);
}

/* Role Selection Options */
.role-options {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.role-option {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    padding: var(--space-md);
    border: 2px solid var(--grey-200);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.role-option:hover {
    border-color: var(--grey-300);
    background: var(--grey-100);
}

.role-option input[type="radio"] {
    margin-top: 4px;
    accent-color: var(--primary);
}

.role-option input[type="radio"]:checked + .role-option-content strong {
    color: var(--primary);
}

.role-option:has(input[type="radio"]:checked) {
    border-color: var(--primary);
    background: rgba(26, 95, 95, 0.05);
}

.role-option-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.role-option-content strong {
    font-size: 0.9375rem;
    color: var(--dark);
}

.role-option-content span {
    font-size: 0.8125rem;
    color: var(--grey-500);
}

/* Nav User Info */
.nav-user {
    display: flex;
    align-items: center;
    gap: 12px;
    color: white;
}
.nav-user-name {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.875rem;
    opacity: 0.9;
}
.nav-badge {
    background: rgba(255,255,255,0.2);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}
.nav-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    background: rgba(255,255,255,0.1);
    border-radius: 6px;
    color: white;
    transition: background 0.2s;
}
.nav-logout:hover {
    background: rgba(255,255,255,0.2);
    color: white;
}

/* Protected row styling */
.row-protected {
    background-color: #fafafa;
}
.row-protected td {
    opacity: 0.85;
}
