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

:root {
    --primary-color: #0066cc;
    --primary-hover: #0052a3;
    --secondary-color: #6c757d;
    --secondary-hover: #5a6268;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --background: #f8f9fa;
    --surface: #ffffff;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --border-color: #dee2e6;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
        'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
        sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header Styles */
header {
    text-align: center;
    padding: 40px 20px;
    background: var(--surface);
    border-radius: 12px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    color: var(--primary-color);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Main Content */
main {
    flex: 1;
}

/* Loading State */
.loading {
    text-align: center;
    padding: 60px 20px;
}

.spinner {
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error State */
.error {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 8px;
    padding: 30px;
    margin: 20px 0;
}

.error h2 {
    color: #856404;
    margin-bottom: 10px;
}

#error-message {
    color: #856404;
    white-space: pre-wrap;
    font-family: monospace;
    font-size: 0.9rem;
}

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

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

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

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: var(--secondary-hover);
}

.btn-copy {
    padding: 6px 12px;
    font-size: 0.85rem;
    margin-left: 10px;
}

.btn-success {
    background: var(--success-color);
}

/* Unauthenticated View */
.auth-section {
    background: var(--surface);
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
}

.auth-section h2 {
    margin-bottom: 20px;
    color: var(--text-primary);
}

.auth-section p {
    margin-bottom: 15px;
    color: var(--text-secondary);
}

.info-section {
    background: var(--surface);
    border-radius: 12px;
    padding: 30px;
    box-shadow: var(--shadow);
}

.info-section h3 {
    margin-bottom: 15px;
    color: var(--text-primary);
}

.info-section ul {
    list-style: none;
    padding: 0;
}

.info-section li {
    padding: 8px 0;
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Authenticated View */
.auth-header {
    background: var(--surface);
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 20px;
}

.avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
}

.user-email {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Token Sections */
.token-sections {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.token-section {
    background: var(--surface);
    border-radius: 12px;
    padding: 30px;
    box-shadow: var(--shadow);
}

.token-section h3 {
    margin-bottom: 15px;
    color: var(--text-primary);
    font-size: 1.5rem;
}

.token-section details > summary {
    cursor: pointer;
    list-style: none;
    margin-bottom: 0;
    user-select: none;
}

.token-section details > summary::-webkit-details-marker {
    display: none;
}

.token-section details > summary::before {
    content: '▶ ';
    font-size: 0.85em;
    color: var(--text-secondary);
    transition: transform 0.15s;
    display: inline-block;
}

.token-section details[open] > summary::before {
    content: '▼ ';
}

.token-section h4 {
    margin: 20px 0 10px;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.token-info {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.badge-valid {
    background: #d4edda;
    color: #155724;
}

.badge-expired {
    background: #f8d7da;
    color: #721c24;
}

.expiration {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.token-content {
    margin-top: 15px;
}

/* Token Display */
.json-display {
    background: #282c34;
    color: #abb2bf;
    padding: 20px;
    border-radius: 8px;
    overflow-x: auto;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    max-height: 500px;
    overflow-y: auto;
}

/* JSON Syntax Highlighting */
.json-key {
    color: #61afef;
}

.json-string {
    color: #98c379;
}

.json-number {
    color: #d19a66;
}

.json-boolean {
    color: #c678dd;
}

.json-null {
    color: #e06c75;
}

/* Raw Token Display */
.token-raw {
    display: flex;
    align-items: center;
    gap: 10px;
}

.token-string {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    overflow-x: auto;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85rem;
    flex: 1;
    word-break: break-all;
    max-height: 150px;
    overflow-y: auto;
}

/* Footer */
footer {
    text-align: center;
    padding: 30px 20px;
    margin-top: 40px;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }

    .auth-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .user-info {
        flex-direction: column;
        align-items: flex-start;
    }

    .token-section {
        padding: 20px;
    }

    .json-display {
        font-size: 0.8rem;
        padding: 15px;
    }
}

/* Scrollbar Styling */
.json-display::-webkit-scrollbar,
.token-string::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.json-display::-webkit-scrollbar-track {
    background: #1e2227;
}

.json-display::-webkit-scrollbar-thumb {
    background: #4b5263;
    border-radius: 4px;
}

.json-display::-webkit-scrollbar-thumb:hover {
    background: #5c6370;
}

.token-string::-webkit-scrollbar-track {
    background: #e9ecef;
}

.token-string::-webkit-scrollbar-thumb {
    background: #adb5bd;
    border-radius: 4px;
}

.token-string::-webkit-scrollbar-thumb:hover {
    background: #868e96;
}

/* SSO Session & Remember Me Section */
.session-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.info-card {
    background: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
}

.info-card h4 {
    margin: 0 0 15px 0;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
}

.info-content {
    font-size: 0.9rem;
}

.info-item {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.info-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.info-item strong {
    display: block;
    color: var(--text-primary);
    margin-bottom: 4px;
    font-size: 0.85rem;
    font-weight: 600;
}

.info-item span,
.info-item code {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.info-item code {
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85rem;
    display: inline-block;
}

.session-id {
    word-break: break-all;
    display: block;
    margin-top: 4px;
}

.info-note {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 6px;
    padding: 10px 12px;
    margin-top: 12px;
    font-size: 0.85rem;
    color: #856404;
}

.info-note strong {
    color: #856404;
    display: inline;
}

.expiration-time {
    color: var(--primary-color);
    font-weight: 600;
}

/* Help Section */
.help-section {
    margin-top: 25px;
    background: #e7f3ff;
    border: 1px solid #b3d9ff;
    border-radius: 8px;
    padding: 20px;
}

.help-section h4 {
    margin: 0 0 15px 0;
    color: var(--primary-color);
    font-size: 1.1rem;
}

.help-content {
    font-size: 0.9rem;
    line-height: 1.7;
}

.help-content p {
    margin-bottom: 15px;
}

.help-content p:last-child {
    margin-bottom: 0;
}

.help-content ul,
.help-content ol {
    margin: 10px 0 15px 20px;
}

.help-content li {
    margin-bottom: 8px;
}

.help-content code {
    background: #cfe2ff;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85rem;
    color: #004085;
}

.help-content strong {
    color: #004085;
}

/* Console Command Display */
.console-command {
    background: #1e1e1e;
    border: 1px solid #333;
    border-radius: 6px;
    padding: 12px;
    margin: 15px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.console-command code {
    flex: 1;
    background: transparent;
    color: #d4d4d4;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85rem;
    padding: 0;
    word-break: break-all;
    white-space: pre-wrap;
}

.console-command .btn-copy {
    flex-shrink: 0;
    padding: 6px 12px;
    font-size: 0.8rem;
}

.console-note {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: -10px;
    margin-bottom: 15px;
}

/* Responsive adjustments for session section */
@media (max-width: 768px) {
    .session-info-grid {
        grid-template-columns: 1fr;
    }
    
    .info-card {
        padding: 15px;
    }
    
    .help-section {
        padding: 15px;
    }
}
