/* ============================================
   CIS Kenya - Portal Styles
   Premium portal UI with CIS branding
   ============================================ */

/* Student ID badge — compact, premium, monospace for readability */
.student-id-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 6px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--portal-primary, #5b1a2e);
    background: rgba(91, 26, 46, 0.06);
    border: 1px solid rgba(91, 26, 46, 0.12);
    white-space: nowrap;
}

:root {
    --portal-sidebar-w: 260px;
    --portal-topbar-h: 64px;
    --portal-bg: #f0f2f5;
    --portal-sidebar-bg: #6b1a2e;
    --portal-sidebar-bg-dark: #4a0f1f;
    --portal-sidebar-active: rgba(197, 160, 40, 0.15);
    --portal-sidebar-active-border: #c5a028;
    --portal-card-bg: #ffffff;
    --portal-card-bg-soft: #fafbfc;
    --portal-card-radius: 12px;
    --portal-text: #1a1a2e;
    --portal-text-muted: #6b7280;
    --portal-border: #e5e7eb;
    --portal-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --portal-shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.10);
    --portal-accent: #c5a028;
    --portal-accent-bright: #e6b845;
    --portal-primary: #6b1a2e;
    --portal-success: #16a34a;
    --portal-danger: #dc2626;
    --portal-warning: #f59e0b;
    --portal-info: #2563eb;
}

* {
    box-sizing: border-box;
}

.portal-body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--portal-bg);
    color: var(--portal-text);
    -webkit-font-smoothing: antialiased;
}

.portal {
    display: flex;
    min-height: 100vh;
}

/* ============================================
   Sidebar
   ============================================ */
.portal__sidebar {
    width: var(--portal-sidebar-w);
    background: linear-gradient(180deg, var(--portal-sidebar-bg) 0%, var(--portal-sidebar-bg-dark) 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.portal__sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.portal__logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #fff;
    flex: 1;
    min-width: 0;
}

.portal__logo-img {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.95);
    padding: 3px;
    flex-shrink: 0;
    object-fit: contain;
}

.portal__logo-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.portal__logo-name {
    font-family: 'Poppins', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.portal__logo-sub {
    font-size: 0.65rem;
    color: var(--portal-accent);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
}

.portal__sidebar-close {
    display: none;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: all 0.2s;
}

.portal__sidebar-close:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

/* User Card */
.portal__user-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.portal__user-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--portal-accent), #b8901f);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: #fff;
    flex-shrink: 0;
    overflow: hidden;
}

.portal__user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.portal__user-avatar--sm {
    width: 34px;
    height: 34px;
    font-size: 0.75rem;
}

.portal__user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.portal__user-name {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.portal__user-role {
    font-size: 0.7rem;
    color: var(--portal-accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

/* Navigation */
.portal__nav {
    flex: 1;
    padding: 0.75rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.portal__nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.65rem 0.85rem;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.2s;
    position: relative;
    white-space: nowrap;
}

.portal__nav-link svg {
    flex-shrink: 0;
    opacity: 0.8;
}

.portal__nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.06);
}

.portal__nav-link.active {
    color: #fff;
    background: var(--portal-sidebar-active);
    font-weight: 600;
}

.portal__nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--portal-sidebar-active-border);
    border-radius: 0 3px 3px 0;
}

.portal__nav-link.active svg {
    opacity: 1;
    color: var(--portal-accent);
}

.portal__nav-badge {
    margin-left: auto;
    background: var(--portal-danger);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.portal__sidebar-footer {
    padding: 0.5rem 0.5rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.portal__nav-link--logout {
    color: rgba(255, 255, 255, 0.5);
}

.portal__nav-link--logout:hover {
    color: #ff6b6b;
    background: rgba(255, 107, 107, 0.1);
}

/* ============================================
   Main Content Area
   ============================================ */
.portal__main {
    flex: 1;
    margin-left: var(--portal-sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Top Bar */
.portal__topbar {
    height: var(--portal-topbar-h);
    background: var(--portal-card-bg);
    border-bottom: 1px solid var(--portal-border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--portal-shadow);
}

.portal__menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--portal-text);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: background 0.2s;
}

.portal__menu-btn:hover {
    background: var(--portal-bg);
}

.portal__page-title {
    font-family: 'Poppins', sans-serif;
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
    flex: 1;
    color: var(--portal-text);
}

.portal__topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.portal__topbar-icon {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    color: var(--portal-text-muted);
    text-decoration: none;
    transition: all 0.2s;
}

.portal__topbar-icon:hover {
    background: var(--portal-bg);
    color: var(--portal-primary);
}

.portal__topbar-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--portal-danger);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 8px;
    min-width: 16px;
    text-align: center;
    line-height: 1.3;
}

