/* Variables for premium design system */
:root {
    --bg-color: #0b0f19;
    --card-bg: rgba(255, 255, 255, 0.03);
    --card-border: rgba(255, 255, 255, 0.08);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --primary-gradient: linear-gradient(135deg, #a78bfa 0%, #6366f1 50%, #4f46e5 100%);
    --secondary-gradient: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.01) 100%);
    --accent-color: #a78bfa;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --glow-1: rgba(99, 102, 241, 0.15);
    --glow-2: rgba(167, 139, 250, 0.15);
    --transition-smooth: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Background orbs */
.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    z-index: 0;
    pointer-events: none;
    animation: pulse 12s infinite alternate ease-in-out;
}

.orb-1 {
    top: -10%;
    left: -10%;
    width: 50vw;
    height: 50vw;
    background: var(--glow-1);
}

.orb-2 {
    bottom: -20%;
    right: -10%;
    width: 60vw;
    height: 60vw;
    background: var(--glow-2);
    animation-delay: -4s;
}

.orb-3 {
    top: 40%;
    left: 35%;
    width: 30vw;
    height: 30vw;
    background: rgba(124, 58, 237, 0.1);
    animation-delay: -8s;
}

@keyframes pulse {
    0% {
        transform: scale(1) translate(0px, 0px);
    }
    100% {
        transform: scale(1.1) translate(30px, -20px);
    }
}

/* Layout systems */
.unauth-layout {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    width: 100%;
    padding: 24px;
    z-index: 1;
    position: relative;
}

.container {
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* App Layout for authenticated screen */
.auth-layout {
    display: flex;
    min-height: 100vh;
    width: 100%;
    z-index: 1;
    position: relative;
}

/* Sidebar navigation - Slimmer & cleaner dashboard style */
.sidebar {
    width: 240px;
    height: 100vh;
    background: rgba(10, 15, 30, 0.7);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-right: 1px solid var(--card-border);
    display: flex;
    flex-direction: column;
    padding: 30px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    transition: var(--transition-smooth);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
    padding-left: 8px;
}

.sidebar-logo {
    max-width: 80px;
    height: auto;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.sidebar-title {
    font-size: 18px;
    font-weight: 800;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 0.5px;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition-smooth);
    border: 1px solid transparent;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
    transform: translateX(4px);
}

.nav-item.active {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.25);
}

.nav-item.active:hover {
    transform: none;
}

.nav-icon {
    width: 18px;
    height: 18px;
}

.sidebar-footer {
    margin-top: auto;
}

/* Mobile toggle button */
.menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 13px;
    left: 16px;
    width: 44px;
    height: 44px;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    cursor: pointer;
    z-index: 150;
    color: var(--text-primary);
    transition: var(--transition-smooth);
}

.menu-toggle:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--accent-color);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 90;
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Professional Header Bar (Bootstrap Dashboard Pro style) */
.header-bar {
    width: 100%;
    height: 70px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 40px;
    background: rgba(10, 15, 30, 0.5);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-bottom: 1px solid var(--card-border);
    position: sticky;
    top: 0;
    z-index: 90;
}

.header-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.header-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-user .avatar-mini {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-gradient);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 15px;
    font-weight: 800;
    color: white;
    box-shadow: 0 4px 8px rgba(99, 102, 241, 0.2);
    cursor: pointer;
    background-size: cover;
    background-position: center;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.header-user .name-mini {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.header-user .role-mini {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 6px;
    border-radius: 6px;
}

/* Main content area */
.main-content {
    flex: 1;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.content-body {
    flex: 1;
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.view-section {
    width: 100%;
    max-width: 640px;
    display: none;
}

.view-section.active {
    display: block;
    animation: fadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* Interactive Profile Avatar (Upload style) */
.profile-avatar-container {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}

.profile-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    border: 3px solid rgba(167, 139, 250, 0.4);
    transition: var(--transition-smooth);
    background: var(--primary-gradient);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 40px;
    font-weight: 800;
    color: white;
    background-size: cover;
    background-position: center;
}

.profile-avatar:hover {
    border-color: var(--accent-color);
    transform: scale(1.03);
}

.avatar-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.85);
    padding: 4px 0;
    font-size: 9px;
    font-weight: 700;
    color: var(--accent-color);
    text-transform: uppercase;
    text-align: center;
    opacity: 0;
    transition: var(--transition-smooth);
}

.profile-avatar:hover .avatar-overlay {
    opacity: 1;
}

/* Cards */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 28px;
    padding: 40px 30px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4), 
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
    width: 100%;
}

/* Form inputs & layout */
.form-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 12px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    transition: var(--transition-smooth);
    outline: none;
}

.form-input:focus {
    border-color: var(--accent-color);
    background: rgba(255, 255, 255, 0.04);
    box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.15);
}

