/**
 * CRT Engine — Base Design System
 *
 * Global CSS custom properties, typography, and utility classes.
 * Component-specific styles are loaded by their respective shortcodes.
 *
 * @package CRT_Engine
 */

/* ═══════════════════════════════════════════════════════════════════
   DESIGN TOKENS
   ═══════════════════════════════════════════════════════════════════ */

:root {
    /* ── Color Palette: "Institutional Trust" ─────────────── */
    --crt-navy:          #0B2545;
    --crt-navy-light:    #13375E;
    --crt-blue:          #13507A;
    --crt-blue-light:    #1A6BA3;
    --crt-teal:          #0EA5A0;
    --crt-teal-light:    #14CCC6;
    --crt-gold:          #D4A853;
    --crt-gold-light:    #E5C87D;

    --crt-white:         #FAFBFC;
    --crt-gray-50:       #F8FAFC;
    --crt-gray-100:      #F1F5F9;
    --crt-gray-200:      #E2E8F0;
    --crt-gray-300:      #CBD5E1;
    --crt-gray-400:      #94A3B8;
    --crt-gray-500:      #64748B;
    --crt-gray-600:      #475569;
    --crt-gray-700:      #334155;
    --crt-gray-800:      #1E293B;
    --crt-gray-900:      #0F172A;

    --crt-success:       #22C55E;
    --crt-success-bg:    #F0FDF4;
    --crt-warning:       #F59E0B;
    --crt-warning-bg:    #FFFBEB;
    --crt-danger:        #EF4444;
    --crt-danger-bg:     #FEF2F2;
    --crt-info:          #3B82F6;
    --crt-info-bg:       #EFF6FF;

    /* ── Typography ───────────────────────────────────────── */
    --crt-font-primary:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --crt-font-display:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --crt-font-mono:     'Fira Code', 'JetBrains Mono', monospace;

    --crt-text-xs:       0.75rem;
    --crt-text-sm:       0.875rem;
    --crt-text-base:     1rem;
    --crt-text-lg:       1.125rem;
    --crt-text-xl:       1.25rem;
    --crt-text-2xl:      1.5rem;
    --crt-text-3xl:      1.875rem;
    --crt-text-4xl:      2.25rem;

    /* ── Spacing ──────────────────────────────────────────── */
    --crt-space-1:       0.25rem;
    --crt-space-2:       0.5rem;
    --crt-space-3:       0.75rem;
    --crt-space-4:       1rem;
    --crt-space-5:       1.25rem;
    --crt-space-6:       1.5rem;
    --crt-space-8:       2rem;
    --crt-space-10:      2.5rem;
    --crt-space-12:      3rem;
    --crt-space-16:      4rem;

    /* ── Border Radius ────────────────────────────────────── */
    --crt-radius-sm:     4px;
    --crt-radius:        8px;
    --crt-radius-lg:     12px;
    --crt-radius-xl:     16px;
    --crt-radius-full:   9999px;

    /* ── Shadows ──────────────────────────────────────────── */
    --crt-shadow-sm:     0 1px 2px rgba(0,0,0,0.05);
    --crt-shadow:        0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --crt-shadow-md:     0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --crt-shadow-lg:     0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --crt-shadow-xl:     0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);

    /* ── Transitions ─────────────────────────────────────── */
    --crt-transition:    all 0.2s ease;
    --crt-transition-slow: all 0.3s ease;
}

/* ═══════════════════════════════════════════════════════════════════
   BASE RESETS (scoped to CRT components only)
   ═══════════════════════════════════════════════════════════════════ */

[class^="crt-"],
[class*=" crt-"] {
    box-sizing: border-box;
    font-family: var(--crt-font-primary);
}

/* ═══════════════════════════════════════════════════════════════════
   SHARED FORM ELEMENTS
   ═══════════════════════════════════════════════════════════════════ */

.crt-label {
    display: flex;
    align-items: center;
    gap: var(--crt-space-2);
    font-size: var(--crt-text-sm);
    font-weight: 600;
    color: var(--crt-gray-700);
    margin-bottom: var(--crt-space-2);
}

.crt-label svg {
    color: var(--crt-teal);
    flex-shrink: 0;
}

.crt-input,
.crt-select {
    width: 100%;
    padding: var(--crt-space-3) var(--crt-space-4);
    font-size: var(--crt-text-base);
    font-family: var(--crt-font-primary);
    color: var(--crt-gray-800);
    background: #fff;
    border: 2px solid var(--crt-gray-200);
    border-radius: var(--crt-radius);
    transition: var(--crt-transition);
    appearance: none;
    -webkit-appearance: none;
}

.crt-input:focus,
.crt-select:focus {
    outline: none;
    border-color: var(--crt-teal);
    box-shadow: 0 0 0 3px rgba(14, 165, 160, 0.15);
}