.portal__topbar-user {
    display: flex;
    align-items: center;
}

/* Flash Messages */
.portal__flash {
    padding: 1rem 1.5rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.portal__flash-item {
    border-radius: 10px;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
}

/* Content Area */
.portal__content {
    flex: 1;
    padding: 1.5rem;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

/* ============================================
   Cards
   ============================================ */
.portal__card {
    background: var(--portal-card-bg);
    border-radius: var(--portal-card-radius);
    box-shadow: var(--portal-shadow);
    overflow: hidden;
    transition: box-shadow 0.3s, transform 0.3s;
}

.portal__card:hover {
    box-shadow: var(--portal-shadow-lg);
}

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

.portal__card-title {
    font-family: 'Poppins', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
    color: var(--portal-text);
}

.portal__card-body {
    padding: 1.5rem;
}

.portal__card-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--portal-border);
    background: #fafafa;
}

/* ============================================
   Stat Cards
   ============================================ */
.portal__stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.portal__stat {
    background: var(--portal-card-bg);
    border-radius: var(--portal-card-radius);
    padding: 1.25rem;
    box-shadow: var(--portal-shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.portal__stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.portal__stat-icon--primary { background: rgba(107, 26, 46, 0.1); color: var(--portal-primary); }
.portal__stat-icon--accent { background: rgba(197, 160, 40, 0.1); color: var(--portal-accent); }
.portal__stat-icon--success { background: rgba(22, 163, 74, 0.1); color: var(--portal-success); }
.portal__stat-icon--danger { background: rgba(220, 38, 38, 0.1); color: var(--portal-danger); }
.portal__stat-icon--info { background: rgba(37, 99, 235, 0.1); color: var(--portal-info); }
.portal__stat-icon--warning { background: rgba(245, 158, 11, 0.1); color: var(--portal-warning); }

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

.portal__stat-value {
    font-family: 'Poppins', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--portal-text);
}

.portal__stat-label {
    font-size: 0.75rem;
    color: var(--portal-text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* ============================================
   Grid Layout
   ============================================ */
.portal__grid {
    display: grid;
    gap: 1.5rem;
}

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

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

.portal__grid--sidebar {
    grid-template-columns: 2fr 1fr;
}

/* ============================================
   Tables
   ============================================ */
.portal__table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.portal__table th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-weight: 600;
    color: var(--portal-text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 2px solid var(--portal-border);
    background: #fafafa;
}

.portal__table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--portal-border);
    color: var(--portal-text);
}

.portal__table tbody tr:hover {
    background: #f9fafb;
}

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

/* ============================================
   Badges
   ============================================ */
.portal__badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.portal__badge--success { background: rgba(22, 163, 74, 0.1); color: var(--portal-success); }
.portal__badge--danger { background: rgba(220, 38, 38, 0.1); color: var(--portal-danger); }
.portal__badge--warning { background: rgba(245, 158, 11, 0.1); color: var(--portal-warning); }
.portal__badge--info { background: rgba(37, 99, 235, 0.1); color: var(--portal-info); }
.portal__badge--neutral { background: #f3f4f6; color: var(--portal-text-muted); }

/* ============================================
   Forms
   ============================================ */
.portal__form-group {
    margin-bottom: 1.25rem;
}

.portal__form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--portal-text);
    margin-bottom: 0.4rem;
}

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

.portal__form-input,
.portal__form-select,
.portal__form-textarea {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1.5px solid var(--portal-border);
    border-radius: 10px;
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--portal-text);
    background: var(--portal-card-bg);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.portal__form-input:focus,
.portal__form-select:focus,
.portal__form-textarea:focus {
    outline: none;
    border-color: var(--portal-accent);
    box-shadow: 0 0 0 3px rgba(197, 160, 40, 0.12);
}

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

