/*
 * Base Styles for SorakaSync Django Application
 * Global resets, typography, and CSS custom properties
 *
 * NOTE: Tailwind CSS v4 wraps all utilities/components in @layer.
 * Unlayered CSS beats layered CSS regardless of load order.
 * DO NOT add utility classes here that duplicate Tailwind utilities
 * (e.g. .flex, .hidden, .text-sm, .bg-primary) — they will override
 * Tailwind's theme-aware versions and break theming.
 */

/* ==========================================================================
   CSS Reset and Base Styles
   Wrapped in @layer base so Tailwind utilities (@layer utilities) and
   DaisyUI components (DaisyUI layers) can override margin/padding/box-sizing.
   Unlayered resets beat ALL layered CSS, which breaks p-4, gap-6, d-card-body, etc.
   ========================================================================== */

@layer base {
    * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
    }
}

/* ==========================================================================
   CSS Custom Properties (Variables)
   ========================================================================== */

:root {
    /* Legacy colors — used by older components not yet migrated to DaisyUI tokens */
    --primary-blue: #2563eb;
    --primary-blue-hover: #1d4ed8;
    --primary-blue-light: #eff4ff;

    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #374151;
    --gray-700: #1f2937;

    --red-50: #fef2f2;
    --red-600: #dc2626;
    --red-700: #b91c1c;

    --yellow-50: #fefce8;
    --yellow-200: #fde047;
    --yellow-300: #fef3c7;
    --yellow-600: #d97706;
    --yellow-700: #92400e;

    --green-50: #dcfce7;
    --green-700: #166534;

    --pink-500: #ec4899;

    /* Typography */
    --font-family-base: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-family-mono: 'Courier New', monospace;

    /* Custom spacing tokens (used by gap-xs, mb-sm, p-lg, etc.) */
    --spacing-xs: 0.125rem;    /* 2px */
    --spacing-sm: 0.25rem;     /* 4px */
    --spacing-md: 0.5rem;      /* 8px */
    --spacing-lg: 1rem;        /* 16px */
    --spacing-xl: 1.5rem;      /* 24px */
    --spacing-2xl: 2rem;       /* 32px */

    /* Border Radius */
    --border-radius-sm: 4px;
    --border-radius-md: 6px;
    --border-radius-lg: 8px;
    --border-radius-xl: 12px;
    --border-radius-full: 50%;

    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 2px 10px rgba(0,0,0,0.1);

    /* Transitions */
    --transition-fast: all 0.2s;
    --transition-normal: all 0.3s;
}

/* ==========================================================================
   Base Typography and Body Styles
   ========================================================================== */

/* Reduces accidental double-tap zoom on iOS/Safari; pinch-zoom still works. */
html,
body {
    touch-action: manipulation;
}

body {
    font-family: var(--font-family-base);
    line-height: 1.6;
}

/* ==========================================================================
   Custom Spacing Utilities (unique names, not in Tailwind)
   ========================================================================== */

.gap-xs { gap: var(--spacing-xs); }
.gap-sm { gap: var(--spacing-sm); }
.gap-md { gap: var(--spacing-md); }
.gap-lg { gap: var(--spacing-lg); }
.gap-xl { gap: var(--spacing-xl); }
.gap-2xl { gap: var(--spacing-2xl); }

.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }
.mb-xl { margin-bottom: var(--spacing-xl); }
.mb-2xl { margin-bottom: var(--spacing-2xl); }

.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.mt-xl { margin-top: var(--spacing-xl); }
.mt-2xl { margin-top: var(--spacing-2xl); }

.p-sm { padding: var(--spacing-sm); }
.p-md { padding: var(--spacing-md); }
.p-lg { padding: var(--spacing-lg); }
.p-xl { padding: var(--spacing-xl); }
.p-2xl { padding: var(--spacing-2xl); }

/* Legacy transition utility */
.transition-normal { transition: var(--transition-normal); }

/* ==========================================================================
   Focus and Accessibility
   ========================================================================== */

/* Improved focus styles for accessibility
   Limit the default blue outline for interactive controls; modal status
   buttons use their own selected border styling. */
*:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* Remove focus ring from status buttons; they will rely on selected state */
.multiple-medication-administration-modal .status-btn:focus,
.administer-medication-modal .status-btn:focus {
    outline: none;
    box-shadow: none;
}

/* Skip link: visually hidden until keyboard focus (clip + off-screen — no “peeking” from box size) */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    border: 0;
    white-space: nowrap;
    z-index: 1000;
}

.skip-link:focus,
.skip-link:focus-visible {
    left: 6px;
    top: 6px;
    width: auto;
    height: auto;
    margin: 0;
    padding: 8px;
    overflow: visible;
    clip: auto;
    clip-path: none;
    white-space: normal;
    background: var(--color-primary);
    color: white;
    text-decoration: none;
    border-radius: var(--border-radius-sm);
}
