/* =================================================================
   Intranet Portal — Application Styles
   Classes match the actual Razor views (md3-* prefix convention)
   ================================================================= */


/* =================================================================
   PORTAL LAYOUT (non-admin, authenticated pages)
   Top navbar + 3-column grid (left panel / center / right panel)
   ================================================================= */

/* --- Portal Navbar --- */
.portal-navbar {
    position: sticky;
    top: 0;
    z-index: 1040;
    background-color: var(--md-sys-color-primary);
    box-shadow: var(--md-sys-elevation-level2);
}

.portal-navbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    height: 60px;
}

.portal-navbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.portal-navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--md-sys-color-on-primary);
}
.portal-navbar-brand:hover { color: var(--md-sys-color-on-primary); text-decoration: none; }

.portal-navbar-brand-icon {
    font-size: 28px;
    color: var(--md-sys-color-accent);
}

.portal-navbar-brand-text {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.15px;
    white-space: nowrap;
}

.portal-navbar-center {
    flex: 1;
    display: flex;
    justify-content: center;
    padding: 0 32px;
    max-width: 540px;
}

/* Search bar in navbar */
.portal-search {
    position: relative;
    width: 100%;
}
.portal-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    color: rgba(255, 255, 255, 0.5);
    pointer-events: none;
}
.portal-search-input {
    width: 100%;
    height: 40px;
    padding: 0 16px 0 44px;
    border: none;
    border-radius: var(--md-sys-shape-corner-full);
    background-color: rgba(255, 255, 255, 0.12);
    color: var(--md-sys-color-on-primary);
    font-size: 14px;
    font-family: inherit;
    transition: background-color 0.2s;
}
.portal-search-input::placeholder { color: rgba(255, 255, 255, 0.5); }
.portal-search-input:focus {
    outline: none;
    background-color: rgba(255, 255, 255, 0.2);
}

.portal-navbar-right {
    display: flex;
    align-items: center;
    gap: 4px;
}
.portal-navbar-right .md3-btn-icon {
    color: rgba(255, 255, 255, 0.8);
}
.portal-navbar-right .md3-btn-icon:hover {
    background-color: rgba(255, 255, 255, 0.12);
    color: #FFFFFF;
}

.portal-navbar-action { position: relative; }

.portal-navbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    border: none;
    border-radius: var(--md-sys-shape-corner-full);
    background: transparent;
    color: var(--md-sys-color-on-primary);
    cursor: pointer;
    transition: background-color 0.2s;
}
.portal-navbar-user:hover { background-color: rgba(255, 255, 255, 0.12); }

.portal-navbar-avatar {
    width: 34px;
    height: 34px;
    border-radius: var(--md-sys-shape-corner-full);
    background-color: var(--md-sys-color-accent);
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
}

.portal-navbar-username {
    font-size: 14px;
    font-weight: 500;
}

/* Mobile hamburger in navbar */
.portal-mobile-toggle { color: rgba(255, 255, 255, 0.8) !important; }
.portal-mobile-toggle:hover { background-color: rgba(255, 255, 255, 0.12) !important; }


/* --- 3-Column Grid Layout --- */
.portal-layout {
    display: grid;
    grid-template-columns: 260px 1fr 300px;
    gap: 0;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    min-height: calc(100vh - 60px);
}

.portal-left {
    padding-right: 20px;
    position: sticky;
    top: 80px;
    align-self: start;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
}

.portal-center {
    min-width: 0; /* prevent grid blowout */
}

.portal-right {
    padding-left: 20px;
    position: sticky;
    top: 80px;
    align-self: start;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
}


/* --- Portal Panel Cards (left/right column widgets) --- */
.portal-panel-card {
    background-color: var(--md-sys-color-surface);
    border-radius: var(--md-sys-shape-corner-medium);
    box-shadow: var(--md-sys-elevation-level1);
    margin-bottom: 16px;
    overflow: hidden;
}

.portal-panel-heading {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--md-sys-color-on-surface-variant);
    padding: 16px 16px 8px;
    margin: 0;
}

