/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header Styles */
header {
    background: linear-gradient(135deg, #375DA4 0%, #4A825A 100%);
    color: white;
    padding: 8px 16px;
    border-radius: 10px;
    margin-bottom: 16px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    gap: 10px;
    min-width: 0;
}

header h1 {
    font-size: 1.1rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.main-nav {
    display: flex;
    gap: 10px;
}

.nav-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 8px 16px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
}

.nav-btn.active {
    background: rgba(255, 255, 255, 0.9);
    color: #375DA4;
    border-color: rgba(255, 255, 255, 0.9);
}

.user-info span {
    font-weight: 500;
    color: rgba(255, 255, 255, 0.92);
}

/* Separator between module nav and account area */
.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    border-left: 1px solid rgba(255, 255, 255, 0.25);
    padding-left: 14px;
}

/* Profile button styled as an account control, not a module tab */
.nav-btn-account {
    background: rgba(255, 255, 255, 0.08) !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    font-size: 0.82rem !important;
    padding: 6px 12px !important;
    opacity: 0.85;
}

.nav-btn-account:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.18) !important;
}

.nav-btn-account.active {
    background: rgba(255, 255, 255, 0.9) !important;
    color: #375DA4 !important;
    opacity: 1;
}

#main-header #logout-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

#main-header #logout-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Section Styles */
.section {
    background: white;
    border-radius: 10px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.section h2 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 1.5rem;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 10px;
}

/* Auth Section Styles */
.auth-container {
    max-width: 500px;
    margin: 0 auto;
    text-align: center;
}

.auth-header {
    margin-bottom: 30px;
}

.auth-header h1 {
    color: #667eea;
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.auth-header p {
    color: #666;
    font-size: 1.1rem;
}

.auth-tabs {
    display: flex;
    margin-bottom: 30px;
    border-bottom: 1px solid #e0e0e0;
    justify-content: center;
}

.auth-form {
    text-align: left;
}

/* Tab Styles */
.tabs, .auth-tabs {
    display: flex;
    margin-bottom: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.tab-btn {
    background: none;
    border: none;
    padding: 12px 24px;
    cursor: pointer;
    font-size: 1rem;
    color: #666;
    border-bottom: 2px solid transparent;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    color: #667eea;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
    font-weight: 500;
}

/* Form Styles */
.form-container {
    max-width: 400px;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #555;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 5px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.form-group textarea {
    resize: vertical;
    font-family: 'Courier New', monospace;
}

/* Button Styles */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.btn.is-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn.is-loading:hover {
    transform: none;
    box-shadow: none;
}

.btn.is-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 18px;
    height: 18px;
    margin: -9px 0 0 -9px;
    border: 2px solid rgba(255, 255, 255, 0.7);
    border-top-color: transparent;
    border-radius: 50%;
    animation: btn-spin 0.8s linear infinite;
}

@keyframes btn-spin {
    to {
        transform: rotate(360deg);
    }
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.btn-impersonation {
    background: #ff9800;
    color: #fff;
    font-weight: 600;
    white-space: nowrap;
}

.btn-impersonation:hover {
    background: #e68900;
}

.btn-info {
    background: #17a2b8;
    color: white;
}

/* Passkey / WebAuthn button */
.btn-passkey {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: white;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid rgba(255,255,255,0.12);
}

.btn-passkey:hover {
    background: linear-gradient(135deg, #2d2d5a 0%, #1a2f56 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(26,26,46,0.4);
}

/* Passkey divider in login form */
.passkey-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 0 12px;
    color: #aaa;
    font-size: 0.85rem;
}

.passkey-divider::before,
.passkey-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e0e0e0;
}

/* Passkey section inside profile */
.passkey-profile-section {
    margin-top: 28px;
    padding-top: 20px;
    border-top: 2px solid #f0f0f0;
}

.passkey-profile-section h3 {
    color: #444;
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.passkey-info {
    color: #666;
    font-size: 0.88rem;
    margin-bottom: 14px;
    line-height: 1.5;
}

.btn-info:hover {
    background: #138496;
    transform: translateY(-2px);
}

.btn-warning {
    background: #ffc107;
    color: #212529;
}

.btn-warning:hover {
    background: #e0a800;
    transform: translateY(-2px);
}

#reset-password-btn {
    margin-top: 8px;
}

/* API Method Styles */
.api-method {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    border-left: 4px solid #667eea;
}

.api-method h3 {
    color: #667eea;
    margin-bottom: 10px;
}

.api-method p {
    color: #666;
    margin-bottom: 15px;
}

.api-call-section {
    background: white;
    padding: 20px;
    border-radius: 5px;
    margin-top: 15px;
}

.api-call-section h4 {
    margin-bottom: 15px;
    color: #555;
}

/* User Details Styles */
.user-details {
    background: white;
    padding: 20px;
    border-radius: 5px;
    border: 1px solid #e0e0e0;
}

.user-details p {
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
}

.user-details strong {
    color: #667eea;
}

/* Response Section Styles */
#response-container {
    background: #2d3748;
    border-radius: 5px;
    padding: 20px;
    overflow-x: auto;
}

