/* ─── Reset & Base ─── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    /* Primary (Apidel Teal — matches Ticketing) */
    --primary-h: 180;
    --primary-s: 81%;
    --primary-l: 25%;
    --primary: hsl(var(--primary-h), var(--primary-s), var(--primary-l));
    --primary-light: hsl(var(--primary-h), var(--primary-s), 32%);
    --primary-dark: hsl(var(--primary-h), var(--primary-s), 18%);
    --primary-fg: #ffffff;

    /* Neutral */
    --bg: hsl(210, 40%, 98%);
    --fg: hsl(224, 71%, 4%);
    --muted: hsl(220, 14%, 96%);
    --muted-fg: hsl(220, 9%, 46%);
    --border: hsl(220, 13%, 91%);
    --input-border: hsl(220, 13%, 85%);

    /* Semantic */
    --destructive: hsl(0, 84%, 60%);
    --destructive-light: hsl(0, 84%, 96%);
    --success: hsl(142, 76%, 36%);
    --success-light: hsl(142, 76%, 95%);

    /* Radius */
    --radius: 0.75rem;
    --radius-sm: 0.5rem;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);

    /* Font */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-heading: 'Outfit', 'Inter', sans-serif;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--fg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.5;
}

/* ─── Auth Layout ─── */
.auth-layout {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* ─── Brand Panel (Left) ─── */
.brand-panel {
    display: none;
    width: 50%;
    background: var(--primary);
    color: var(--primary-fg);
    padding: 3rem;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

@media (min-width: 1024px) {
    .brand-panel {
        display: flex;
    }
}

.brand-content {
    position: relative;
    z-index: 10;
}

.brand-logo {
    display: inline-flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.95);
    border-radius: var(--radius);
    padding: 0.65rem 1.5rem;
    margin-bottom: 2.5rem;
    box-shadow: var(--shadow-sm);
}

.logo-text {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--primary);
}

.logo-text-dark {
    color: var(--primary);
}

.brand-heading {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1.15;
    margin-bottom: 2rem;
    max-width: 28rem;
    letter-spacing: -0.02em;
}

.feature-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 24rem;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.1rem;
    font-weight: 500;
}

.feature-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.brand-description {
    margin-top: 2rem;
    color: rgba(255, 255, 255, 0.8);
    max-width: 26rem;
    line-height: 1.7;
    font-size: 0.95rem;
}

.brand-footer {
    position: relative;
    z-index: 10;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.55);
}

/* Decorative circles */
.deco-circle {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
}

.deco-circle-1 {
    width: 350px;
    height: 350px;
    bottom: -100px;
    right: -80px;
}

.deco-circle-2 {
    width: 200px;
    height: 200px;
    top: -50px;
    right: 30%;
}

/* ─── Shared View Transitions ─── */
.view-container {
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1), transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.view-hidden {
    opacity: 0 !important;
    transform: translateY(20px) !important;
    pointer-events: none !important;
    visibility: hidden;
}

/* ─── Login Panel & Container ─── */
.login-panel {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #ffffff;
}

.login-container {
    width: 100%;
    max-width: 440px;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 3rem;
    border-radius: calc(var(--radius) * 1.5);
    box-shadow: var(--shadow-lg), 0 0 0 1px var(--border);
    animation: fadeIn 0.8s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ─── Form ─── */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--fg);
    margin-bottom: 0.4rem;
}

.form-group input {
    width: 100%;
    height: 2.75rem;
    padding: 0 0.875rem;
    border: 1px solid var(--input-border);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    color: var(--fg);
    background: #fff;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input::placeholder {
    color: var(--muted-fg);
    opacity: 0.7;
}

.form-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px hsla(var(--primary-h), var(--primary-s), var(--primary-l), 0.12);
}

.form-group input.input-error {
    border-color: var(--destructive);
}

.form-group input.input-error:focus {
    box-shadow: 0 0 0 3px hsla(0, 84%, 60%, 0.12);
}

.field-error {
    display: block;
    font-size: 0.8rem;
    color: var(--destructive);
    margin-top: 0.3rem;
    min-height: 1em;
}

/* Password wrapper */
.password-wrapper {
    position: relative;
}

.password-wrapper input {
    padding-right: 2.75rem;
}

.toggle-password {
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    width: 2.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--muted-fg);
    transition: color 0.15s;
}

.toggle-password:hover {
    color: var(--fg);
}

/* ─── Submit Button ─── */
.btn-submit {
    width: 100%;
    height: 2.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    background: var(--primary);
    color: var(--primary-fg);
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
    margin-top: 0.5rem;
}

.btn-submit:hover:not(:disabled) {
    background: var(--primary-light);
    box-shadow: var(--shadow-md);
}

.btn-submit:active:not(:disabled) {
    transform: scale(0.98);
}

