/**
 * SafeQA Design System - Pure CSS Version
 * Compiled from Tailwind @apply rules for CDN compatibility
 */

:root {
    --color-primary-50: #EEF2FF;
    --color-primary-100: #E0E7FF;
    --color-primary-200: #C7D2FE;
    --color-primary-300: #A5B4FC;
    --color-primary-400: #818CF8;
    --color-primary-500: #6366F1;
    --color-primary-600: #4F46E5;
    --color-primary-700: #4338CA;
    --color-primary-800: #3730A3;
    --color-primary-900: #312E81;

    --color-secondary-500: #10B981;
    --color-secondary-600: #059669;

    --color-gray-50: #FAFAF9;
    --color-gray-100: #F5F5F4;
    --color-gray-200: #E7E5E4;
    --color-gray-500: #78716C;
    --color-gray-600: #57534E;
    --color-gray-700: #44403C;
    --color-gray-900: #1C1917;
}

/* Layout */
.container-custom {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
    max-width: 80rem;
    /* max-w-7xl */
}

/* Typography */
.heading-1 {
    font-size: 2.25rem;
    line-height: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    color: var(--color-gray-900);
}

@media (min-width: 768px) {
    .heading-1 {
        font-size: 3rem;
        line-height: 1;
    }
}

.heading-2 {
    font-size: 1.875rem;
    line-height: 2.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--color-gray-900);
}

@media (min-width: 768px) {
    .heading-2 {
        font-size: 2.25rem;
        line-height: 2.5rem;
    }
}

.heading-3 {
    font-size: 1.5rem;
    line-height: 2rem;
    font-weight: 700;
    color: var(--color-gray-900);
    /* Adjusted from 800 */
}

.body-large {
    font-size: 1.125rem;
    line-height: 1.625;
    color: var(--color-gray-600);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 700;
    font-size: 1rem;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
    white-space: nowrap;
}

.btn:focus {
    outline: none;
    box-shadow: 0 0 0 4px var(--color-primary-200);
}

.btn-primary {
    background: linear-gradient(to right, var(--color-primary-600), var(--color-primary-500));
    color: white;
    box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.2);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(79, 70, 229, 0.3);
}

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

.btn-secondary:hover {
    background-color: #047857;
    /* secondary-700 */
}

.btn-outline {
    background-color: white;
    color: var(--color-gray-700);
    border: 2px solid var(--color-gray-200);
}

.btn-outline:hover {
    border-color: var(--color-primary-300);
    background-color: var(--color-primary-50);
    color: var(--color-primary-700);
}

.btn-danger {
    background-color: #EF4444;
    color: white;
}

.btn-icon {
    padding: 0.625rem;
    border-radius: 0.5rem;
    color: var(--color-gray-500);
    background: transparent;
}

.btn-icon:hover {
    background-color: var(--color-gray-100);
    color: var(--color-gray-700);
}

/* Cards */
.card {
    background-color: white;
    border-radius: 1rem;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    border: 1px solid var(--color-gray-200);
    overflow: hidden;
}

.card-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--color-gray-100);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(250, 250, 249, 0.3);
    /* gray-50/30 */
}

.card-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--color-gray-900);
}

.card-body {
    padding: 1.5rem;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-primary {
    background-color: var(--color-primary-100);
    color: var(--color-primary-700);
    border: 1px solid var(--color-primary-200);
}

.badge-success {
    background-color: #D1FAE5;
    color: #047857;
    border: 1px solid #A7F3D0;
}

.badge-secondary {
    background-color: #ECFDF5;
    color: #059669;
    border: 1px solid #A7F3D0;
}

.badge-warning {
    background-color: #FFFBEB;
    color: #D97706;
    border: 1px solid #FDE68A;
}

.badge-danger {
    background-color: #FEF2F2;
    color: #DC2626;
    border: 1px solid #FECACA;
}

.badge-info {
    background-color: #EFF6FF;
    border-color: #BFDBFE;
    color: #1E40AF;
}

.badge-gray {
    background-color: #F5F5F4;
    color: #57534E;
    border: 1px solid #E7E5E4;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-gray-700);
    margin-bottom: 0.5rem;
}

.form-input,
.form-select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--color-gray-200);
    border-radius: 0.75rem;
    font-size: 1rem;
    color: var(--color-gray-900);
    transition: all 0.2s;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--color-primary-500);
    box-shadow: 0 0 0 4px var(--color-primary-200);
}

.form-checkbox,
.form-radio {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 1rem;
    color: var(--color-gray-700);
    user-select: none;
}

.form-checkbox input,
.form-radio input {
    appearance: none;
    -webkit-appearance: none;
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid var(--color-gray-200);
    transition: all 0.2s;
    flex-shrink: 0;
}

