/*
 * Devicel Core Stylesheet
 * Version: 1.0.0
 * Modern CSS with CSS Variables, Grid, Flexbox
 * Cross-browser compatible (Chrome, Firefox, Safari, Edge)
 */

/* ========================================
   CSS Custom Properties (Variables)
   ======================================== */
:root {
    /* Primary Brand Colors */
    --primary: #0077B6;
    --primary-light: #48CAE4;
    --primary-dark: #005a8c;
    --primary-gradient: linear-gradient(135deg, #0077B6, #48CAE4);
    
    /* Accent Colors */
    --accent: #FF9F1C;
    --accent-light: #FFC300;
    --accent-gradient: linear-gradient(135deg, #FF9F1C, #FFC300);
    
    /* Text Colors */
    --text-primary: #1a1a1a;
    --text-secondary: #4b5563;
    --text-muted: #6b7280;
    --text-light: #9ca3af;
    --text-white: #ffffff;
    
    /* Background Colors */
    --bg-white: #ffffff;
    --bg-light: #f9fafb;
    --bg-gray: #f3f4f6;
    --bg-dark: #1a1a1a;
    
    /* Border Colors */
    --border: #e5e7eb;
    --border-dark: #d1d5db;
    
    /* Status Colors */
    --success: #10b981;
    --success-light: #d1fae5;
    --error: #ef4444;
    --error-light: #fee2e2;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --info: #3b82f6;
    --info-light: #dbeafe;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.12);
    --shadow-primary: 0 4px 14px rgba(0, 119, 182, 0.25);
    --shadow-accent: 0 4px 14px rgba(255, 159, 28, 0.25);
    
    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;
    
    /* Spacing Scale (8px base) */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;
    --space-16: 64px;
    
    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-size-xs: 12px;
    --font-size-sm: 13px;
    --font-size-base: 14px;
    --font-size-md: 15px;
    --font-size-lg: 16px;
    --font-size-xl: 18px;
    --font-size-2xl: 20px;
    --font-size-3xl: 24px;
    --font-size-4xl: 30px;
    --font-size-5xl: 36px;
    
    /* Line Heights */
    --leading-tight: 1.25;
    --leading-normal: 1.5;
    --leading-relaxed: 1.7;
    
    /* Font Weights */
    --font-normal: 400;
    --font-medium: 500;
    --font-semibold: 600;
    --font-bold: 700;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;
    
    /* Z-Index Scale */
    --z-dropdown: 50;
    --z-sticky: 100;
    --z-modal: 200;
    --z-tooltip: 300;
    --z-toast: 400;
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    color: var(--text-primary);
    background-color: var(--bg-light);
    line-height: var(--leading-relaxed);
    min-height: 100vh;
}

/* Prevent FOUC */
body {
    animation: pageLoad 0.15s ease-out forwards;
    opacity: 0;
}

@keyframes pageLoad {
    to { opacity: 1; }
}

/* Links */
a {
    color: inherit;
    text-decoration: none;
    transition: color var(--transition-base);
}

a:hover {
    color: var(--primary);
}

/* Images */
img,
picture,
video,
canvas,
svg {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Form Elements Reset */
button,
input,
select,
textarea {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    color: inherit;
}

button {
    cursor: pointer;
    border: none;
    background: none;
}

/* Remove default list styles */
ul,
ol {
    list-style: none;
}

/* Tables */
table {
    border-collapse: collapse;
    width: 100%;
}

/* ========================================
   Typography
   ======================================== */
h1, h2, h3, h4, h5, h6 {
    font-weight: var(--font-bold);
    line-height: var(--leading-tight);
    color: var(--text-primary);
}

h1 { font-size: var(--font-size-5xl); }
h2 { font-size: var(--font-size-4xl); }
h3 { font-size: var(--font-size-3xl); }
h4 { font-size: var(--font-size-2xl); }
h5 { font-size: var(--font-size-xl); }
h6 { font-size: var(--font-size-lg); }

p {
    margin-bottom: var(--space-4);
    color: var(--text-secondary);
}

p:last-child {
    margin-bottom: 0;
}

strong, b {
    font-weight: var(--font-semibold);
}

small {
    font-size: var(--font-size-sm);
}

/* ========================================
   Layout Utilities
   ======================================== */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-5);
}

.container-sm { max-width: 640px; }
.container-md { max-width: 768px; }
.container-lg { max-width: 1024px; }
.container-xl { max-width: 1280px; }

/* Flexbox */
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

/* Grid */
.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

/* Visibility */
.hidden { display: none !important; }
.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;
}

/* ========================================
   Livewire & Alpine.js Compatibility
   ======================================== */
[x-cloak],
[wire\:loading] {
    display: none !important;
}

[wire\:loading\.delay] {
    display: block !important;
}

[wire\:snapshot]:not([wire\:id]) {
    visibility: hidden;
}

[wire\:offline] {
    display: none;
}

html.no-js * {
    visibility: visible;
}

/* Livewire Loading States */
.livewire-loading {
    opacity: 0.6;
    pointer-events: none;
    transition: opacity var(--transition-base);
}

.livewire-loaded {
    opacity: 1;
}

/* ========================================
   Skeleton Loaders
   ======================================== */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-gray) 25%,
        var(--border) 50%,
        var(--bg-gray) 75%
    );
    background-size: 200% 100%;
    animation: skeleton 1.5s ease-in-out infinite;
    border-radius: var(--radius-md);
}

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

.skeleton-text {
    height: 14px;
    margin-bottom: var(--space-2);
}

.skeleton-title {
    height: 24px;
    width: 60%;
    margin-bottom: var(--space-3);
}

.skeleton-image {
    aspect-ratio: 1;
    width: 100%;
}

/* ========================================
   Scrollbar Styling
   ======================================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-gray);
}

::-webkit-scrollbar-thumb {
    background: var(--border-dark);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-dark) var(--bg-gray);
}

/* ========================================
   Selection Styling
   ======================================== */
::selection {
    background-color: var(--primary);
    color: var(--text-white);
}

/* ========================================
   Focus States (Accessibility)
   ======================================== */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ========================================
   Print Styles
   ======================================== */
@media print {
    *,
    *::before,
    *::after {
        background: transparent !important;
        color: #000 !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }
    
    a,
    a:visited {
        text-decoration: underline;
    }
    
    img {
        page-break-inside: avoid;
    }
    
    p, h2, h3 {
        orphans: 3;
        widows: 3;
    }
    
    h2, h3 {
        page-break-after: avoid;
    }
}

/* FOUC Prevention */
body{opacity:0;animation:fadeIn 0.2s ease-out 0.1s forwards}
@keyframes fadeIn{to{opacity:1}}
[x-cloak],[wire\:loading]{display:none!important}
.livewire-loading{opacity:0}
.livewire-loaded{opacity:1;transition:opacity 0.15s ease}

/* FOUC Prevention Enhanced */
body{opacity:0;animation:fadeIn 0.2s ease-out 0.1s forwards}
@keyframes fadeIn{to{opacity:1}}
[x-cloak],[wire\:loading]{display:none!important}