.portal__form-hint {
    font-size: 0.75rem;
    color: var(--portal-text-muted);
    margin-top: 0.3rem;
}

.portal__form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* ============================================
   Buttons
   ============================================ */
.portal__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0.65rem 1.5rem;
    border: none;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
}

.portal__btn--primary {
    background: var(--portal-primary);
    color: #fff;
}

.portal__btn--primary:hover {
    background: #5a1525;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(107, 26, 46, 0.25);
}

.portal__btn--accent {
    background: linear-gradient(135deg, var(--portal-accent), #b8901f);
    color: #fff;
}

.portal__btn--accent:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(197, 160, 40, 0.3);
}

.portal__btn--outline {
    background: transparent;
    border: 1.5px solid var(--portal-border);
    color: var(--portal-text);
}

.portal__btn--outline:hover {
    border-color: var(--portal-primary);
    color: var(--portal-primary);
    background: rgba(107, 26, 46, 0.04);
}

.portal__btn--danger {
    background: var(--portal-danger);
    color: #fff;
}

.portal__btn--danger:hover {
    background: #b91c1c;
}

.portal__btn--sm {
    padding: 0.4rem 0.85rem;
    font-size: 0.75rem;
}

.portal__btn--block {
    width: 100%;
}

/* ============================================
   Empty State
   ============================================ */
.portal__empty {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--portal-text-muted);
}

.portal__empty-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #d1d5db;
}

.portal__empty-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--portal-text);
    margin-bottom: 0.25rem;
}

.portal__empty-text {
    font-size: 0.85rem;
    max-width: 400px;
    margin: 0 auto;
}

/* ============================================
   Announcement Item
   ============================================ */
.portal__announcement {
    padding: 1.25rem;
    border-bottom: 1px solid var(--portal-border);
}

.portal__announcement:last-child {
    border-bottom: none;
}

.portal__announcement-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.portal__announcement-title {
    font-family: 'Poppins', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--portal-text);
    margin: 0;
}

.portal__announcement-meta {
    font-size: 0.75rem;
    color: var(--portal-text-muted);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.portal__announcement-content {
    font-size: 0.85rem;
    color: var(--portal-text);
    line-height: 1.6;
}

.portal__announcement--pinned {
    background: rgba(197, 160, 40, 0.04);
}

/* ============================================
   Chat UI
   ============================================ */
.portal__chat {
    display: flex;
    border: 1px solid var(--portal-border);
    border-radius: 14px;
    overflow: hidden;
    background: var(--portal-card-bg);
    height: calc(100vh - 220px);
    min-height: 500px;
}

/* Contact List Sidebar */
.portal__chat-sidebar {
    width: 280px;
    flex-shrink: 0;
    border-right: 1px solid var(--portal-border);
    display: flex;
    flex-direction: column;
    background: #fafbfc;
}

.portal__chat-sidebar-header {
    padding: 1rem 1.25rem;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--portal-text);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--portal-border);
    background: var(--portal-card-bg);
}

.portal__chat-contacts {
    flex: 1;
    overflow-y: auto;
}

.portal__chat-contact {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f0f1f3;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
    cursor: pointer;
    position: relative;
}

.portal__chat-contact:hover {
    background: #f3f4f6;
}

.portal__chat-contact.active {
    background: rgba(107, 26, 46, 0.06);
    border-left: 3px solid var(--portal-primary);
    padding-left: calc(1rem - 3px);
}

.portal__chat-contact-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--portal-primary), #8a2540);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.portal__chat-contact-info {
    flex: 1;
    min-width: 0;
}

.portal__chat-contact-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--portal-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.portal__chat-contact-preview {
    font-size: 0.72rem;
    color: var(--portal-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 2px;
}

.portal__chat-contact--unread .portal__chat-contact-name {
    font-weight: 700;
    color: var(--portal-primary);
}

.portal__chat-contact--unread .portal__chat-contact-preview {
    color: var(--portal-text);
    font-weight: 500;
}

.portal__chat-contact-badge {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--portal-info);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Chat Main Panel */
.portal__chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--portal-card-bg);
}

