/* APX Platform Shell - Custom Styles */
/* Design aligned with APX Website Revamp */
/* Phase 2: Component Styling */

/* ============================================
   Base Styles
   ============================================ */

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--apx-bg-primary, #0a0d12);
}

/* ============================================
   Module Card Styles (SHELL-101)
   ============================================ */

.module-card {
    background: var(--apx-bg-card, #12171e);
    border: 1px solid var(--apx-border, rgba(255, 255, 255, 0.08));
    border-radius: 16px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

/* Animated gradient top border element */
.module-card-border {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Module-specific gradient borders */
.module-card-vault .module-card-border {
    background: linear-gradient(90deg, #3b82f6, #2563eb);
}

.module-card-insight .module-card-border {
    background: linear-gradient(90deg, #10b981, #059669);
}

.module-card-allocator .module-card-border {
    background: linear-gradient(90deg, #8b5cf6, #7c3aed);
}

/* Card hover effects */
.module-card:hover {
    transform: translateY(-4px);
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.5);
}

.module-card:hover .module-card-border {
    transform: scaleX(1);
}

/* Module-specific hover glow shadows */
.module-card-vault:hover {
    box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.5),
                0 0 30px rgba(59, 130, 246, 0.15);
}

.module-card-insight:hover {
    box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.5),
                0 0 30px rgba(16, 185, 129, 0.15);
}

.module-card-allocator:hover {
    box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.5),
                0 0 30px rgba(139, 92, 246, 0.15);
}

/* ============================================
   Module Button Styles (SHELL-102)
   ============================================ */

.module-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.module-btn:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* Vault button - Blue gradient */
.module-btn-vault {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.25),
                0 0 0 0 rgba(59, 130, 246, 0);
}

.module-btn-vault:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.35),
                0 0 20px rgba(59, 130, 246, 0.2);
}

.module-btn-vault:active {
    transform: translateY(0);
}

.module-btn-vault:focus-visible {
    outline-color: #60a5fa;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.25),
                0 0 0 3px rgba(59, 130, 246, 0.3);
}

/* Insight button - Green gradient */
.module-btn-insight {
    background: linear-gradient(135deg, #10b981, #059669);
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.25),
                0 0 0 0 rgba(16, 185, 129, 0);
}

.module-btn-insight:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35),
                0 0 20px rgba(16, 185, 129, 0.2);
}

.module-btn-insight:active {
    transform: translateY(0);
}

.module-btn-insight:focus-visible {
    outline-color: #34d399;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.25),
                0 0 0 3px rgba(16, 185, 129, 0.3);
}

/* Allocator button - Purple gradient */
.module-btn-allocator {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    box-shadow: 0 4px 14px rgba(139, 92, 246, 0.25),
                0 0 0 0 rgba(139, 92, 246, 0);
}

.module-btn-allocator:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.35),
                0 0 20px rgba(139, 92, 246, 0.2);
}

.module-btn-allocator:active {
    transform: translateY(0);
}

.module-btn-allocator:focus-visible {
    outline-color: #a78bfa;
    box-shadow: 0 4px 14px rgba(139, 92, 246, 0.25),
                0 0 0 3px rgba(139, 92, 246, 0.3);
}

/* Legacy btn-primary support */
.btn-primary {
    background: linear-gradient(135deg, #0ea5a5, #06b6d4);
    color: white;
    font-weight: 500;
    padding: 0.625rem 1.25rem;
    border-radius: 8px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 14px rgba(14, 165, 165, 0.25);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(14, 165, 165, 0.35);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Legacy module-specific button colors (for backward compatibility) */
.btn-vault {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.25);
}

.btn-vault:hover {
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.35);
}

.btn-insight {
    background: linear-gradient(135deg, #10b981, #059669);
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.25);
}

.btn-insight:hover {
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35);
}

.btn-allocator {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    box-shadow: 0 4px 14px rgba(139, 92, 246, 0.25);
}

.btn-allocator:hover {
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.35);
}

/* ============================================
   Icon Badge Styles
   ============================================ */

