:root {
    --bg-gradient: linear-gradient(135deg, #c9d9ff 0%, #eeedfe 100%);
    --card-bg: rgba(255, 255, 255, 0.7);
    --card-hover: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(112, 114, 240, 0.15);
    --glass-border-focus: rgba(112, 114, 240, 0.4);
    --text-primary: #2f2f2f;
    --text-secondary: #7e8b9b;
    --accent-primary: #7072f0;
    --accent-hover: #6366f1;
    --accent-glow: rgba(112, 114, 240, 0.2);
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --input-bg: #e3e2f0;
    --inner-bg: rgba(255, 255, 255, 0.5);
}

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

body {
    background: var(--bg-gradient);
    color: var(--text-primary);
    font-family: 'Plus Jakarta Sans', sans-serif;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Ambient Glow Backgrounds */
.ambient-glow-1 {
    position: absolute;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.12) 0%, transparent 70%);
    top: -100px;
    left: -100px;
    pointer-events: none;
    z-index: 0;
}

.ambient-glow-2 {
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(168, 85, 247, 0.08) 0%, transparent 70%);
    bottom: -200px;
    right: -100px;
    pointer-events: none;
    z-index: 0;
}

/* Container & Navigation */
header {
    width: 100%;
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    z-index: 10;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: inherit;
}

.logo-symbol {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #818cf8 0%, #6366f1 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.25rem;
    color: #fff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    font-family: 'Outfit', sans-serif;
}

.logo-text {
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.system-badge {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: #34d399;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.badge-dot {
    width: 8px;
    height: 8px;
    background-color: var(--success-color);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--success-color);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Main Section Wrapper */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 2rem;
    position: relative;
    z-index: 5;
    overflow-y: auto;
}

/* 1. LOGIN STATE CSS */
.login-section {
    width: 100%;
    max-width: 400px;
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2.5rem;
    box-shadow: 0 5px 15px rgba(105, 105, 105, 0.3);
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    display: none;
    flex-direction: column;
    margin: auto;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.5;
}

.form-group {
    margin-bottom: 1.5rem;
    position: relative;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.input-wrapper {
    position: relative;
}

.form-input {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.875rem 1rem;
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.submit-btn {
    width: 100%;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 1rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
    margin-top: 0.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
}

.submit-btn:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
    transform: translateY(-1px);
}

.submit-btn:active {
    transform: translateY(0);
}

.submit-btn:disabled {
    background: rgba(99, 102, 241, 0.5);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Spinner for loading */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}

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

/* Alert notifications */
.alert {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #f87171;
    padding: 0.875rem 1rem;
    border-radius: 12px;
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
    display: none;
    align-items: center;
    gap: 0.5rem;
    animation: fadeIn 0.3s ease;
}

/* 2. DASHBOARD STATE CSS */
.dashboard-section {
    width: 100%;
    max-width: 1100px;
    display: none;
    animation: fadeIn 0.8s ease;
    margin: auto;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.welcome-title h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.welcome-title p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

.logout-btn {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #f87171;
    padding: 0.65rem 1.25rem;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.logout-btn:hover {
    background: var(--error-color);
    color: white;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

/* Grid Layout for Cards */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
}

@media (max-width: 900px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

.panel-card {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2rem;
    backdrop-filter: blur(16px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    margin-bottom: 2rem;
}

.panel-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 0.75rem;
}

/* Profile details list */
.profile-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

@media (max-width: 550px) {
    .profile-grid {
        grid-template-columns: 1fr;
    }
}

.profile-item {
    background: var(--inner-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1rem 1.25rem;
}

.profile-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.profile-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.badge-status-active {
    display: inline-block;
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #34d399;
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 700;
}

/* Connected Apps cards */
.apps-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
}

@media (max-width: 600px) {
    .apps-container {
        grid-template-columns: 1fr;
    }
}

.app-card {
    background: var(--inner-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.5rem;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.app-card:hover {
    background: var(--card-hover);
    border-color: var(--glass-border-focus);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.1);
}

.app-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
    margin-bottom: 1rem;
}

.doreh-icon {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.teqic-icon {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.app-name {
    font-weight: 600;
    font-size: 1.05rem;
    margin-bottom: 0.25rem;
}

.app-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 1.25rem;
}

.app-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--accent-primary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    transition: color 0.2s;
    margin-top: auto;
}

.app-link:hover {
    color: #818cf8;
}

/* Timeline for Security Audit Logs */
.timeline {
    position: relative;
    padding-left: 1.5rem;
    border-left: 1px dashed var(--glass-border);
    margin-left: 0.5rem;
}

.timeline-item {
    position: relative;
    margin-bottom: 1.5rem;
}

.timeline-item::before {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    left: -21px;
    top: 4px;
    background: var(--accent-primary);
    box-shadow: 0 0 6px var(--accent-primary);
}

.timeline-item.failed::before {
    background: var(--error-color);
    box-shadow: 0 0 6px var(--error-color);
}

.timeline-item.success::before {
    background: var(--success-color);
    box-shadow: 0 0 6px var(--success-color);
}

.timeline-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.15rem;
}

.timeline-action {
    font-size: 0.875rem;
    font-weight: 600;
}

.timeline-detail {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

/* Stats items */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.stat-item {
    background: var(--inner-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    text-align: center;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.stat-val {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 0.15rem;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
    border-top: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    z-index: 10;
}

/* Transitions & Animations */
@keyframes slideUp {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Responsive styling */
@media (max-width: 480px) {
    body { padding: 0; }
    header { padding: 1rem; }
    main { padding: 1rem; }
    .login-section { padding: 2rem 1.5rem; border-radius: 20px; }
    footer { padding: 1.5rem 1rem; }
}

.sso-icon {
    height: 80px;
    width: auto;
    margin-bottom: 10px;
}

.logo-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.alert-icon {
    font-size: 1.125rem;
}

/* Dismissible */
.alert-close {
    display: none;
}

.alert-dismissible .alert-close {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;

    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;

    padding: 2px;
    margin-left: auto;

    opacity: .7;
    transition: opacity .2s ease;
}

.alert-close:hover {
    opacity: 1;
}

.alert-close i {
    font-size: 18px;
}