.crt-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}

.crt-select--large {
    padding: var(--crt-space-4) var(--crt-space-5);
    font-size: var(--crt-text-lg);
    padding-right: 40px;
}

.crt-select--small {
    padding: var(--crt-space-2) var(--crt-space-3);
    font-size: var(--crt-text-sm);
    padding-right: 30px;
}

/* ═══════════════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════════════ */

.crt-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--crt-space-2);
    padding: var(--crt-space-3) var(--crt-space-6);
    font-size: var(--crt-text-base);
    font-weight: 600;
    font-family: var(--crt-font-primary);
    border: none;
    border-radius: var(--crt-radius);
    cursor: pointer;
    transition: var(--crt-transition);
    text-decoration: none;
    line-height: 1.5;
    white-space: nowrap;
}

.crt-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.crt-btn--primary {
    background: linear-gradient(135deg, var(--crt-navy) 0%, var(--crt-blue) 100%);
    color: #fff;
    box-shadow: var(--crt-shadow-md);
}

.crt-btn--primary:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--crt-navy-light) 0%, var(--crt-blue-light) 100%);
    box-shadow: var(--crt-shadow-lg);
    transform: translateY(-1px);
}

.crt-btn--primary:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: var(--crt-shadow-sm);
}

.crt-btn--success {
    background: linear-gradient(135deg, #16A34A 0%, var(--crt-success) 100%);
    color: #fff;
    box-shadow: var(--crt-shadow-md);
}

.crt-btn--success:hover:not(:disabled) {
    background: linear-gradient(135deg, #15803D 0%, #16A34A 100%);
    box-shadow: var(--crt-shadow-lg);
    transform: translateY(-1px);
}

.crt-btn--warning {
    background: linear-gradient(135deg, #D97706 0%, var(--crt-warning) 100%);
    color: #fff;
}

.crt-btn--outline {
    background: transparent;
    color: var(--crt-navy);
    border: 2px solid var(--crt-navy);
}

.crt-btn--outline:hover:not(:disabled) {
    background: var(--crt-navy);
    color: #fff;
}

.crt-btn--lg {
    padding: var(--crt-space-4) var(--crt-space-8);
    font-size: var(--crt-text-lg);
}

/* ═══════════════════════════════════════════════════════════════════
   LOADING SPINNER
   ═══════════════════════════════════════════════════════════════════ */

.crt-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--crt-gray-200);
    border-top-color: var(--crt-teal);
    border-radius: 50%;
    animation: crt-spin 0.8s linear infinite;
}

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

.crt-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--crt-space-4);
    padding: var(--crt-space-12);
    color: var(--crt-gray-500);
}

/* ═══════════════════════════════════════════════════════════════════
   MODAL
   ═══════════════════════════════════════════════════════════════════ */

.crt-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--crt-space-4);
}

.crt-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(11, 37, 69, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.crt-modal__content {
    position: relative;
    background: #fff;
    border-radius: var(--crt-radius-xl);
    box-shadow: var(--crt-shadow-xl);
    max-width: 640px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: var(--crt-space-8);
    animation: crt-modal-in 0.3s ease-out;
}

.crt-modal__close {
    position: absolute;
    top: var(--crt-space-4);
    right: var(--crt-space-4);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--crt-gray-100);
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    color: var(--crt-gray-500);
    cursor: pointer;
    transition: var(--crt-transition);
}

.crt-modal__close:hover {
    background: var(--crt-gray-200);
    color: var(--crt-gray-800);
}

@keyframes crt-modal-in {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ═══════════════════════════════════════════════════════════════════
   ALERT BADGES
   ═══════════════════════════════════════════════════════════════════ */

.crt-alert {
    display: flex;
    align-items: flex-start;
    gap: var(--crt-space-3);
    padding: var(--crt-space-4);
    border-radius: var(--crt-radius);
    border-left: 4px solid;
    margin-bottom: var(--crt-space-3);
    font-size: var(--crt-text-sm);
    line-height: 1.5;
}

.crt-alert--info {
    background: var(--crt-info-bg);
    border-color: var(--crt-info);
    color: #1E40AF;
}

.crt-alert--success {
    background: var(--crt-success-bg);
    border-color: var(--crt-success);
    color: #166534;
}

.crt-alert--warning {
    background: var(--crt-warning-bg);
    border-color: var(--crt-warning);
    color: #92400E;
}

.crt-alert--caution,
.crt-alert--danger {
    background: var(--crt-danger-bg);
    border-color: var(--crt-danger);
    color: #991B1B;
}

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .crt-modal__content {
        padding: var(--crt-space-5);
        border-radius: var(--crt-radius-lg);
    }
}
