@import "tailwindcss";

/* Sidebar theme variable — consumed by sidebar.blade.php and module-hero.blade.php */
:root {
    --theme-bg-sidebar: #1a4731;
}

/* Theme Variables using Tailwind CSS 4.x @theme directive */
@theme {
    /* SSHIA Brand Colors */
    --color-forest-green: #1a4731;
    --color-sshia-green: #16a34a;
    --color-sshia-red: #dc2626;
    --color-sshia-blue: #2563eb;
    --color-sshia-gold: #fbbf24;
    
    /* Extended Color Palette */
    --color-dark-slate: #0f172a;
    --color-dark-gray: #111827;
    --color-medium-gray: #1f2937;
    --color-light-gray: #d1d5db;
    
    /* Typography Scale */
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 1.875rem;
    --font-size-4xl: 2.25rem;
    
    /* Spacing Scale */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    
    /* Border Radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;
    --radius-xl: 0.75rem;
    --radius-2xl: 1rem;
    --radius-full: 9999px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1);
    --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);
    
    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base Styles */
@layer base {
    /* Prevent FOUC (Flash of Unstyled Content) */
    [x-cloak] {
        display: none !important;
    }
    
    /* Smooth scrolling */
    html {
        scroll-behavior: smooth;
        width: 100%;
        max-width: 100%;
    }
    
    /* Font loading optimization */
    @font-face {
        font-family: 'Inter';
        font-display: swap; /* Prevent FOIT, use fallback during load */
        src: local('Inter');
    }
    
    /* Body defaults */
    html, body {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }
    
    body {
        font-family: var(--theme-font-body, 'Inter', 'Figtree', sans-serif);
        color: var(--theme-color-body, #1f2937);
        background-color: var(--theme-bg-body, #ffffff);
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        margin: 0;
        padding: 0;
    }
    
    /* Override max-width constraints for header/footer/nav full-width wrappers only */
    header .max-w-screen-2xl,
    footer .max-w-screen-2xl,
    nav .max-w-screen-2xl {
        max-width: 100% !important;
    }
    
    /* Heading defaults */
    h1, h2, h3, h4, h5, h6 {
        font-family: var(--theme-font-heading, 'Inter', 'Figtree', sans-serif);
        color: var(--theme-color-heading, #111827);
        font-weight: var(--theme-heading-weight, 600);
        letter-spacing: var(--theme-heading-spacing, -0.025em);
    }
    
    /* Link defaults */
    a {
        color: var(--theme-color-link, #2563eb);
        text-decoration: none;
        transition: color var(--transition-fast);
    }
    
    a:hover {
        color: var(--theme-color-link-hover, #1d4ed8);
    }
    
    /* Focus visible styles for accessibility */
    *:focus-visible {
        outline: 2px solid var(--color-sshia-green);
        outline-offset: 2px;
    }
    
    /* Custom scrollbar */
    ::-webkit-scrollbar {
        width: var(--theme-scrollbar-width, 8px);
        height: var(--theme-scrollbar-width, 8px);
    }
    
    ::-webkit-scrollbar-track {
        background: var(--theme-scrollbar-track, #f1f5f9);
    }
    
    ::-webkit-scrollbar-thumb {
        background: var(--theme-scrollbar-thumb, #cbd5e1);
        border-radius: var(--radius-full);
    }
    
    ::-webkit-scrollbar-thumb:hover {
        background: var(--theme-scrollbar-thumb-hover, #94a3b8);
    }
}

/* Component Styles */
@layer components {
    /* Full-width section utilities */
    .section-full {
        width: 100vw;
        position: relative;
        left: 50%;
        right: 50%;
        margin-left: -50vw;
        margin-right: -50vw;
    }
    
    .hero-full {
        width: 100%;
        max-width: 100%;
    }
    
    /* Button Base */
    .btn {
        @apply inline-flex items-center justify-center px-4 py-2 rounded-lg font-medium transition-all duration-200;
        @apply focus:outline-none focus:ring-2 focus:ring-offset-2;
    }
    
    .btn-primary {
        @apply bg-green-600 text-white hover:bg-green-700 focus:ring-green-500;
    }
    
    .btn-secondary {
        @apply bg-gray-600 text-white hover:bg-gray-700 focus:ring-gray-500;
    }
    
    .btn-outline {
        @apply border-2 border-current bg-transparent hover:bg-current hover:text-white;
    }
    
    /* Card Base */
    .card {
        @apply bg-white rounded-xl shadow-md overflow-hidden;
        background-color: var(--theme-bg-card, #ffffff);
    }
    
    .card-hero {
        @apply bg-gradient-to-br from-green-50 to-blue-50;
        background: var(--theme-bg-card-hero, linear-gradient(to bottom right, #f0fdf4, #eff6ff));
    }
    
    /* Form Input Base */
    .form-input {
        @apply w-full px-4 py-2 border border-gray-300 rounded-lg;
        @apply focus:ring-2 focus:ring-green-500 focus:border-green-500;
        @apply transition-colors duration-200;
    }
    
    /* Badge Base */
    .badge {
        @apply inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium;
    }
    
    .badge-red {
        @apply bg-red-100 text-red-800;
    }
    
    .badge-green {
        @apply bg-green-100 text-green-800;
    }
    
    .badge-blue {
        @apply bg-blue-100 text-blue-800;
    }
    
    /* Divider */
    .divider {
        border-color: var(--theme-divider-color, #e5e7eb);
        border-style: var(--theme-divider-style, solid);
        border-width: var(--theme-divider-width, 1px);
    }

    /* ─────────────────────────────────────────────────────────────
       SSHIA Theme Buttons
       theme-btn-primary / theme-btn-secondary are used throughout
       the codebase and are driven by CSS variables injected by the
       InjectTheme middleware.
    ───────────────────────────────────────────────────────────── */
    .theme-btn-primary {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.375rem;
        padding: 0.5rem 1.25rem;
        background-color: var(--theme-primary, #16a34a);
        color: #ffffff;
        font-weight: 600;
        font-size: 0.875rem;
        line-height: 1.5;
        border: 2px solid transparent;
        border-radius: 0.5rem;
        cursor: pointer;
        text-decoration: none;
        transition: background-color 200ms ease, box-shadow 200ms ease, transform 150ms ease, opacity 200ms ease;
        box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.12), 0 1px 2px -1px rgb(0 0 0 / 0.08);
    }

    .theme-btn-primary:hover {
        background-color: var(--theme-secondary, #15803d);
        box-shadow: 0 4px 12px 0 rgb(0 0 0 / 0.15);
        transform: translateY(-1px);
    }

    .theme-btn-primary:active {
        transform: translateY(0);
        box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.12);
    }

    .theme-btn-primary:focus-visible {
        outline: 2px solid var(--theme-primary, #16a34a);
        outline-offset: 3px;
    }

    .theme-btn-primary:disabled,
    .theme-btn-primary[disabled] {
        opacity: 0.45;
        cursor: not-allowed;
        transform: none;
        box-shadow: none;
    }

    .theme-btn-secondary {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.375rem;
        padding: 0.5rem 1.25rem;
        background-color: var(--theme-bg-card, #ffffff);
        color: var(--theme-color-heading, #111827);
        font-weight: 600;
        font-size: 0.875rem;
        line-height: 1.5;
        border: 1.5px solid var(--theme-divider-color, #d1d5db);
        border-radius: 0.5rem;
        cursor: pointer;
        text-decoration: none;
        transition: background-color 200ms ease, border-color 200ms ease, box-shadow 200ms ease, transform 150ms ease;
        box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.06);
    }

    .theme-btn-secondary:hover {
        background-color: var(--theme-bg-body, #f9fafb);
        border-color: var(--theme-primary, #16a34a);
        color: var(--theme-primary, #16a34a);
        box-shadow: 0 4px 10px 0 rgb(0 0 0 / 0.08);
        transform: translateY(-1px);
    }

    .theme-btn-secondary:active {
        transform: translateY(0);
        box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.06);
    }

    .theme-btn-secondary:focus-visible {
        outline: 2px solid var(--theme-primary, #16a34a);
        outline-offset: 3px;
    }

    .theme-btn-secondary:disabled,
    .theme-btn-secondary[disabled] {
        opacity: 0.45;
        cursor: not-allowed;
        transform: none;
        box-shadow: none;
    }

    /* ─────────────────────────────────────────────────────────────
       SSHIA Form Components
       Shared design language for all form inputs, selects, textareas,
       labels, and helper/error text.
    ───────────────────────────────────────────────────────────── */

    /* Field wrapper — provides consistent bottom spacing */
    .sshia-field-group {
        margin-bottom: 1.25rem;
    }

    /* Label */
    .sshia-label {
        display: flex;
        align-items: center;
        gap: 0.375rem;
        margin-bottom: 0.375rem;
        font-size: 0.8125rem;
        font-weight: 600;
        letter-spacing: 0.01em;
        color: var(--theme-color-heading, #111827);
    }

    .sshia-label-icon {
        font-size: 0.75rem;
        color: var(--theme-primary, #16a34a);
        opacity: 0.85;
    }

    .sshia-required {
        color: #ef4444;
        font-size: 0.875rem;
        line-height: 1;
        margin-left: 0.125rem;
    }

    /* Input shell — the outer border/shadow container */
    .sshia-input-shell {
        position: relative;
        display: flex;
        align-items: stretch;
        border-radius: 0.5rem;
        border: 1.5px solid var(--theme-divider-color, #d1d5db);
        background-color: var(--theme-bg-card, #ffffff);
        box-shadow: inset 0 1px 3px 0 rgb(0 0 0 / 0.06), 0 1px 2px 0 rgb(0 0 0 / 0.04);
        transition: border-color 180ms ease, box-shadow 180ms ease;
    }

    .sshia-input-shell:focus-within {
        border-color: var(--theme-primary, #16a34a);
        box-shadow: inset 0 1px 3px 0 rgb(0 0 0 / 0.04),
                    0 0 0 3px color-mix(in srgb, var(--theme-primary, #16a34a) 18%, transparent);
    }

    .sshia-input-shell--error {
        border-color: #ef4444 !important;
        box-shadow: inset 0 1px 3px 0 rgb(239 68 68 / 0.08),
                    0 0 0 3px rgb(239 68 68 / 0.12) !important;
    }

    /* Prefix icon inside the shell */
    .sshia-input-prefix-icon {
        display: flex;
        align-items: center;
        padding: 0 0.75rem;
        color: var(--theme-primary, #16a34a);
        font-size: 0.8125rem;
        opacity: 0.7;
        pointer-events: none;
        flex-shrink: 0;
    }

    /* Base input */
    .sshia-input {
        width: 100%;
        padding: 0.625rem 0.875rem;
        background: var(--theme-bg-card, #ffffff);
        border: 1.5px solid var(--theme-divider-color, #d1d5db);
        border-radius: 0.5rem;
        outline: none;
        font-size: 0.9375rem;
        color: var(--theme-color-body, #1f2937);
        line-height: 1.5;
        box-shadow: inset 0 1px 3px 0 rgb(0 0 0 / 0.06), 0 1px 2px 0 rgb(0 0 0 / 0.04);
        transition: border-color 180ms ease, box-shadow 180ms ease;
    }

    .sshia-input:focus {
        border-color: var(--theme-primary, #16a34a);
        box-shadow: inset 0 1px 3px 0 rgb(0 0 0 / 0.04),
                    0 0 0 3px color-mix(in srgb, var(--theme-primary, #16a34a) 18%, transparent);
    }

    /* When inside a shell, remove the input's own border/shadow — the shell handles it */
    .sshia-input-shell .sshia-input {
        background: transparent;
        border: none;
        border-radius: 0;
        box-shadow: none !important;
    }

    .sshia-input-shell .sshia-input:focus {
        border: none;
        box-shadow: none !important;
    }

    .sshia-input--has-icon {
        padding-left: 0.25rem;
    }

    .sshia-input::placeholder {
        color: var(--theme-color-body, #6b7280);
        opacity: 0.45;
    }

    .sshia-input:disabled {
        opacity: 0.55;
        cursor: not-allowed;
        background-color: color-mix(in srgb, var(--theme-bg-card, #ffffff) 60%, #f3f4f6);
    }

    /* Select shell — extends input-shell with chevron space */
    .sshia-select-shell {
        overflow: hidden;
    }

    .sshia-select {
        width: 100%;
        padding: 0.625rem 2.5rem 0.625rem 0.875rem;
        background: transparent;
        border: none;
        outline: none;
        font-size: 0.9375rem;
        color: var(--theme-color-body, #1f2937);
        line-height: 1.5;
        appearance: none;
        -webkit-appearance: none;
        cursor: pointer;
        box-shadow: none !important;
    }

    .sshia-select--has-icon {
        padding-left: 0.25rem;
    }

    .sshia-select option {
        background-color: var(--theme-bg-card, #ffffff);
        color: var(--theme-color-body, #1f2937);
    }

    .sshia-select:disabled {
        opacity: 0.55;
        cursor: not-allowed;
    }

    /* Custom chevron for select */
    .sshia-select-chevron {
        position: absolute;
        right: 0.75rem;
        top: 50%;
        transform: translateY(-50%);
        pointer-events: none;
        color: var(--theme-primary, #16a34a);
        font-size: 0.7rem;
        opacity: 0.75;
        transition: transform 200ms ease;
    }

    .sshia-input-shell:focus-within .sshia-select-chevron {
        transform: translateY(-50%) rotate(180deg);
        opacity: 1;
    }

    /* Textarea */
    .sshia-textarea {
        width: 100%;
        padding: 0.625rem 0.875rem;
        background: transparent;
        border: none;
        outline: none;
        font-size: 0.9375rem;
        color: var(--theme-color-body, #1f2937);
        border-radius: 0.5rem;
        line-height: 1.6;
        resize: vertical;
        min-height: 6rem;
        box-shadow: none !important;
    }

    .sshia-textarea::placeholder {
        color: var(--theme-color-body, #6b7280);
        opacity: 0.45;
    }

    .sshia-textarea:disabled {
        opacity: 0.55;
        cursor: not-allowed;
    }

    /* Help text */
    .sshia-help-text {
        margin-top: 0.3rem;
        font-size: 0.8rem;
        color: var(--theme-color-body, #6b7280);
        opacity: 0.8;
        line-height: 1.4;
    }

    /* Error text */
    .sshia-error-text {
        margin-top: 0.3rem;
        font-size: 0.8rem;
        color: #ef4444;
        display: flex;
        align-items: center;
        gap: 0.25rem;
        line-height: 1.4;
    }

    /* ─────────────────────────────────────────────────────────────
       SSHIA Dropdown Panel
    ───────────────────────────────────────────────────────────── */
    .sshia-dropdown-panel {
        background-color: var(--theme-bg-card, #ffffff);
        border: 1.5px solid var(--theme-divider-color, #e5e7eb);
        border-radius: 0.625rem;
        box-shadow: 0 10px 25px -5px rgb(0 0 0 / 0.12),
                    0 4px 10px -3px rgb(0 0 0 / 0.08);
        overflow: hidden;
        padding: 0.375rem 0;
    }

    /* Dropdown link item */
    .sshia-dropdown-link {
        display: flex;
        align-items: center;
        width: 100%;
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
        font-weight: 500;
        color: var(--theme-color-body, #374151);
        text-decoration: none;
        transition: background-color 150ms ease, color 150ms ease, padding-left 150ms ease;
        border-left: 3px solid transparent;
        white-space: nowrap;
    }

    .sshia-dropdown-link:hover,
    .sshia-dropdown-link:focus {
        background-color: color-mix(in srgb, var(--theme-primary, #16a34a) 8%, transparent);
        color: var(--theme-primary, #16a34a);
        border-left-color: var(--theme-primary, #16a34a);
        padding-left: 1.25rem;
        outline: none;
    }

    .sshia-dropdown-link:active {
        background-color: color-mix(in srgb, var(--theme-primary, #16a34a) 14%, transparent);
    }
}

/* Utility Styles */
@layer utilities {
    /*
     * Tailwind v4 dropped the built-in responsive container centering.
     * Re-define .container so that `container mx-auto px-4` works as expected:
     * full-width on mobile, capped at 1280px on xl screens, always centered.
     */
    .container {
        width: 100%;
        margin-left: auto;
        margin-right: auto;
        padding-left: 1rem;
        padding-right: 1rem;
    }

    @media (min-width: 640px) {
        .container {
            max-width: 640px;
            padding-left: 1.5rem;
            padding-right: 1.5rem;
        }
    }

    @media (min-width: 768px) {
        .container {
            max-width: 768px;
        }
    }

    @media (min-width: 1024px) {
        .container {
            max-width: 1024px;
            padding-left: 2rem;
            padding-right: 2rem;
        }
    }

    @media (min-width: 1280px) {
        .container {
            max-width: 1280px;
        }
    }

    @media (min-width: 1536px) {
        .container {
            max-width: 1536px;
        }
    }

    /* Full-width container utilities */
    .container-full {
        width: 100%;
        max-width: 100%;
        margin-left: auto;
        margin-right: auto;
    }
    
    .container-wide {
        width: 100%;
        max-width: 1920px;
        margin-left: auto;
        margin-right: auto;
    }
    
    /* Glassmorphism effect */
    .glass {
        @apply backdrop-blur-md bg-white/80;
    }
    
    .glass-dark {
        @apply backdrop-blur-md bg-gray-900/80;
    }
    
    /* Text truncation */
    .truncate-2 {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    
    .truncate-3 {
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    
    /* Smooth transitions */
    .transition-smooth {
        transition: all var(--transition-base);
    }
    
    /* Hide scrollbar but keep functionality */
    .scrollbar-hide {
        -ms-overflow-style: none;
        scrollbar-width: none;
    }
    
    .scrollbar-hide::-webkit-scrollbar {
        display: none;
    }
}

/* Animation Keyframes */
@keyframes fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fade-in-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slide-in-right {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

@keyframes slide-in-left {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

@keyframes pulse-slow {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Animation Classes */
.animate-fade-in {
    animation: fade-in 0.3s ease-out;
}

.animate-fade-in-up {
    animation: fade-in-up 0.6s ease-out;
}

.animate-slide-in-right {
    animation: slide-in-right 0.3s ease-out;
}

.animate-slide-in-left {
    animation: slide-in-left 0.3s ease-out;
}

.animate-pulse-slow {
    animation: pulse-slow 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Print Styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    body {
        background: white;
        color: black;
    }
    
    a {
        text-decoration: underline;
    }
}

/* Full-Width Layout Overrides */
/*
 * IMPORTANT: Only override max-width for header, footer, and nav wrappers.
 * Do NOT globally override .max-w-7xl / .max-w-6xl / .max-w-screen-xl etc.
 * as those are used by content sections and must retain their constrained widths.
 */

/* Force full-width ONLY for the direct inner wrappers of header, footer, and nav */
header > div > .max-w-screen-2xl,
header nav > div > .max-w-screen-2xl,
footer > div > .max-w-screen-2xl,
nav[data-navbar] > .max-w-screen-2xl {
    max-width: 100% !important;
}

/* Ensure mega menu panels span the full nav width */
nav[data-navbar] [x-show] {
    width: 100%;
}

/* Hero sections and full-bleed banners should be full width */
main section.section-full,
main .hero-full {
    width: 100%;
    max-width: 100%;
}

/* Ensure proper padding is maintained for header/footer full-width wrappers */
header .max-w-screen-2xl,
footer .max-w-screen-2xl,
nav .max-w-screen-2xl {
    padding-left: 1rem;
    padding-right: 1rem;
}

@media (min-width: 640px) {
    header .max-w-screen-2xl,
    footer .max-w-screen-2xl,
    nav .max-w-screen-2xl {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
}

@media (min-width: 1024px) {
    header .max-w-screen-2xl,
    footer .max-w-screen-2xl,
    nav .max-w-screen-2xl {
        padding-left: 2rem;
        padding-right: 2rem;
    }
}