.icon-badge {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.module-card:hover .icon-badge {
    transform: scale(1.05);
}

.icon-badge-vault {
    background: rgba(59, 130, 246, 0.15);
    color: var(--apx-vault-light, #60a5fa);
}

.module-card-vault:hover .icon-badge-vault {
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
}

.icon-badge-insight {
    background: rgba(16, 185, 129, 0.15);
    color: var(--apx-insight-light, #34d399);
}

.module-card-insight:hover .icon-badge-insight {
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
}

.icon-badge-allocator {
    background: rgba(139, 92, 246, 0.15);
    color: var(--apx-allocator-light, #a78bfa);
}

.module-card-allocator:hover .icon-badge-allocator {
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.3);
}

/* ============================================
   Login Form Styles (SHELL-103)
   ============================================ */

/* APX Input styling with design tokens */
.apx-input,
.input-dark {
    width: 100%;
    padding: 0.75rem 1rem;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: var(--apx-text-sm, 0.875rem);
    color: var(--apx-text-primary, #f0f2f5);
    background: var(--apx-bg-secondary, #12171e);
    border: 1px solid var(--apx-border, rgba(255, 255, 255, 0.08));
    border-radius: var(--apx-radius-md, 8px);
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.apx-input::placeholder,
.input-dark::placeholder {
    color: var(--apx-text-tertiary, #5c6878);
}

/* Teal focus ring */
.apx-input:focus,
.input-dark:focus {
    outline: none;
    border-color: var(--apx-primary, #0ea5a5);
    box-shadow: 0 0 0 3px rgba(14, 165, 165, 0.2),
                0 0 20px rgba(14, 165, 165, 0.1);
}

/* Error state */
.apx-input-error,
.input-dark.input-error,
.input-dark[aria-invalid="true"] {
    border-color: var(--apx-error, #ef4444);
}

.apx-input-error:focus,
.input-dark.input-error:focus,
.input-dark[aria-invalid="true"]:focus {
    border-color: var(--apx-error, #ef4444);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2),
                0 0 20px rgba(239, 68, 68, 0.1);
}

/* Success state */
.apx-input-success,
.input-dark.input-success {
    border-color: var(--apx-success, #10b981);
}

.apx-input-success:focus,
.input-dark.input-success:focus {
    border-color: var(--apx-success, #10b981);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2),
                0 0 20px rgba(16, 185, 129, 0.1);
}

/* Disabled state */
.apx-input:disabled,
.input-dark:disabled {
    background: var(--apx-bg-tertiary, #151b23);
    color: var(--apx-text-disabled, #3d4654);
    cursor: not-allowed;
}

/* Form validation messages */
.form-error-message,
.text-red-400 {
    color: #f87171;
    font-size: 0.75rem;
    margin-top: 0.375rem;
}

/* Login form specific input styling */
input[type="text"],
input[type="password"],
input[type="email"] {
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

/* Checkbox styling for dark theme */
input[type="checkbox"] {
    accent-color: var(--apx-primary, #0ea5a5);
    width: 1rem;
    height: 1rem;
    border-radius: 4px;
    border: 1px solid var(--apx-border, rgba(255, 255, 255, 0.08));
    background: var(--apx-bg-secondary, #12171e);
}

input[type="checkbox"]:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(14, 165, 165, 0.3);
}

/* ============================================
   Header & Navigation Styles (SHELL-104)
   ============================================ */

/* Navbar header with backdrop blur */
.apx-navbar-header {
    background: rgba(15, 20, 25, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

/* Legacy navbar styles */
.apx-header,
nav.bg-apx-bg-secondary {
    background: rgba(15, 20, 25, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* Logo badge with gradient */
.logo-badge {
    background: linear-gradient(135deg, var(--apx-primary, #0ea5a5) 0%, var(--apx-cyan, #06b6d4) 100%);
    box-shadow: 0 2px 8px rgba(14, 165, 165, 0.25);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.group:hover .logo-badge {
    box-shadow: 0 4px 16px rgba(14, 165, 165, 0.4);
    transform: scale(1.05);
}

/* Sign out button styling */
.btn-signout {
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 0.75rem;
    font-size: var(--apx-text-sm, 0.875rem);
    font-weight: 500;
    color: var(--apx-text-secondary, #8b95a5);
    background: transparent;
    border: 1px solid var(--apx-border, rgba(255, 255, 255, 0.08));
    border-radius: var(--apx-radius-md, 8px);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-signout:hover {
    color: var(--apx-text-primary, #f0f2f5);
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--apx-border-hover, rgba(255, 255, 255, 0.15));
    transform: translateY(-1px);
}

.btn-signout:active {
    transform: translateY(0);
}

.btn-signout:focus-visible {
    outline: 2px solid var(--apx-primary, #0ea5a5);
    outline-offset: 2px;
}

.btn-signout svg {
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.btn-signout:hover svg {
    opacity: 1;
}

/* ============================================
   Loading & Animations
   ============================================ */

.spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in-up {
    animation: fadeInUp 0.5s ease forwards;
}

.animate-delay-100 { animation-delay: 0.1s; }
.animate-delay-200 { animation-delay: 0.2s; }
.animate-delay-300 { animation-delay: 0.3s; }

/* Subtle pulse for primary accent */
@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 20px rgba(14, 165, 165, 0.2);
    }
    50% {
        box-shadow: 0 0 30px rgba(14, 165, 165, 0.4);
    }
}

.pulse-glow {
    animation: pulse-glow 3s ease-in-out infinite;
}

/* Gradient border animation for cards */
@keyframes borderGlow {
    0%, 100% {
        opacity: 0.5;
    }
    50% {
        opacity: 1;
    }
}

/* ============================================
   Panel Styles
   ============================================ */

#module-panel {
    transition: opacity 0.2s ease-in-out, backdrop-filter 0.2s ease-in-out;
    background: rgba(10, 13, 18, 0.95);
    backdrop-filter: blur(8px);
}

#module-panel.hidden {
    opacity: 0;
    pointer-events: none;
}

#module-frame {
    background-color: var(--apx-bg-secondary, #0f1419);
}

/* ============================================
   Focus & Accessibility
   ============================================ */

button:focus-visible,
a:focus-visible,
input:focus-visible {
    outline: 2px solid var(--apx-primary, #0ea5a5);
    outline-offset: 2px;
}

/* ============================================
   Utility Classes
   ============================================ */

.text-gradient {
    background: linear-gradient(135deg, #0ea5a5, #06b6d4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.border-gradient {
    border-image: linear-gradient(90deg, #0ea5a5, #06b6d4) 1;
}

.glow-teal {
    box-shadow: 0 0 30px rgba(14, 165, 165, 0.15);
}

/* Module-specific glows */
.glow-vault {
    box-shadow: 0 0 30px rgba(59, 130, 246, 0.15);
}

.glow-insight {
    box-shadow: 0 0 30px rgba(16, 185, 129, 0.15);
}

.glow-allocator {
    box-shadow: 0 0 30px rgba(139, 92, 246, 0.15);
}

/* ============================================
   Theme Toggle Button
   ============================================ */

.btn-theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    color: var(--apx-text-secondary, #8b95a5);
    background: transparent;
    border: 1px solid var(--apx-border, rgba(255, 255, 255, 0.08));
    border-radius: var(--apx-radius-lg, 8px);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-theme-toggle:hover {
    color: var(--apx-text-primary, #f0f2f5);
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--apx-border-hover, rgba(255, 255, 255, 0.15));
    transform: translateY(-1px);
}

.btn-theme-toggle:active {
    transform: translateY(0);
}

.btn-theme-toggle:focus-visible {
    outline: 2px solid var(--apx-primary, #0ea5a5);
    outline-offset: 2px;
}

/* Light mode button adjustments */
.light .btn-theme-toggle,
[data-theme="light"] .btn-theme-toggle {
    color: var(--apx-text-secondary);
    border-color: var(--apx-border);
}

.light .btn-theme-toggle:hover,
[data-theme="light"] .btn-theme-toggle:hover {
    color: var(--apx-text-primary);
    background: var(--apx-bg-hover);
    border-color: var(--apx-border-strong);
}

/* ============================================
   Session Timeout Modal Styles
   ============================================ */

#session-timeout-modal {
    transition: opacity 0.2s ease-out;
}

#session-timeout-modal.hidden {
    opacity: 0;
    pointer-events: none;
}

#session-extend-btn.loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

#session-extend-btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ============================================
   Screen Reader Only (Accessibility)
   ============================================ */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================
   Light Mode Overrides
   ============================================ */

.light,
[data-theme="light"] {
    --apx-bg-primary: #ffffff;
    --apx-bg-secondary: #fafafa;
    --apx-bg-tertiary: #f5f5f5;
    --apx-bg-card: #ffffff;
    --apx-bg-hover: #f0f0f0;
    --apx-text-primary: #111827;
    --apx-text-secondary: #4b5563;
    --apx-text-tertiary: #9ca3af;
    --apx-border: #e2e8f0;
    --apx-border-hover: #cbd5e1;
}

.light body,
[data-theme="light"] body {
    background-color: var(--apx-bg-primary);
    color: var(--apx-text-primary);
}

.light .apx-navbar-header,
[data-theme="light"] .apx-navbar-header {
    background: rgba(255, 255, 255, 0.95);
    border-bottom-color: var(--apx-border);
}

.light .btn-signout,
[data-theme="light"] .btn-signout {
    color: var(--apx-text-secondary);
    border-color: var(--apx-border);
}

.light .btn-signout:hover,
[data-theme="light"] .btn-signout:hover {
    color: var(--apx-text-primary);
    background: var(--apx-bg-hover);
    border-color: var(--apx-border-hover);
}

.light .module-card,
[data-theme="light"] .module-card {
    background: var(--apx-bg-card);
    border-color: var(--apx-border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.light .module-card:hover,
[data-theme="light"] .module-card:hover {
    border-color: var(--apx-border-hover);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

.light footer,
[data-theme="light"] footer {
    background: var(--apx-bg-secondary);
    border-top-color: var(--apx-border);
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
    nav,
    footer,
    #module-panel {
        display: none !important;
    }

    body {
        background: white !important;
        color: black !important;
    }
}

/* ============================================
   Reduced Motion Support
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
