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

/* ================================================================
   SAIAB User-KPA Portal: Official Brand Design System
   Enforces Modern Rich Aesthetics, Glassmorphism & Micro-Animations
   Branding: Manrope, Primary #2A3F54, Accent #6C757D
   ================================================================ */
:root {
    /* Typography */
    --font-heading: 'Manrope', Arial, Helvetica, sans-serif;
    --font-body: 'Manrope', Arial, Helvetica, sans-serif;

    /* Curated Institutional Color Palette (From saiab_branding.json) */
    --primary-color: #2A3F54;      /* Deep Slate Blue */
    --primary-dark: #1b2a3a;       /* Darker Slate */
    --primary-light: #f0f4f8;      /* Soft Accent Background */
    --secondary-color: #6C757D;    /* Muted Gray Accent */
    --secondary-dark: #495057;     /* Darker Gray */
    
    /* Gradients & Backgrounds */
    --accent-gradient: linear-gradient(135deg, #2A3F54 0%, #495057 100%);
    --bg-gradient: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%); /* Clean Light Backdrop */
    --card-bg: rgba(255, 255, 255, 0.97); /* Glassmorphism Base */
    --section-bg: #ffffff;
    --input-bg: #ffffff;
    
    /* Utility Colors */
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --border-color: #e2e8f0;
    --text-main: #334155;
    --text-muted: #6C757D;
    
    /* Elevation & Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 12px 32px rgba(42, 63, 84, 0.12);
    --shadow-glow: 0 0 20px rgba(42, 63, 84, 0.15);
    --card-shadow: 0 20px 50px rgba(0, 0, 0, 0.1);

    /* Radius & Transitions */
    --radius-lg: 16px;
    --radius-md: 10px;
    --radius-sm: 5px; /* From branding json */
    --transition-fast: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: var(--font-body);
    line-height: 1.6;
    color: var(--text-main);
    background: var(--bg-gradient);
    min-height: 100vh;
    padding: 30px 20px;
    background-attachment: fixed;
    overflow-x: hidden;
}

/* --- Main Container & Glassmorphism --- */
.container {
    max-width: 1200px;
    margin: 0 auto;
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    border: 1px solid rgba(255, 255, 255, 0.6);
    overflow: hidden;
    animation: containerFadeIn 0.6s ease-out;
}

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

/* --- Logo & Branding Section --- */
.logo-section {
    background: rgba(255, 255, 255, 1);
    padding: 24px 40px;
    text-align: center;
    border-bottom: 3px solid transparent;
    border-image: var(--accent-gradient) 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.logo-section img {
    max-height: 85px;
    width: auto;
    transition: var(--transition-normal);
}

.logo-section img:hover {
    transform: scale(1.03);
    filter: drop-shadow(0 4px 12px rgba(42, 63, 84, 0.15));
}

/* --- Hero Header --- */
.header {
    background: var(--accent-gradient);
    color: white;
    padding: 40px 30px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(circle at top right, rgba(255,255,255,0.08), transparent 60%);
    pointer-events: none;
}

.header h1 {
    font-family: var(--font-heading);
    font-size: 2.6rem;
    font-weight: 700;
    margin-bottom: 12px;
    letter-spacing: -0.5px;
}

.header p {
    font-size: 1.15rem;
    font-weight: 400;
    opacity: 0.9;
    max-width: 700px;
    margin: 0 auto;
}

/* --- Form Layout & Sections --- */
.form-container {
    padding: 40px 50px;
}

.form-section {
    margin-bottom: 45px;
    padding: 35px;
    background: var(--section-bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    border-left: 6px solid var(--primary-color);
    box-shadow: var(--shadow-sm);
    transition: var(--transition-normal);
}

.form-section:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-left-color: var(--secondary-color);
}

.form-section h2 {
    font-family: var(--font-heading);
    color: var(--primary-color);
    margin-bottom: 24px;
    font-size: 1.7rem;
    font-weight: 700;
    letter-spacing: -0.3px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.form-group {
    margin-bottom: 25px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--primary-color);
}

/* --- Premium Inputs & Controls --- */
input[type="text"],
input[type="email"],
input[type="tel"],
textarea,
select {
    width: 100%;
    padding: 14px 18px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--text-main);
    background: var(--input-bg);
    transition: var(--transition-normal);
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.02);
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(42, 63, 84, 0.15);
}

textarea {
    resize: vertical;
    min-height: 120px;
}

/* --- Interactive Platform Categories (Nested Cleanly) --- */
.platform-category {
    margin-bottom: 30px;
    padding: 20px 0;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border-color);
    box-shadow: none;
}

.platform-category:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.category-title {
    font-family: var(--font-heading);
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 1.4rem;
    font-weight: 700;
    padding-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* --- Checkbox Grid & Premium Cards --- */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 18px;
    margin-top: 15px;
}

.checkbox-item {
    display: flex;
    align-items: flex-start;
    padding: 18px 20px;
    background: var(--primary-light);
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border-color);
    transition: var(--transition-normal);
    min-height: 90px;
    cursor: pointer;
}