/* Navigation list inside panel cards */
.portal-nav-list {
    list-style: none;
    margin: 0;
    padding: 0 8px 8px;
}
.portal-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--md-sys-shape-corner-small);
    color: var(--md-sys-color-on-surface);
    text-decoration: none;
    font-size: 14px;
    font-weight: 400;
    transition: background-color 0.15s;
}
.portal-nav-item:hover {
    background-color: var(--md-sys-color-surface-container);
    color: var(--md-sys-color-primary);
    text-decoration: none;
}
.portal-nav-item.active {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    font-weight: 500;
}
.portal-nav-item .material-symbols-outlined {
    font-size: 20px;
    color: var(--md-sys-color-on-surface-variant);
}
.portal-nav-item.active .material-symbols-outlined {
    color: var(--md-sys-color-on-primary-container);
}


/* --- Right Panel: Profile Card --- */
.portal-profile-card { text-align: center; }

.portal-profile-cover {
    height: 80px;
    background: linear-gradient(135deg, var(--md-sys-color-primary) 0%, var(--md-sys-color-secondary) 100%);
}

.portal-profile-body {
    padding: 0 20px 20px;
    margin-top: -36px;
}

.portal-profile-avatar {
    width: 72px;
    height: 72px;
    border-radius: var(--md-sys-shape-corner-full);
    background-color: var(--md-sys-color-accent);
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 600;
    margin: 0 auto 12px;
    border: 4px solid var(--md-sys-color-surface);
}

.portal-profile-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--md-sys-color-on-surface);
    margin-bottom: 2px;
}

.portal-profile-email {
    font-size: 13px;
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: 8px;
}

.portal-profile-roles { margin-bottom: 4px; }

.portal-role-badge {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    font-size: 11px;
    font-weight: 500;
}


/* --- Right Panel: Activity list --- */
.portal-activity-list {
    list-style: none;
    margin: 0;
    padding: 0 16px 16px;
}
.portal-activity-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
}
.portal-activity-item:last-child { border-bottom: none; }
.portal-activity-icon { font-size: 20px; flex-shrink: 0; margin-top: 2px; }
.portal-activity-text { font-size: 13px; margin: 0; color: var(--md-sys-color-on-surface); }
.portal-activity-time { font-size: 11px; color: var(--md-sys-color-on-surface-variant); }


/* --- Mobile Overlay for left panel --- */
.portal-mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1029;
}
.portal-mobile-overlay.show { display: block; }


/* --- Portal Responsive --- */
@media (max-width: 1199.98px) {
    /* Drop to 2 columns: hide right panel */
    .portal-layout {
        grid-template-columns: 260px 1fr;
    }
    .portal-right { display: none; }
}

@media (max-width: 991.98px) {
    /* Drop to 1 column: left panel becomes off-canvas */
    .portal-layout {
        grid-template-columns: 1fr;
        padding: 16px;
    }
    .portal-left {
        display: none;
        position: fixed;
        top: 60px;
        left: 0;
        bottom: 0;
        width: 280px;
        z-index: 1030;
        background-color: var(--md-sys-color-surface-container-low);
        padding: 16px;
        overflow-y: auto;
        box-shadow: var(--md-sys-elevation-level4);
    }
    .portal-left.show { display: block; }
    .portal-right { display: none; }
}


/* =================================================================
   ADMIN LAYOUT (Settings area — sidebar + topbar)
   ================================================================= */

/* --- App Layout (authenticated) --- */
.md3-app-layout {
    min-height: 100vh;
}

.md3-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1049;
}
.md3-sidebar-overlay.show { display: block; }

/* --- Sidebar --- */
.md3-sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background-color: var(--md-sys-color-secondary);
    color: #FFFFFF;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.md3-sidebar-brand {
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.md3-sidebar-brand a { color: #FFFFFF; }
.md3-sidebar-brand-icon {
    font-size: 28px;
    color: var(--md-sys-color-accent);
}
.md3-sidebar-brand-text {
    font-size: 18px;
    font-weight: 600;
    color: #FFFFFF;
    letter-spacing: 0.15px;
}
.md3-sidebar-close { color: rgba(255, 255, 255, 0.7); }

.md3-sidebar-nav {
    padding: 12px 0;
    flex: 1;
}
.md3-sidebar-section {
    padding: 0 12px;
    margin-bottom: 8px;
}
.md3-sidebar-section-label {
    display: block;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.5);
    padding: 8px 12px 4px;
}
.md3-sidebar-menu {
    list-style: none;
    margin: 0;
    padding: 0;
}