.portal__chat-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--portal-border);
    background: var(--portal-card-bg);
    flex-shrink: 0;
}

.portal__chat-back {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--portal-text-muted);
    padding: 4px;
    border-radius: 6px;
    transition: background 0.15s;
}

.portal__chat-back:hover {
    background: #f3f4f6;
}

.portal__chat-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--portal-primary), #8a2540);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.portal__chat-header-info {
    flex: 1;
    min-width: 0;
}

.portal__chat-header-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--portal-text);
}

.portal__chat-header-status {
    margin-top: 2px;
}

/* Chat Messages Area */
.portal__chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: #f8f9fa;
}

/* Chat Bubbles */
.portal__chat-bubble-wrap {
    display: flex;
    gap: 0.5rem;
    max-width: 70%;
    align-items: flex-end;
}

.portal__chat-bubble-wrap--mine {
    margin-left: auto;
    flex-direction: row-reverse;
}

.portal__chat-bubble-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--portal-primary), #8a2540);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 0.6rem;
    flex-shrink: 0;
}

.portal__chat-bubble {
    background: var(--portal-card-bg);
    border: 1px solid var(--portal-border);
    border-radius: 16px 16px 16px 4px;
    padding: 0.625rem 0.875rem;
    min-width: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.portal__chat-bubble--mine {
    background: linear-gradient(135deg, var(--portal-primary), #7d1f38);
    color: #fff;
    border: none;
    border-radius: 16px 16px 4px 16px;
}

.portal__chat-bubble-text {
    font-size: 0.85rem;
    line-height: 1.5;
}

.portal__chat-bubble-time {
    font-size: 0.62rem;
    color: var(--portal-text-muted);
    margin-top: 4px;
    text-align: right;
}

.portal__chat-bubble--mine .portal__chat-bubble-time {
    color: rgba(255, 255, 255, 0.65);
}

/* Group Chat */
.portal__chat-group-avatar {
    background: linear-gradient(135deg, var(--portal-accent), #b8901f) !important;
}

.portal__chat-contact--group {
    border-bottom: 2px solid var(--portal-border);
}

.portal__chat-bubble-author {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--portal-primary);
    margin-bottom: 3px;
}

/* Chat Input */
.portal__chat-input {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--portal-border);
    background: var(--portal-card-bg);
    flex-shrink: 0;
}

.portal__chat-input input {
    flex: 1;
    border: 1.5px solid var(--portal-border);
    border-radius: 22px;
    padding: 0.625rem 1rem;
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.portal__chat-input input:focus {
    border-color: var(--portal-primary);
}

.portal__chat-send {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--portal-primary), #7d1f38);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s, box-shadow 0.15s;
}

.portal__chat-send:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(107, 26, 46, 0.3);
}

.portal__chat-send:active {
    transform: scale(0.95);
}

/* Mobile Chat */
@media (max-width: 768px) {
    .portal__chat {
        height: calc(100vh - 200px);
    }
    .portal__chat-sidebar {
        width: 100%;
        border-right: none;
    }
    .portal__chat.sidebar-hidden .portal__chat-sidebar {
        display: none;
    }
    .portal__chat:not(.sidebar-hidden) .portal__chat-main {
        display: none;
    }
    .portal__chat-back {
        display: flex;
    }
    .portal__chat-bubble-wrap {
        max-width: 85%;
    }
}

/* ============================================
   Tabs
   ============================================ */
.portal__tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 2px solid var(--portal-border);
    margin-bottom: 1.5rem;
}

.portal__tab {
    padding: 0.65rem 1.25rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--portal-text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
    border-radius: 8px 8px 0 0;
}

.portal__tab:hover {
    color: var(--portal-text);
    background: #f9fafb;
}

.portal__tab.active {
    color: var(--portal-primary);
    border-bottom-color: var(--portal-primary);
}

/* ============================================
   Section Spacing
   ============================================ */
.portal__section {
    margin-bottom: 1.5rem;
}

.portal__section-title {
    font-family: 'Poppins', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0 0 1rem;
    color: var(--portal-text);
}

/* ============================================
   Mobile Overlay
   ============================================ */
.portal__overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.portal__overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   Auth Pages (Login, Activate, Reset)
   ============================================ */