#response-output {
    color: #e2e8f0;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.4;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Success/Error Message Styles */
.success-message {
    background: #d4edda;
    color: #155724;
    padding: 12px;
    border-radius: 5px;
    border: 1px solid #c3e6cb;
    margin-bottom: 15px;
}

.error-message {
    background: #f8d7da;
    color: #721c24;
    padding: 12px;
    border-radius: 5px;
    border: 1px solid #f5c6cb;
    margin-bottom: 15px;
}

/* Loading Animation */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #667eea;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .header-content {
        flex-direction: row;
        flex-wrap: nowrap;
        text-align: left;
    }
    
    header h1 {
        font-size: 1rem;
    }
    
    .main-nav {
        order: 0;
        width: auto;
        justify-content: flex-start;
        flex-shrink: 0;
    }
    
    .section {
        padding: 20px;
    }
    
    .form-container {
        max-width: 100%;
    }
    
    .user-details p {
        flex-direction: column;
        gap: 5px;
    }
    
    .auth-header h1 {
        font-size: 2rem;
    }
}

@media (max-width: 480px) {
    .tabs, .auth-tabs {
        flex-direction: column;
    }
    
    .tab-btn {
        border-bottom: 1px solid #e0e0e0;
        border-right: none;
    }
    
    .tab-btn.active {
        border-bottom-color: #667eea;
    }
    
    .main-nav {
        flex-direction: row;
        flex-wrap: wrap;
        width: auto;
        gap: 4px;
    }
    
    .nav-btn {
        width: auto;
        margin-bottom: 0;
        padding: 6px 9px;
        font-size: 0.78rem;
    }

    .header-content {
        flex-wrap: wrap;
        gap: 6px;
        width: 100%;
    }

    .header-content h1 {
        flex: 1 1 100%;
    }

    .user-info {
        width: 100%;
        min-width: 0;
        justify-content: flex-end;
        flex-wrap: wrap;
        gap: 5px;
        padding-left: 0;
        border-left: 0;
    }

    .user-info span {
        margin-right: auto;
        min-width: 0;
        max-width: 36%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    #main-header .btn,
    #main-header .nav-btn {
        max-width: 100%;
        white-space: nowrap;
    }

    #main-header #logout-btn {
        padding: 6px 9px;
        font-size: 0.78rem;
    }

    .profile-container {
        width: 100%;
        max-width: 100%;
        margin: 0;
        padding: 14px;
        overflow-wrap: anywhere;
    }

    .profile-container h2 {
        font-size: 1.2rem;
        margin-bottom: 14px;
    }

    .profile-container .form-row {
        flex-direction: column;
        gap: 0;
        margin-bottom: 0;
    }

    .profile-container .form-group {
        margin-bottom: 12px;
    }

    .profile-container .password-profile-section,
    .profile-container .passkey-profile-section {
        padding: 12px 0;
    }
    
    .auth-header h1 {
        font-size: 1.8rem;
    }
}