.md3-sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--md-sys-shape-corner-full);
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-size: 14px;
    font-weight: 400;
    transition: background-color 0.2s, color 0.2s;
    margin-bottom: 2px;
}
.md3-sidebar-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #FFFFFF;
    text-decoration: none;
}
.md3-sidebar-link.active {
    background-color: rgba(255, 255, 255, 0.15);
    color: #FFFFFF;
    font-weight: 500;
}
.md3-sidebar-link .material-symbols-outlined {
    font-size: 22px;
    opacity: 0.9;
}


/* --- Main Content Area (admin) --- */
.md3-main-content {
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.md3-page-content {
    flex: 1;
    max-width: 1400px;
    width: 100%;
}


/* --- TopBar (admin) --- */
.md3-topbar {
    background-color: var(--md-sys-color-surface);
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    z-index: 999;
}

.md3-btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: var(--md-sys-shape-corner-full);
    background: transparent;
    color: var(--md-sys-color-on-surface-variant);
    cursor: pointer;
}
.md3-btn-icon:hover { background-color: rgba(28, 27, 31, 0.08); }

.md3-breadcrumb-link {
    color: var(--md-sys-color-on-surface-variant);
    text-decoration: none;
}
.md3-breadcrumb-link:hover { color: var(--md-sys-color-primary); }

.md3-avatar-circle {
    width: 36px;
    height: 36px;
    border-radius: var(--md-sys-shape-corner-full);
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 500;
}

.md3-topbar-username {
    font-size: 14px;
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
}

.md3-user-dropdown {
    border: none;
    background: transparent;
}
.md3-user-dropdown:hover { background-color: rgba(28, 27, 31, 0.04); border-radius: var(--md-sys-shape-corner-small); }

.md3-dropdown-menu {
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-small);
    box-shadow: var(--md-sys-elevation-level2);
}


/* --- Flash Messages Container --- */
.md3-flash-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
}

.md3-snackbar-close {
    margin-left: auto;
    background: none;
    border: none;
    color: inherit;
    opacity: 0.7;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}
.md3-snackbar-close:hover { opacity: 1; }


/* =================================================================
   SHARED STYLES (used by both layouts)
   ================================================================= */

/* --- Content --- */
.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}
.content-header h1 {
    margin: 0;
    color: var(--md-sys-color-on-surface);
}

.content-body { }


/* --- Login Page --- */
.md3-login-body {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--md-sys-color-primary) 0%, var(--md-sys-color-secondary) 100%);
}

.md3-login-card {
    width: 100%;
    max-width: 440px;
    background: var(--md-sys-color-surface);
    border-radius: var(--md-sys-shape-corner-extra-large);
    padding: 48px 40px;
    box-shadow: var(--md-sys-elevation-level3);
}

.md3-input-wrapper {
    position: relative;
}
.md3-input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--md-sys-color-on-surface-variant);
    font-size: 20px;
    pointer-events: none;
}
.md3-input {
    padding-left: 44px !important;
}
.md3-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--md-sys-color-on-surface-variant);
    letter-spacing: 0.5px;
}
.md3-validation-error {
    font-size: 12px;
    color: var(--md-sys-color-error);
}

.md3-divider-text {
    display: flex;
    align-items: center;
    gap: 16px;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 13px;
}
.md3-divider-text::before,
.md3-divider-text::after {
    content: '';
    flex: 1;
    height: 1px;
    background-color: var(--md-sys-color-outline-variant);
}


/* --- Dashboard Cards --- */
.dashboard-card {
    transition: transform 0.2s, box-shadow 0.2s;
}
.dashboard-card:hover { transform: translateY(-2px); }