.btn-submit:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

/* Spinner animation */
.spinner {
    display: none;
    width: 1.125rem;
    height: 1.125rem;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

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

/* ─── Apps Section (Post-Login) ─── */
.apps-section {
    margin-top: 1.5rem;
    animation: slideDown 0.3s ease;
}

.apps-section h3 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--fg);
    text-align: center;
}

.apps-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

.app-card {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 1rem 1.25rem;
    background: var(--muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--fg);
    transition: all 0.2s;
    cursor: pointer;
}

.app-card:hover {
    background: #fff;
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.app-card-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: var(--primary-fg);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.app-card-info {
    flex: 1;
}

.app-card-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.app-card-role {
    font-size: 0.8rem;
    color: var(--muted-fg);
    text-transform: capitalize;
}

.app-card-arrow {
    color: var(--muted-fg);
    transition: color 0.2s, transform 0.2s;
}

.app-card:hover .app-card-arrow {
    color: var(--primary);
    transform: translateX(2px);
}

/* Logout */
.btn-logout {
    display: block;
    width: 100%;
    margin-top: 1.25rem;
    padding: 0.65rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--muted-fg);
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.btn-logout:hover {
    background: var(--destructive-light);
    border-color: var(--destructive);
    color: var(--destructive);
}

/* ─── Toaster & Toasts ─── */
.toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none;
}

.toast {
    background: #ffffff;
    color: var(--fg);
    padding: 0.875rem 1.25rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg), 0 0 0 1px var(--border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 280px;
    max-width: 400px;
    font-size: 0.875rem;
    font-weight: 500;
    pointer-events: auto;
    animation: toast-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    transition: all 0.3s ease;
}

/* ─── Form Elements Focus States ─── */
.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px hsla(var(--primary-h), var(--primary-s), var(--primary-l), 0.1);
}

.btn-submit:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px hsla(var(--primary-h), var(--primary-s), var(--primary-l), 0.2);
}

.toast-success {
    border-left: 4px solid var(--success);
}

.toast-error {
    border-left: 4px solid var(--destructive);
}

.toast-icon {
    flex-shrink: 0;
}

.toast-success .toast-icon {
    color: var(--success);
}

.toast-error .toast-icon {
    color: var(--destructive);
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateX(100%);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast-out {
    opacity: 0;
    transform: translateX(100%);
}

/* ─── Dashboard Transition ─── */
.view-container {
    width: 100%;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.view-hidden {
    display: none;
    opacity: 0;
    transform: translateY(10px);
}

/* ─── Dashboard View ─── */
.dashboard-panel {
    width: 100%;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    background: radial-gradient(circle at top right, hsl(var(--primary-h), 20%, 96%), var(--bg));
    position: relative;
}

.dashboard-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(to right, var(--primary), var(--primary-light));
}

.dashboard-container {
    width: 100%;
    max-width: 900px;
    z-index: 10;
}

.dashboard-header {
    text-align: center;
    margin-bottom: 4rem;
    animation: fadeInDown 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dashboard-header h2 {
    font-family: var(--font-heading);
    font-size: 2.75rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, var(--fg) 10%, var(--primary) 90%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.dashboard-header p {
    color: var(--muted-fg);
    font-size: 1.2rem;
    font-weight: 500;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 2rem;
}

/* Enhanced app cards for dashboard */
.app-card-large {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) * 1.5);
    padding: 3rem 2rem;
    text-decoration: none;
    color: var(--fg);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1.5rem;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.app-card-large::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 0;
    background: var(--primary);
    transition: height 0.3s ease;
    opacity: 0.1;
}

.app-card-large:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-lg), 0 0 0 4px hsla(var(--primary-h), var(--primary-s), var(--primary-l), 0.05);
    transform: translateY(-8px);
}

.app-card-large:hover::after {
    height: 100%;
}

.app-card-large .icon-box {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-size: 1.75rem;
    font-weight: 800;
    box-shadow: 0 8px 16px -4px hsla(var(--primary-h), var(--primary-s), var(--primary-l), 0.3);
    transition: transform 0.3s ease;
}

.app-card-large:hover .icon-box {
    transform: scale(1.1) rotate(5deg);
}

.app-card-large h4 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.app-card-large .role-tag {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background: var(--muted);
    padding: 0.4rem 1rem;
    border-radius: 100px;
    color: var(--primary);
    transition: all 0.3s ease;
}

.app-card-large:hover .role-tag {
    background: var(--primary);
    color: white;
}

.dashboard-footer {
    margin-top: 5rem;
    display: flex;
    justify-content: center;
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 100px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

/* ─── Responsive ─── */
@media (max-width: 640px) {
    .login-panel {
        padding: 1.5rem;
    }

    .login-header h2 {
        font-size: 1.5rem;
    }
}