/**
 * Auth Module - SSO Login/Logout Styles
 */

/* ===== User Menu (Logged In State) ===== */
.user-menu {
    position: relative;
    display: flex;
    align-items: center;
}

.user-menu-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border: none;
    border-radius: var(--radius-full, 50px);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    transition: all 0.3s ease;
    white-space: nowrap;
    max-width: 220px;
}

.user-menu-toggle:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg, 0 10px 25px rgba(0,0,0,0.15));
}

.user-menu-toggle .user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    flex-shrink: 0;
}

.user-menu-toggle .user-display-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-menu-toggle .chevron-icon {
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.user-menu.active .chevron-icon {
    transform: rotate(180deg);
}

/* Dropdown */
.user-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    min-width: 240px;
    background: white;
    border-radius: var(--radius-xl, 16px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.25s ease;
    z-index: 1000;
    overflow: hidden;
}

.user-menu.active .user-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-dropdown-header {
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
}

.user-dropdown-header .user-full-name {
    font-weight: 600;
    font-size: 0.9375rem;
    margin-bottom: 0.125rem;
}

.user-dropdown-header .user-email {
    font-size: 0.8125rem;
    opacity: 0.85;
    word-break: break-all;
}

.user-dropdown-header .user-role-badge {
    display: inline-block;
    margin-top: 0.5rem;
    padding: 0.125rem 0.5rem;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.user-dropdown-body {
    padding: 0.5rem 0;
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    color: var(--text-primary, #212121);
    text-decoration: none;
    font-size: 0.875rem;
    transition: background 0.2s ease;
    border: none;
    background: none;
    width: 100%;
    cursor: pointer;
    font-family: inherit;
}

.user-dropdown-item:hover {
    background: var(--bg-secondary, #fafafa);
}

.user-dropdown-item svg {
    width: 18px;
    height: 18px;
    color: var(--text-secondary, #616161);
    flex-shrink: 0;
}

.user-dropdown-divider {
    height: 1px;
    background: var(--bg-tertiary, #f5f5f5);
    margin: 0.25rem 0;
}

.user-dropdown-item.logout-item {
    color: #c62828;
}

.user-dropdown-item.logout-item svg {
    color: #c62828;
}

.user-dropdown-item.logout-item:hover {
    background: #ffebee;
}

/* ===== SSO Login Button (replaces old modal login) ===== */
.btn-sso-login {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.75rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border: none;
    border-radius: var(--radius-full, 50px);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    transition: all 0.3s ease;
    text-decoration: none;
}

.btn-sso-login:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg, 0 10px 25px rgba(0,0,0,0.15));
    color: white;
    text-decoration: none;
}

.btn-sso-login svg {
    width: 20px;
    height: 20px;
}

/* ===== Auth Error/Success Page ===== */
.auth-message-container {
    max-width: 480px;
    margin: 4rem auto;
    padding: 2.5rem;
    text-align: center;
    background: white;
    border-radius: var(--radius-2xl, 20px);
    box-shadow: var(--shadow-md, 0 4px 15px rgba(0,0,0,0.1));
}

.auth-message-container .auth-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-message-container .auth-icon.success {
    background: #e8f5e9;
    color: #2e7d32;
}

.auth-message-container .auth-icon.error {
    background: #ffebee;
    color: #c62828;
}

.auth-message-container h2 {
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary, #212121);
}

.auth-message-container p {
    color: var(--text-secondary, #616161);
    margin-bottom: 1.5rem;
}

/* ===== Welcome Page ===== */
.welcome-page {
    max-width: 900px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.welcome-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.welcome-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color, #1a237e) 0%, var(--secondary-color, #0277bd) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
    margin: 0 auto 1rem;
    box-shadow: 0 8px 25px rgba(26, 35, 126, 0.3);
}

.welcome-header h1 {
    font-size: 2rem;
    margin-bottom: 0.25rem;
    background: linear-gradient(135deg, var(--primary-color, #1a237e) 0%, var(--secondary-color, #0277bd) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary, #616161);
}

.info-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    margin-bottom: 1.5rem;
    overflow: hidden;
    border: 1px solid var(--bg-tertiary, #f5f5f5);
}

.info-card h2 {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 1rem 1.5rem;
    margin: 0;
    font-size: 1.0625rem;
    font-weight: 600;
    background: var(--bg-secondary, #fafafa);
    border-bottom: 1px solid var(--bg-tertiary, #f5f5f5);
    color: var(--text-primary, #212121);
}

.info-card h2 svg {
    color: var(--secondary-color, #0277bd);
    flex-shrink: 0;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 0.75rem 1.5rem;
    text-align: left;
    border-bottom: 1px solid var(--bg-tertiary, #f5f5f5);
    font-size: 0.875rem;
    vertical-align: top;
}

.data-table th {
    width: 200px;
    font-weight: 600;
    color: var(--text-primary, #212121);
    background: var(--bg-secondary, #fafafa);
    white-space: nowrap;
}

.data-table td {
    color: var(--text-secondary, #616161);
    word-break: break-all;
}

.data-table tr:last-child th,
.data-table tr:last-child td {
    border-bottom: none;
}

.role-badge {
    display: inline-block;
    padding: 0.2rem 0.625rem;
    background: linear-gradient(135deg, var(--primary-color, #1a237e) 0%, var(--secondary-color, #0277bd) 100%);
    color: white;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-right: 0.375rem;
    margin-bottom: 0.25rem;
}

.json-block {
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 1rem 1.5rem;
    margin: 0;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.8125rem;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
    border-radius: 0;
}

.token-value {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.8125rem;
    word-break: break-all;
    line-height: 1.5;
    color: var(--text-secondary, #616161);
}

.text-muted {
    color: var(--text-light, #9e9e9e);
    padding: 1.5rem;
    text-align: center;
}

.welcome-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
    margin-bottom: 2rem;
}

.btn-outline {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 2rem;
    background: transparent;
    color: var(--primary-color, #1a237e);
    border: 2px solid var(--primary-color, #1a237e);
    border-radius: 50px;
    cursor: pointer;
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: inherit;
    transition: all 0.3s ease;
    text-decoration: none;
}

.btn-outline:hover {
    background: var(--primary-color, #1a237e);
    color: white;
    text-decoration: none;
}

/* ===== Mobile Responsive ===== */
@media (max-width: 768px) {
    .user-menu-toggle {
        padding: 0.4rem 0.75rem;
        font-size: 0.8125rem;
        max-width: 160px;
    }

    .user-menu-toggle .user-display-name {
        display: none;
    }

    .user-menu-toggle .user-avatar {
        width: 32px;
        height: 32px;
        font-size: 0.875rem;
    }

    .user-dropdown {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        min-width: 100%;
        border-radius: var(--radius-xl, 16px) var(--radius-xl, 16px) 0 0;
        transform: translateY(100%);
    }

    .user-menu.active .user-dropdown {
        transform: translateY(0);
    }

    .btn-sso-login {
        padding: 0.6rem 1.25rem;
        font-size: 0.8125rem;
    }

    .btn-sso-login .btn-login-text {
        display: none;
    }

    .auth-message-container {
        margin: 2rem 1rem;
        padding: 1.5rem;
    }

    .welcome-page {
        margin: 1rem auto;
    }

    .welcome-header h1 {
        font-size: 1.5rem;
    }

    .welcome-avatar {
        width: 64px;
        height: 64px;
        font-size: 1.5rem;
    }

    .data-table th {
        width: 120px;
        font-size: 0.8125rem;
    }

    .data-table th,
    .data-table td {
        padding: 0.625rem 1rem;
    }

    .info-card h2 {
        font-size: 0.9375rem;
        padding: 0.875rem 1rem;
    }

    .welcome-actions {
        flex-direction: column;
        align-items: center;
    }

    .json-block {
        font-size: 0.75rem;
        padding: 0.75rem 1rem;
    }
}

@media (max-width: 480px) {
    .user-dropdown {
        min-width: 100%;
    }

    .user-dropdown-header {
        padding: 1rem;
    }

    .user-dropdown-item {
        padding: 0.75rem 1rem;
    }
}

/* Mobile nav user item */
.mobile-only .mobile-user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
}

.mobile-only .mobile-user-info .user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
}

.mobile-only .mobile-user-info span {
    font-weight: 500;
}

/* ===== Moodle Button - Welcome Page ===== */
.btn-moodle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 2rem;
    background: linear-gradient(135deg, #f98012 0%, #f57c00 100%);
    color: #fff;
    border: none;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(249, 128, 18, 0.3);
}

.btn-moodle:hover {
    background: linear-gradient(135deg, #e67300 0%, #ef6c00 100%);
    color: #fff;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(249, 128, 18, 0.45);
}

.btn-moodle svg {
    flex-shrink: 0;
}

/* ===== Moodle Item - User Dropdown ===== */
.user-dropdown-item.moodle-item {
    color: #f57c00;
}

.user-dropdown-item.moodle-item:hover {
    background: #fff3e0;
    color: #e65100;
}

.user-dropdown-item.moodle-item svg {
    stroke: #f57c00;
}

.user-dropdown-item.moodle-item:hover svg {
    stroke: #e65100;
}

/* Dropdown overlay for mobile */
.user-dropdown-overlay {
    display: none;
}

@media (max-width: 768px) {
    .user-dropdown-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 999;
    }

    .user-menu.active .user-dropdown-overlay {
        display: block;
    }
}