.form-checkbox input {
    border-radius: 0.5rem;
}

.form-radio input {
    border-radius: 9999px;
}

.form-checkbox input:checked,
.form-radio input:checked {
    background-color: var(--color-primary-600);
    border-color: var(--color-primary-600);
    background-image: url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3e%3c/svg%3e");
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
}

.form-radio input:checked {
    background-image: url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3ccircle cx='8' cy='8' r='3'/%3e%3c/svg%3e");
}

.form-checkbox:hover input:not(:checked),
.form-radio:hover input:not(:checked) {
    border-color: var(--color-primary-300);
}

.form-hint,
.form-error {
    font-size: 0.875rem;
    color: var(--color-gray-500);
    margin-top: 0.5rem;
}

.form-error {
    color: #EF4444;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 0.75rem;
    border: 1px solid transparent;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.alert svg {
    width: 1.5rem;
    height: 1.5rem;
    flex-shrink: 0;
}

.alert-success {
    background-color: #ECFDF5;
    border-color: #A7F3D0;
    color: #065F46;
}

.alert-error {
    background-color: #FEF2F2;
    border-color: #FECACA;
    color: #991B1B;
}

.alert-warning {
    background-color: #FFFBEB;
    border-color: #FDE68A;
    color: #92400E;
}

.alert-info {
    background-color: #EFF6FF;
    border-color: #BFDBFE;
    color: #1E40AF;
}

/* Utilities */
.logo-icon {
    width: 2.5rem;
    height: 2.5rem;
    background: linear-gradient(to bottom right, var(--color-primary-600), var(--color-primary-600), #4338CA);
    border-radius: 1rem;
    box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.3);
}

.text-gradient-primary {
    background: linear-gradient(to right, var(--color-primary-600), #7C3AED, var(--color-primary-600));
    -webkit-background-clip: text;
    color: transparent;
}

/* Additional Components */

/* Feature & Stat Cards */
.card-feature,
.card-stat {
    position: relative;
    overflow: hidden;
    transition: all 0.3s;
}

.card-feature:hover,
.card-stat:hover {
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Pseudo-element for gradients (simplified for pure CSS) */
.card-feature::before,
.card-stat::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 10rem;
    height: 10rem;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.1) 0%, rgba(139, 92, 246, 0.05) 100%);
    border-radius: 9999px;
    filter: blur(40px);
    transform: translate(50%, -50%);
    pointer-events: none;
}

.card-icon {
    width: 3.5rem;
    height: 3.5rem;
    background: linear-gradient(to bottom right, var(--color-primary-500), #7C3AED);
    border-radius: 0.75rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    color: white;
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--color-gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stat-value {
    font-size: 3rem;
    font-weight: 800;
    color: var(--color-gray-900);
    line-height: 1;
    letter-spacing: -0.025em;
}

.stat-badge {
    font-size: 0.75rem;
    font-weight: 600;
    background-color: var(--color-primary-50);
    color: var(--color-primary-700);
    border: 1px solid var(--color-primary-100);
    padding: 0.125rem 0.625rem;
    border-radius: 9999px;
    display: inline-block;
    margin-top: 0.5rem;
}

/* Progress Bars */
.progress-bar-container {
    width: 100%;
    background-color: var(--color-gray-100);
    border-radius: 9999px;
    height: 0.625rem;
    overflow: hidden;
    border: 1px solid var(--color-gray-200);
}

.progress-bar {
    height: 100%;
    background: linear-gradient(to right, var(--color-primary-500), var(--color-primary-600), #7C3AED);
    border-radius: 9999px;
    transition: width 0.7s ease-out;
}

.progress-bar-shimmer {
    position: relative;
    overflow: hidden;
}

.progress-bar-shimmer::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s infinite;
}

/* Modals */
.modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(17, 24, 39, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background-color: white;
    border-radius: 1rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-width: 28rem;
    width: 100%;
    margin: 1rem;
    transform: scale(0.95);
    transition: transform 0.3s;
}

.modal.active .modal-content {
    transform: scale(100%);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--color-gray-100);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--color-gray-50);
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* Pulse Dots */
.pulse-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.pulse-dot-primary {
    background-color: var(--color-primary-500);
}

.pulse-dot-success {
    background-color: #10B981;
}

.pulse-dot-danger {
    background-color: #EF4444;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: .5;
    }
}

