/**
 * Main Stylesheet - Organized Component Architecture
 * Briefed/PolicyPages Platform
 */

/* Tailwind CSS Base */
@tailwind base;
@tailwind components;
@tailwind utilities;

/* Utility Classes */
@import './utilities/accessibility.css';

/* Component Styles */
@import './components/modules.css';
@import './components/collapsible-sections.css';
@import './components/buttons.css';

/* Layout Styles */
@import './layouts/homepage.css';

/* Base Typography and Layout */
@layer base {
  html {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    font-size: 16px;
    line-height: 1.5;
  }
  
  body {
    @apply text-gray-900 bg-white antialiased;
    min-height: 100vh;
  }
  
  /* Improved focus management */
  *:focus {
    outline: 2px solid currentColor;
    outline-offset: 2px;
  }
  
  /* Link styling for accessibility */
  a {
    @apply text-blue-600 hover:text-blue-800 focus:text-blue-800;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
  }
  
  a:hover {
    text-decoration-thickness: 2px;
  }
  
  /* Heading hierarchy */
  h1, h2, h3, h4, h5, h6 {
    @apply font-semibold text-gray-900;
    line-height: 1.2;
  }
  
  h1 {
    @apply text-2xl sm:text-3xl lg:text-4xl;
  }
  
  h2 {
    @apply text-xl sm:text-2xl;
  }
  
  h3 {
    @apply text-lg sm:text-xl;
  }
  
  h4 {
    @apply text-base sm:text-lg;
  }
  
  /* Consistent spacing */
  p {
    @apply mb-4 leading-relaxed;
  }
  
  ul, ol {
    @apply mb-4 pl-6;
  }
  
  li {
    @apply mb-2;
  }
  
  /* Form elements */
  input, select, textarea {
    @apply block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500;
  }
  
  label {
    @apply block text-sm font-medium text-gray-700 mb-1;
  }
}

/* Component Layer Utilities */
@layer components {
  /* Skip links */
  .skip-links {
    @apply sr-only focus-within:not-sr-only bg-blue-900 p-2 z-50 relative;
  }
  
  .skip-link {
    @apply bg-blue-600 text-white px-4 py-2 rounded-md font-medium focus:outline-none focus:ring-4 focus:ring-blue-300 mr-2;
  }
  
  /* Main content container */
  .main-container {
    @apply max-w-4xl mx-auto px-4 py-8;
  }
  
  /* Page header */
  .page-header {
    @apply border-b-2 border-gray-200 mb-8;
  }
  
  .page-title {
    @apply text-2xl sm:text-3xl lg:text-4xl font-bold text-gray-900 mb-4 leading-tight text-center;
  }
  
  /* Dropdown menus */
  .dropdown {
    @apply absolute top-full right-0 mt-2 bg-white border-2 border-gray-200 rounded-lg shadow-lg p-4 hidden z-50;
    min-width: 250px;
  }
  
  .dropdown.show {
    @apply block;
  }
  
  .dropdown-title {
    @apply font-semibold text-gray-900 text-sm mb-3;
  }
  
  /* Keyboard shortcut display */
  .kbd {
    @apply px-2 py-1 bg-gray-100 border rounded text-xs font-mono;
  }
  
  /* Status indicators */
  .status-indicator {
    @apply inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium;
  }
  
  .status-active {
    @apply bg-green-100 text-green-800;
  }
  
  .status-consultation {
    @apply bg-yellow-100 text-yellow-800;
  }
  
  .status-published {
    @apply bg-blue-100 text-blue-800;
  }
  
  /* Loading states */
  .loading {
    @apply animate-pulse;
  }
  
  .loading-skeleton {
    @apply bg-gray-200 rounded;
  }
}

/* Custom CSS Variables for Theming */
:root {
  --primary-color: #1e40af;
  --secondary-color: #059669;
  --accent-color: #dc2626;
  --text-color: #111827;
  --bg-color: #ffffff;
  --border-color: #d1d5db;
}

/* CSS Custom Properties for Dynamic Theming */
.theme-blue {
  --primary-color: #1e40af;
  --primary-color-08: rgba(30, 64, 175, 0.08);
  --primary-color-15: rgba(30, 64, 175, 0.15);
  --primary-color-20: rgba(30, 64, 175, 0.2);
  --primary-color-25: rgba(30, 64, 175, 0.25);
  --primary-color-33: rgba(30, 64, 175, 0.33);
}

.theme-purple {
  --primary-color: #603970;
  --primary-color-08: rgba(96, 57, 112, 0.08);
  --primary-color-15: rgba(96, 57, 112, 0.15);
  --primary-color-20: rgba(96, 57, 112, 0.2);
  --primary-color-25: rgba(96, 57, 112, 0.25);
  --primary-color-33: rgba(96, 57, 112, 0.33);
}

.theme-green {
  --primary-color: #059669;
  --primary-color-08: rgba(5, 150, 105, 0.08);
  --primary-color-15: rgba(5, 150, 105, 0.15);
  --primary-color-20: rgba(5, 150, 105, 0.2);
  --primary-color-25: rgba(5, 150, 105, 0.25);
  --primary-color-33: rgba(5, 150, 105, 0.33);
}