.portal-auth {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #6b1a2e 0%, #4a0f1f 100%);
    padding: 1rem;
    position: relative;
    overflow: hidden;
}

.portal-auth::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(197, 160, 40, 0.08) 0%, transparent 60%);
    animation: portalAuthGlow 8s ease-in-out infinite alternate;
}

@keyframes portalAuthGlow {
    0% { transform: scale(1); }
    100% { transform: scale(1.1); }
}

.portal-auth__card {
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3);
    padding: 2.5rem;
    max-width: 440px;
    width: 100%;
    position: relative;
    z-index: 1;
}

.portal-auth__logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 1.5rem;
}

.portal-auth__logo img {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.95);
    padding: 4px;
    object-fit: contain;
}

.portal-auth__logo-text {
    display: flex;
    flex-direction: column;
}

.portal-auth__logo-name {
    font-family: 'Poppins', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--portal-text);
}

.portal-auth__logo-sub {
    font-size: 0.7rem;
    color: var(--portal-accent);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
}

.portal-auth__title {
    font-family: 'Poppins', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    margin: 0 0 0.5rem;
    color: var(--portal-text);
}

.portal-auth__subtitle {
    text-align: center;
    font-size: 0.85rem;
    color: var(--portal-text-muted);
    margin: 0 0 2rem;
}

.portal-auth__footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.8rem;
    color: var(--portal-text-muted);
}

.portal-auth__footer a {
    color: var(--portal-primary);
    text-decoration: none;
    font-weight: 600;
}

.portal-auth__footer a:hover {
    text-decoration: underline;
}

.portal-auth__alert {
    padding: 0.75rem 1rem;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 1.5rem;
}

.portal-auth__alert--error {
    background: rgba(220, 38, 38, 0.08);
    color: var(--portal-danger);
    border: 1px solid rgba(220, 38, 38, 0.15);
}

.portal-auth__alert--success {
    background: rgba(22, 163, 74, 0.08);
    color: var(--portal-success);
    border: 1px solid rgba(22, 163, 74, 0.15);
}

.portal-auth__back {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 1.5rem;
    font-size: 0.85rem;
    color: var(--portal-text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

.portal-auth__back:hover {
    color: var(--portal-primary);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 1024px) {
    .portal__grid--3 {
        grid-template-columns: repeat(2, 1fr);
    }

    .portal__grid--sidebar {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .portal__sidebar {
        transform: translateX(-100%);
    }

    .portal__sidebar.open {
        transform: translateX(0);
    }

    .portal__sidebar-close {
        display: flex;
    }

    .portal__overlay.active {
        display: block;
    }

    .portal__main {
        margin-left: 0;
    }

    .portal__menu-btn {
        display: flex;
    }

    .portal__content {
        padding: 1rem;
    }

    .portal__grid--2,
    .portal__grid--3 {
        grid-template-columns: 1fr;
    }

    .portal__form-row {
        grid-template-columns: 1fr;
    }

    .portal__stats {
        grid-template-columns: 1fr 1fr;
    }

    .portal__page-title {
        font-size: 1rem;
    }

    .portal__topbar {
        padding: 0 1rem;
    }

    .portal-auth__card {
        padding: 1.75rem;
    }
}

@media (max-width: 480px) {
    .portal__stats {
        grid-template-columns: 1fr;
    }

    .portal__topbar-user {
        display: none;
    }
}

/* ============================================
   Notification Dropdown
   ============================================ */
.portal__notif {
    position: relative;
}

.portal__notif-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 360px;
    max-width: calc(100vw - 2rem);
    background: var(--portal-card-bg);
    border-radius: var(--portal-card-radius);
    box-shadow: var(--portal-shadow-lg);
    border: 1px solid var(--portal-border);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
}

.portal__notif-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.portal__notif-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--portal-border);
    font-weight: 600;
    font-size: 0.9rem;
}

.portal__notif-markall {
    background: none;
    border: none;
    color: var(--portal-primary);
    font-size: 0.78rem;
    cursor: pointer;
    padding: 0;
    font-weight: 500;
}

.portal__notif-markall:hover {
    text-decoration: underline;
}

.portal__notif-list {
    max-height: 400px;
    overflow-y: auto;
}