/* Spinner */
.spinner {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid var(--color-gray-200);
    border-top-color: var(--color-primary-600);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* ========================================
   Phase 4: Polish & Interaction
   ======================================== */

/* Toast notifications, loading states, transitions, and mobile optimizations */

/* ========================================
   TOAST NOTIFICATIONS
   ======================================== */

/* Toast Container */
.toast-container {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 24rem;
    pointer-events: none;
}

@media (max-width: 640px) {
    .toast-container {
        left: 1rem;
        right: 1rem;
        max-width: none;
    }
}

/* Toast Base */
.toast {
    background-color: white;
    border-radius: 0.75rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--color-gray-200);
    padding: 1rem;
    pointer-events: auto;
    transform: translateX(calc(100% + 2rem));
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 20rem;
}

@media (max-width: 640px) {
    .toast {
        min-width: auto;
    }
}

/* Toast Show/Hide Animations */
.toast-show {
    transform: translateX(0);
    opacity: 1;
}

.toast-hide {
    transform: translateX(calc(100% + 2rem));
    opacity: 0;
}

/* Toast Content */
.toast-content {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.toast-icon {
    flex-shrink: 0;
    width: 1.25rem;
    height: 1.25rem;
}

.toast-message {
    flex: 1;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--color-gray-700);
    font-weight: 500;
}

.toast-close {
    flex-shrink: 0;
    background: transparent;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    color: var(--color-gray-400);
    transition: color 0.2s;
    border-radius: 0.375rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toast-close:hover {
    color: var(--color-gray-600);
    background-color: var(--color-gray-100);
}

.toast-close i {
    width: 1rem;
    height: 1rem;
}

/* Toast Action Button */
.toast-action {
    margin-top: 0.75rem;
    width: 100%;
    padding: 0.5rem 1rem;
    background-color: var(--color-primary-50);
    color: var(--color-primary-700);
    border: 1px solid var(--color-primary-200);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.toast-action:hover {
    background-color: var(--color-primary-100);
    border-color: var(--color-primary-300);
}

/* Toast Variants */
.toast-success {
    border-left: 4px solid #10B981;
}

.toast-success .toast-icon {
    color: #10B981;
}

.toast-error {
    border-left: 4px solid #EF4444;
}

.toast-error .toast-icon {
    color: #EF4444;
}

.toast-warning {
    border-left: 4px solid #F59E0B;
}

.toast-warning .toast-icon {
    color: #F59E0B;
}

.toast-info {
    border-left: 4px solid var(--color-primary-500);
}

.toast-info .toast-icon {
    color: var(--color-primary-500);
}

/* ========================================
   BUTTON LOADING STATES
   ======================================== */

/* Loading Button */
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.btn-outline.btn-loading::after,
.btn-icon.btn-loading::after {
    border-color: rgba(79, 70, 229, 0.3);
    border-top-color: var(--color-primary-600);
}

/* ========================================
   ENHANCED TRANSITIONS
   ======================================== */

/* Smooth Page Transitions */
.page-transition {
    animation: fadeInUp 0.4s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(1rem);
    }

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

/* Hover Lift Effect */
.hover-lift {
    transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
}

.hover-lift:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Smooth Accordion */
.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.accordion-content.open {
    max-height: 1000px;
}

/* Fade In Animation */
.fade-in {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Slide In From Right */
.slide-in-right {
    animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

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

/* ========================================
   MOBILE OPTIMIZATIONS
   ======================================== */

/* Responsive Table */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 0.75rem;
    border: 1px solid var(--color-gray-200);
}

.table-responsive table {
    min-width: 100%;
    border-collapse: collapse;
}

@media (max-width: 768px) {
    .table-responsive {
        border: none;
    }

    .table-mobile-cards {
        display: block;
    }

    .table-mobile-cards thead {
        display: none;
    }

    .table-mobile-cards tbody,
    .table-mobile-cards tr {
        display: block;
    }

    .table-mobile-cards tr {
        margin-bottom: 1rem;
        border: 1px solid var(--color-gray-200);
        border-radius: 0.75rem;
        padding: 1rem;
        background-color: white;
    }

    .table-mobile-cards td {
        display: flex;
        justify-content: space-between;
        padding: 0.5rem 0;
        border: none;
    }

    .table-mobile-cards td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--color-gray-700);
    }
}

/* Mobile-Friendly Buttons */
@media (max-width: 640px) {
    .btn-mobile-full {
        width: 100%;
        justify-content: center;
    }

    .btn-group-mobile-stack {
        flex-direction: column;
    }

    .btn-group-mobile-stack .btn {
        width: 100%;
    }
}

/* Touch-Friendly Tap Targets */
@media (hover: none) and (pointer: coarse) {

    .btn,
    .btn-icon,
    .toast-close,
    button {
        min-height: 44px;
        min-width: 44px;
    }
}

/* Shimmer Loading Effect */
.shimmer {
    background: linear-gradient(90deg,
            var(--color-gray-100) 0%,
            var(--color-gray-200) 50%,
            var(--color-gray-100) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}