.checkbox-item:hover {
    border-color: var(--primary-color);
    background: #ffffff;
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.checkbox-item input[type="checkbox"] {
    margin-right: 15px;
    margin-top: 3px;
    transform: scale(1.4);
    cursor: pointer;
    accent-color: var(--primary-color);
    transition: var(--transition-fast);
}

.checkbox-item input[type="checkbox"]:checked {
    accent-color: var(--primary-color);
}

.checkbox-item label {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 0;
    font-weight: 500;
    font-size: 0.95rem;
    line-height: 1.4;
    color: var(--text-main);
}

.checkbox-item label strong {
    color: var(--primary-color);
    font-size: 1.05rem;
    font-weight: 700;
    font-family: var(--font-heading);
}

.platform-desc {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
}

/* --- Dynamic Tables & Drag-and-Drop --- */
.table-container {
    overflow-x: auto;
    margin-bottom: 25px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    background: white;
}

.team-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    min-width: 1250px; /* Prevents squashing on desktop & mobile */
}

.team-table thead {
    background: var(--primary-light);
    color: var(--primary-color);
    border-bottom: 2px solid var(--border-color);
}

.team-table th {
    padding: 16px 14px;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    text-align: left;
}

.team-table td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.team-table tbody tr {
    transition: var(--transition-fast);
}

.team-table tbody tr:hover {
    background-color: var(--primary-light);
}

/* Drag & Drop Visuals */
.team-table tbody tr.dragging {
    opacity: 0.4;
    transform: scale(0.98);
    box-shadow: var(--shadow-lg);
    background: var(--primary-light);
}

.team-table tbody tr.drag-over {
    border-top: 3px solid var(--primary-color);
    border-bottom: 3px solid var(--primary-color);
    background: #f8fafc;
}

.drag-handle {
    cursor: grab;
    color: var(--text-muted);
    font-size: 18px;
    padding: 0 8px;
    transition: var(--transition-fast);
}

.drag-handle:hover {
    color: var(--primary-color);
}

.drag-handle:active {
    cursor: grabbing;
}

.team-table input, 
.team-table select {
    padding: 10px 14px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    background: var(--input-bg);
    min-width: 160px; /* Prevents input text squashing */
}

.team-table td:nth-child(4) select,
.team-table td:nth-child(4) input {
    min-width: 240px; /* Institution / University dropdown */
}

.team-table td:nth-child(9) select {
    min-width: 220px; /* Platforms dropdown */
}

.team-table input:focus, 
.team-table select:focus {
    background: white;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(42, 63, 84, 0.15);
}

/* --- Premium Buttons --- */
.add-member {
    background: var(--primary-light);
    color: var(--primary-color);
    border: 1.5px solid var(--primary-color);
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition-normal);
    margin-bottom: 25px;
}

.add-member:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.remove-row {
    background: var(--danger-color);
    color: white;
    border: none;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font-heading);
    font-size: 0.8rem;
    font-weight: 700;
    transition: var(--transition-fast);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.remove-row:hover {
    background: #dc2626;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* --- Platform Badges & Summaries --- */
.platform-badge {
    display: inline-flex;
    align-items: center;
    background: var(--primary-color);
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    margin: 4px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.platform-summary {
    background: #f0fdf4;
    border: 2px solid var(--success-color);
    border-radius: var(--radius-md);
    padding: 25px;
    margin: 30px 0;
    display: none;
}

.platform-summary.show {
    display: block;
    animation: slideDown 0.4s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-15px); }
    to { opacity: 1; transform: translateY(0); }
}

.platform-summary h4 {
    font-family: var(--font-heading);
    color: #15803d;
    margin-bottom: 16px;
    font-size: 1.2rem;
    font-weight: 700;
}

/* --- Consent & Submit Section --- */
.consent-text {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-left: 6px solid var(--warning-color);
    border-radius: var(--radius-sm);
    padding: 24px;
    margin-bottom: 30px;
    font-size: 0.95rem;
    color: #92400e;
}

.submit-section {
    background: var(--accent-gradient);
    padding: 50px 40px;
    text-align: center;
    margin-top: 50px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}

.submit-btn {
    background: white;
    color: var(--primary-color);
    border: none;
    padding: 18px 50px;
    border-radius: 50px;
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 800;
    cursor: pointer;
    transition: var(--transition-normal);
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    letter-spacing: 0.5px;
}

.submit-btn:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0,0,0,0.25);
    color: var(--primary-dark);
}

.required {
    color: var(--danger-color);
    font-weight: bold;
    margin-left: 3px;
}

/* --- Responsive Breakpoints --- */
@media (max-width: 840px) {
    body { padding: 15px 10px; }
    .form-container { padding: 25px 20px; }
    .header { padding: 30px 20px; }
    .header h1 { font-size: 2rem; }
    .form-section { padding: 25px 20px; }
    .checkbox-grid { grid-template-columns: 1fr; }
    .submit-section { padding: 35px 20px; }
    .submit-btn { padding: 15px 35px; font-size: 1.1rem; width: 100%; }
}