.portal__notif-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--portal-border);
    transition: background 0.15s ease;
}

.portal__notif-item:hover {
    background: var(--portal-card-bg-soft);
}

.portal__notif-item--unread {
    background: rgba(107, 26, 46, 0.03);
}

.portal__notif-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

.portal__notif-icon--info { background: var(--portal-info); }
.portal__notif-icon--success { background: var(--portal-success); }
.portal__notif-icon--warning { background: var(--portal-warning); }
.portal__notif-icon--danger { background: var(--portal-danger); }
.portal__notif-icon--attendance { background: var(--portal-warning); }
.portal__notif-icon--homework { background: var(--portal-info); }
.portal__notif-icon--default { background: var(--portal-text-muted); }

.portal__notif-content {
    flex: 1;
    min-width: 0;
}

.portal__notif-title {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 2px;
}

.portal__notif-text {
    font-size: 0.8rem;
    color: var(--portal-text-muted);
    line-height: 1.4;
}

.portal__notif-time {
    font-size: 0.72rem;
    color: var(--portal-text-muted);
    margin-top: 4px;
}

.portal__notif-dot {
    flex-shrink: 0;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--portal-primary);
    border: none;
    cursor: pointer;
    margin-top: 4px;
}

.portal__notif-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--portal-text-muted);
    font-size: 0.85rem;
}

/* ============================================
   Parent Child Selector
   ============================================ */
.portal__child-selector {
    margin-right: 0.5rem;
}

.portal__child-select {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--portal-border);
    border-radius: 8px;
    font-size: 0.82rem;
    font-family: inherit;
    background: var(--portal-card-bg);
    color: var(--portal-text);
    cursor: pointer;
    font-weight: 500;
    transition: border-color 0.2s ease;
}

.portal__child-select:hover {
    border-color: var(--portal-primary);
}

.portal__child-select:focus {
    outline: none;
    border-color: var(--portal-primary);
    box-shadow: 0 0 0 3px rgba(107, 26, 46, 0.1);
}

/* ============================================
   Small Form Inputs
   ============================================ */
.portal__form-input--sm {
    padding: 0.35rem 0.6rem;
    font-size: 0.82rem;
}

.portal__form-file {
    padding: 0.5rem;
    font-size: 0.85rem;
    border: 2px dashed var(--portal-border);
    border-radius: 8px;
    cursor: pointer;
}

.portal__form-file:hover {
    border-color: var(--portal-primary);
}

/* ============================================
   Alerts
   ============================================ */
.portal__alert {
    padding: 0.875rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    line-height: 1.5;
}

.portal__alert--info {
    background: rgba(37, 99, 235, 0.08);
    color: #1e40af;
    border: 1px solid rgba(37, 99, 235, 0.2);
}

.portal__alert--warning {
    background: rgba(245, 158, 11, 0.08);
    color: #92400e;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.portal__alert--success {
    background: rgba(22, 163, 74, 0.08);
    color: #166534;
    border: 1px solid rgba(22, 163, 74, 0.2);
}

.portal__alert--danger {
    background: rgba(220, 38, 38, 0.08);
    color: #991b1b;
    border: 1px solid rgba(220, 38, 38, 0.2);
}

/* ============================================
   Quick Action Cards
   ============================================ */
.portal__quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.portal__quick-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.25rem 0.75rem;
    background: var(--portal-card-bg);
    border-radius: var(--portal-card-radius);
    border: 1px solid var(--portal-border);
    text-decoration: none;
    color: var(--portal-text);
    transition: all 0.2s ease;
    text-align: center;
}

.portal__quick-action:hover {
    border-color: var(--portal-primary);
    box-shadow: var(--portal-shadow);
    transform: translateY(-2px);
}

.portal__quick-action-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(107, 26, 46, 0.08);
    color: var(--portal-primary);
}

.portal__quick-action-label {
    font-size: 0.8rem;
    font-weight: 500;
}

@media (max-width: 768px) {
    .portal__notif-dropdown {
        position: fixed;
        top: var(--portal-topbar-h);
        right: 0;
        left: 0;
        width: auto;
        max-width: none;
        border-radius: 0 0 12px 12px;
    }

    .portal__child-selector {
        display: none;
    }
}