/* Print Optimizations */
@media print {
  /* Hide interactive elements that shouldn't appear in print */
  .fixed, 
  #header-navigation, 
  #header-accessibility,
  .homepage-tools,
  .skip-links,
  #keyboard-shortcuts-toggle,
  #keyboard-shortcuts,
  .toolbar-button,
  .homepage-button,
  .btn-secondary,
  button:not(.module-toggle-button),
  [role="button"]:not(.module-toggle-button),
  .dropdown-menu,
  .relative > .absolute,
  nav[aria-label="Skip navigation"] {
    display: none !important;
  }
  
  /* Show collapsed sections content for print */
  .module-content[hidden] {
    display: block !important;
  }
  
  /* Reset backgrounds and shadows for print */
  .bg-gradient-to-r,
  .bg-gray-50,
  .bg-gray-100,
  .bg-blue-50,
  .bg-green-50 {
    background: white !important;
  }
  
  .shadow-lg, 
  .shadow-sm,
  .shadow-xl {
    box-shadow: none !important;
  }
  
  /* Simplify borders for print with better spacing */
  .border-2 {
    border: 1px solid #ccc !important;
    padding: 8pt !important;
  }
  
  .border-4 {
    border: 2px solid #ccc !important;
    padding: 10pt !important;
  }
  
  .border,
  .border-gray-200,
  .border-gray-300 {
    border: 1px solid #ddd !important;
    padding: 6pt !important;
  }
  
  /* Optimize typography for print */
  body {
    font-size: 11pt;
    line-height: 1.4;
    color: #000 !important;
    background: white !important;
  }
  
  h1 { 
    font-size: 18pt; 
    margin-bottom: 12pt;
    page-break-after: avoid;
  }
  
  h2 { 
    font-size: 14pt; 
    margin-top: 18pt;
    margin-bottom: 6pt;
    page-break-after: avoid;
  }
  
  h3 { 
    font-size: 12pt; 
    margin-top: 12pt;
    margin-bottom: 4pt;
    page-break-after: avoid;
  }
  
  h4 { 
    font-size: 11pt; 
    margin-top: 8pt;
    margin-bottom: 3pt;
    page-break-after: avoid;
  }
  
  /* Layout optimizations */
  .main-container,
  .max-w-content,
  .max-w-government {
    max-width: none;
    padding: 12pt;
    margin: 0;
  }
  
  .px-4,
  .px-6,
  .px-8 {
    padding-left: 8pt !important;
    padding-right: 8pt !important;
  }
  
  .py-4,
  .py-6,
  .py-8 {
    padding-top: 6pt !important;
    padding-bottom: 6pt !important;
  }
  
  /* Module spacing for print */
  .briefing-module,
  .homepage-module {
    break-inside: avoid;
    margin-bottom: 18pt;
    padding: 12pt;
    page-break-after: auto;
  }
  
  /* Ensure URLs are visible in print with proper spacing */
  a[href] {
    word-wrap: break-word;
    hyphens: auto;
  }
  
  a[href]:after {
    content: " (" attr(href) ")";
    font-size: 8pt;
    color: #666;
    font-weight: normal;
    word-break: break-all;
    display: inline-block;
    margin-left: 2pt;
    line-height: 1.2;
  }
  
  /* Special handling for document format cards */
  .grid a[href] {
    display: block !important;
    position: relative;
  }
  
  .grid a[href]:after {
    display: block !important;
    margin-top: 4pt;
    margin-left: 0;
    font-size: 7pt;
    line-height: 1.1;
    word-break: break-all;
    border-top: 1px solid #eee;
    padding-top: 2pt;
    margin-top: 6pt;
  }
  
  .grid a[href] .flex-shrink-0 {
    margin-bottom: 4pt;
  }
  
  a[href^="#"]:after,
  a[href^="javascript:"]:after,
  a[href^="mailto:"]:after {
    content: "";
  }
  
  /* Better paragraph spacing */
  p {
    margin-bottom: 8pt;
    line-height: 1.5;
  }
  
  /* List spacing */
  ul, ol {
    margin-bottom: 8pt;
    padding-left: 18pt;
  }
  
  li {
    margin-bottom: 3pt;
  }
  
  /* Page breaks */
  .page-break-before {
    page-break-before: always;
  }
  
  .page-break-after {
    page-break-after: always;
  }
  
  .page-break-avoid {
    page-break-inside: avoid;
  }
  
  /* Header optimizations for print */
  header {
    border-bottom: 2px solid #000 !important;
    margin-bottom: 18pt;
    padding-bottom: 12pt;
  }
  
  /* Footer optimizations */
  footer {
    border-top: 1px solid #ccc !important;
    margin-top: 18pt;
    padding-top: 12pt;
  }
}

/* Dark mode support (future enhancement) */
@media (prefers-color-scheme: dark) {
  .dark-mode-auto {
    --bg-color: #111827;
    --text-color: #f9fafb;
    --border-color: #374151;
  }
}