/* Buttons */
.btn {
    width: 100%;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    padding: 15px 24px;
    border-radius: 12px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    transition: var(--transition-smooth);
    border: none;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 12px 28px rgba(99, 102, 241, 0.5);
    transform: translateY(-2px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    border: 1px solid var(--card-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.btn-tertiary {
    background: transparent;
    color: var(--accent-color);
    border: 1px dashed rgba(167, 139, 250, 0.3);
}

.btn-tertiary:hover {
    background: rgba(167, 139, 250, 0.05);
    border-color: var(--accent-color);
    transform: translateY(-2px);
}

.btn-danger {
    background: linear-gradient(135deg, #f87171 0%, #ef4444 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    box-shadow: 0 8px 20px rgba(239, 68, 68, 0.4);
    transform: translateY(-2px);
}

/* Logo & unauth layout card */
.logo-container {
    margin-bottom: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.logo {
    max-width: 160px;
    height: auto;
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.5));
    transition: var(--transition-smooth);
}

.logo:hover {
    transform: scale(1.05);
    filter: drop-shadow(0 12px 24px rgba(167, 139, 250, 0.3));
}

.keycloak-card {
    width: 100%;
}

.kc-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

.kc-header.error {
    color: var(--danger-color);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 600;
    margin-bottom: 8px;
}

.kc-icon {
    width: 20px;
    height: 20px;
}

.kc-desc.error-text {
    font-size: 13px;
    color: #fca5a5;
    line-height: 1.5;
}

/* Footer (unauth only) */
.unauth-layout footer {
    text-align: center;
    font-size: 11px;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
    opacity: 0.8;
}

/* Responsiveness and Desktop overrides */
@media (max-width: 768px) {
    .auth-layout {
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        box-shadow: 20px 0 40px rgba(0, 0, 0, 0.5);
        z-index: 100;
        width: 240px;
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: block;
    }

    .menu-toggle {
        display: flex;
    }

    .header-bar {
        padding: 0 16px 0 76px;
    }

    .content-body {
        padding: 24px 16px;
    }

    .card {
        padding: 30px 20px;
    }

    .header-user .name-mini,
    .header-user .role-mini {
        display: none;
    }
}

/* Meetings & Calendar styles */
.meetings-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    margin-top: 16px;
}

.meeting-card {
    position: relative;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: var(--transition-smooth);
    width: 100%;
}

.meeting-card:hover {
    transform: translateY(-3px);
    border-color: rgba(167, 139, 250, 0.2);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
}

.meeting-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 12px;
}

.meeting-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.meeting-date {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-top: 4px;
}

.degree-parts {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
}

.degree-part {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid rgba(255, 255, 255, 0.03);
    position: relative;
    overflow: hidden;
}

.degree-part.locked {
    background: rgba(239, 68, 68, 0.02);
    border-color: rgba(239, 68, 68, 0.08);
}

.degree-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.degree-badge {
    font-size: 9px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-apprenti {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-compagnon {
    background: rgba(59, 130, 246, 0.1);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.badge-maitre {
    background: rgba(139, 92, 246, 0.1);
    color: var(--accent-color);
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.locked-message {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    font-style: italic;
    font-weight: 500;
    padding: 4px 0;
}

.locked-icon {
    width: 14px;
    height: 14px;
    color: var(--danger-color);
}

.degree-content {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.5;
    white-space: pre-wrap;
}

.meeting-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 8px;
}

.btn-icon {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: var(--transition-smooth);
    border: none;
    font-family: inherit;
}

.btn-icon-edit {
    background: rgba(59, 130, 246, 0.1);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.btn-icon-edit:hover {
    background: rgba(59, 130, 246, 0.2);
}

.btn-icon-delete {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-icon-delete:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* Sub-elements inside a meeting card */
.elements-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
    border-top: 1px dashed rgba(255, 255, 255, 0.08);
    padding-top: 12px;
}

.element-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 14px;
    position: relative;
    transition: var(--transition-smooth);
}

.element-item:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(167, 139, 250, 0.2);
}

.element-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    flex-wrap: wrap;
    gap: 6px;
}

.element-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.element-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 8px;
    white-space: pre-wrap;
}

.element-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    flex-wrap: wrap;
    gap: 8px;
}

.doc-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--accent-color);
    text-decoration: none;
    background: rgba(167, 139, 250, 0.1);
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid rgba(167, 139, 250, 0.2);
    transition: var(--transition-smooth);
    font-weight: 500;
}

.doc-link:hover {
    background: rgba(167, 139, 250, 0.2);
    transform: translateY(-1px);
}

.doc-link svg {
    width: 12px;
    height: 12px;
}

/* Warnings and Locked states */
.hidden-elements-warning {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 10px 14px;
    margin-top: 8px;
    font-style: italic;
}

.hidden-elements-warning svg {
    width: 14px;
    height: 14px;
    color: var(--danger-color);
    flex-shrink: 0;
}

.element-actions {
    display: flex;
    gap: 6px;
}

.btn-element-action {
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    font-family: inherit;
    transition: var(--transition-smooth);
}

.btn-element-edit {
    background: rgba(59, 130, 246, 0.1);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.btn-element-edit:hover {
    background: rgba(59, 130, 246, 0.2);
}

.btn-element-delete {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-element-delete:hover {
    background: rgba(239, 68, 68, 0.2);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

@media (min-width: 640px) {
    .form-grid-2 {
        grid-template-columns: 1fr 1fr;
    }
}