.dashboard-card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--md-sys-shape-corner-medium);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}
.dashboard-card-icon.primary { background-color: var(--md-sys-color-primary-container); color: var(--md-sys-color-on-primary-container); }
.dashboard-card-icon.secondary { background-color: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }
.dashboard-card-icon.tertiary { background-color: var(--md-sys-color-tertiary-container); color: var(--md-sys-color-on-tertiary-container); }
.dashboard-card-icon.accent { background-color: #FFE0D6; color: #BF360C; }

.dashboard-card-title {
    font-size: 16px; font-weight: 500; margin-bottom: 4px; color: var(--md-sys-color-on-surface);
}
.dashboard-card-desc {
    font-size: 14px; color: var(--md-sys-color-on-surface-variant); margin-bottom: 0;
}


/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--md-sys-color-on-surface-variant);
}
.empty-state .material-symbols-outlined { font-size: 64px; opacity: 0.4; margin-bottom: 16px; }
.empty-state h3 { font-size: 20px; font-weight: 500; margin-bottom: 8px; color: var(--md-sys-color-on-surface); }
.empty-state p { font-size: 14px; margin-bottom: 24px; }


/* --- Error Pages --- */
.error-page {
    min-height: 60vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 48px 24px;
}
.error-page .material-symbols-outlined { font-size: 80px; color: var(--md-sys-color-on-surface-variant); opacity: 0.5; margin-bottom: 24px; }
.error-page h1 { font-size: 48px; font-weight: 700; margin-bottom: 8px; }
.error-page p { font-size: 16px; color: var(--md-sys-color-on-surface-variant); margin-bottom: 32px; }


/* --- Permissions Matrix --- */
.permissions-matrix .form-check-input:checked {
    background-color: var(--md-sys-color-primary);
    border-color: var(--md-sys-color-primary);
}
.permissions-matrix td { vertical-align: middle; }
.permissions-matrix .feature-name { font-weight: 500; }


/* --- Settings Cards --- */
.settings-card { text-decoration: none; color: inherit; display: block; }
.settings-card:hover { color: inherit; text-decoration: none; }
.settings-card .md3-card-elevated { height: 100%; }
.settings-card-icon {
    width: 56px; height: 56px;
    border-radius: var(--md-sys-shape-corner-medium);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 16px; font-size: 28px;
}

.md3-card-interactive {
    transition: box-shadow 0.2s, transform 0.2s;
    cursor: pointer;
}
.md3-card-interactive:hover {
    box-shadow: var(--md-sys-elevation-level3);
    transform: translateY(-2px);
}


/* --- Search Bar (admin) --- */
.search-bar {
    position: relative;
    max-width: 360px;
}
.search-bar .material-symbols-outlined {
    position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
    color: var(--md-sys-color-on-surface-variant); font-size: 20px;
}
.search-bar input {
    padding-left: 48px;
    border-radius: var(--md-sys-shape-corner-full);
    border: 1px solid var(--md-sys-color-outline-variant);
    height: 44px; font-size: 14px; width: 100%;
}
.search-bar input:focus { border-color: var(--md-sys-color-primary); box-shadow: none; }


/* --- Step Circle (getting started) --- */
.md3-step-circle {
    width: 28px;
    height: 28px;
    border-radius: var(--md-sys-shape-corner-full);
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
}

/* --- Card Outlined (used in dashboard) --- */
.md3-card-outlined {
    background-color: var(--md-sys-color-surface);
    border-radius: var(--md-sys-shape-corner-medium);
    border: 1px solid var(--md-sys-color-outline-variant);
    transition: box-shadow 0.2s;
}
.md3-card-outlined:hover { box-shadow: var(--md-sys-elevation-level1); }


/* =================================================================
   RESPONSIVE (Admin layout)
   ================================================================= */
@media (max-width: 991.98px) {
    .md3-sidebar {
        transform: translateX(-100%);
    }
    .md3-sidebar.show {
        transform: translateX(0);
    }
    .md3-main-content {
        margin-left: 0;
    }
}

@media (max-width: 767.98px) {
    .md3-page-content { padding: 16px !important; }
    .content-header { margin-bottom: 16px; }
    .md3-login-card { padding: 32px 24px; margin: 16px; }
}
