/* Pal Tenders - Main CSS Entry Point */
/* Created: 2025 - Consolidated Styles */

/* ========================================
   CORE SYSTEM IMPORTS
   ======================================== */

@import 'core/variables.css';
@import 'core/components.css';
@import 'core/utilities.css';
@import 'base.css';
/* pages.css removed - functionality split into pages/list-pages.css, pages/detail-pages.css, pages/submission-forms.css */
@import 'legacy.css';

/* ========================================
   BASE STYLES
   ======================================== */

* {
  box-sizing: border-box;
}

*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  line-height: 1.15;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

body {
  margin: 0;
  font-family: var(--font-family-primary);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-normal);
  color: var(--color-text-primary);
  background-color: var(--color-white);
  text-align: var(--text-align-start);
  direction: rtl;
  
  /* Enhanced text rendering */
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   MAIN CONTAINER - Mobile-First Responsive
   ======================================== */

main {
  width: 100%;
  margin: var(--space-lg) auto !important;
  padding: var(--space-lg) !important;
  background: var(--color-white);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-lg);
  min-height: calc(100vh - 200px);
}

/* Tablet and up */
@media (min-width: 768px) {
  main {
    max-width: var(--container-lg) !important;
    margin: var(--space-xl) auto !important;
    padding: var(--space-2xl) !important;
  }
}

/* Desktop and up */
@media (min-width: 1024px) {
  main {
    max-width: var(--container-xl) !important;
    margin: var(--space-2xl) auto !important;
    padding: var(--space-4xl) !important;
  }
}

/* ========================================
   TYPOGRAPHY ENHANCEMENTS
   ======================================== */

h1, h2, h3, h4, h5, h6 {
  margin-top: 0;
  margin-bottom: var(--space-md);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
  color: var(--color-text-primary);
}

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

p {
  margin-top: 0;
  margin-bottom: var(--space-lg);
  line-height: var(--line-height-relaxed);
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast) var(--ease-out);
}

a:hover {
  color: var(--color-primary-dark);
  text-decoration: underline;
}

a:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* ========================================
   IMAGE STYLES
   ======================================== */

img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
  * {
    color: black !important;
    background: white !important;
    box-shadow: none !important;
  }
  
  main {
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    max-width: none !important;
  }
  
  .btn,
  .pagination,
  .modal,
  .dropdown {
    display: none !important;
  }
  
  a[href^="http"]:after {
    content: " (" attr(href) ")";
    font-size: 12px;
    color: #666;
  }
}

/* ========================================
   RESPONSIVE CONTAINER
   ======================================== */

@media (max-width: 1200px) {
  main {
    max-width: 95% !important;
    margin: var(--space-lg) auto !important;
    padding: var(--space-3xl) !important;
  }
}

/* ========================================
   ACCESSIBILITY ENHANCEMENTS
   ======================================== */

/* Enhanced focus indicators for keyboard navigation */
*:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: var(--focus-ring-offset);
  border-radius: var(--radius-xs);
}

/* Reduced motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4);
  }
}

/* Skip to main content link for screen readers */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: var(--color-primary);
  color: white;
  padding: var(--space-sm) var(--space-md);
  text-decoration: none;
  border-radius: var(--radius-sm);
  z-index: 9999;
}

.skip-link:focus {
  top: 6px;
}

/* ========================================
   RESPONSIVE TYPOGRAPHY WITH FLUID SCALING
   ======================================== */

h1 { 
  font-size: var(--font-size-fluid-hero);
  line-height: var(--line-height-tight);
}
h2 { 
  font-size: var(--font-size-fluid-3xl);
}
h3 { 
  font-size: var(--font-size-fluid-2xl);
}
h4 { 
  font-size: var(--font-size-fluid-xl);
}
h5 { 
  font-size: var(--font-size-fluid-lg);
}
h6 { 
  font-size: var(--font-size-fluid-base);
}

/* ========================================
   ENHANCED MOBILE RESPONSIVENESS
   ======================================== */

@media (max-width: 768px) {
  main {
    max-width: 98% !important;
    margin: var(--space-md) auto !important;
    padding: var(--space-xl) !important;
    border-radius: var(--radius-lg);
  }
  
  /* Enhanced mobile typography */
  h1 { font-size: clamp(1.75rem, 5vw, 2.5rem); }
  h2 { font-size: clamp(1.5rem, 4vw, 2rem); }
  h3 { font-size: clamp(1.25rem, 3.5vw, 1.75rem); }
  h4 { font-size: clamp(1.125rem, 3vw, 1.5rem); }
  h5 { font-size: clamp(1rem, 2.5vw, 1.25rem); }
  h6 { font-size: clamp(0.875rem, 2vw, 1rem); }
  
  /* Mobile table improvements */
  table {
    font-size: var(--font-size-sm);
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
  
  th, td {
    padding: var(--space-sm) var(--space-md);
    min-width: 120px;
  }
  
  /* Mobile form improvements */
  .form-control,
  .form-select,
  textarea {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
  }
  
  /* Mobile button improvements */
  .btn {
    padding: var(--space-md) var(--space-lg);
    font-size: var(--font-size-base);
    min-height: 44px; /* Touch target size */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
  }
  
  /* Mobile card improvements */
  .card {
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-lg);
  }
  
  .card-body,
  .card-header,
  .card-footer {
    padding: var(--space-lg);
  }
  
  /* Mobile grid improvements */
  .row {
    margin: 0 calc(-1 * var(--space-sm));
  }
  
  .col,
  [class*="col-"] {
    padding: 0 var(--space-sm);
    margin-bottom: var(--space-md);
  }
  
  /* Mobile navigation improvements */
  .nav-link {
    padding: var(--space-md) var(--space-lg);
    font-size: var(--font-size-base);
    min-height: 44px;
    display: flex;
    align-items: center;
  }
  
  /* Mobile search improvements */
  .search-box {
    flex-direction: column;
    gap: var(--space-md);
  }
  
  .search-input {
    width: 100%;
    font-size: 16px;
  }
  
  .search-btn {
    width: 100%;
    min-height: 44px;
  }
  
  /* Mobile filter improvements */
  .filter-controls {
    flex-direction: column;
    gap: var(--space-md);
  }
  
  .filter-select {
    width: 100%;
    font-size: 16px;
    min-height: 44px;
  }
  
  /* Mobile pagination improvements */
  .pagination {
    justify-content: center;
    flex-wrap: wrap;
    gap: var(--space-xs);
  }
  
  .page-link {
    min-width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-sm);
  }
  
  /* Mobile stats improvements */
  .stats-container {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }
  
  .stat-card {
    padding: var(--space-lg);
    min-height: 80px;
  }
  
  /* Mobile tender/job card improvements */
  .tender-row,
  .job-card {
    padding: var(--space-lg);
    margin-bottom: var(--space-md);
    border-radius: var(--radius-lg);
  }
  
  .tender-title,
  .job-title {
    font-size: var(--font-size-lg);
    line-height: var(--line-height-tight);
  }
  
  /* Mobile organization card improvements */
  .org-card {
    padding: var(--space-lg);
    text-align: center;
  }
  
  .org-avatar {
    margin: 0 auto var(--space-md);
  }
  
  /* Mobile form improvements */
  .form-section {
    margin-bottom: var(--space-xl);
  }
  
  .form-row {
    flex-direction: column;
    gap: var(--space-md);
  }
  
  .form-group {
    width: 100%;
  }
  
  /* Mobile contact form improvements */
  .contact-form {
    padding: var(--space-lg);
  }
  
  .contact-info {
    margin-top: var(--space-xl);
  }
  
  /* Mobile about page improvements */
  .about-content {
    padding: var(--space-lg);
  }
  
  .about-grid {
    grid-template-columns: 1fr;
    gap: var(--space-lg);
  }
}

@media (max-width: 480px) {
  main {
    margin: var(--space-xs) auto !important;
    padding: var(--space-lg) !important;
    border-radius: var(--radius-md);
  }
  
  /* Extra small mobile improvements */
  h1 { font-size: clamp(1.5rem, 4.5vw, 2rem); }
  h2 { font-size: clamp(1.25rem, 3.5vw, 1.75rem); }
  h3 { font-size: clamp(1.125rem, 3vw, 1.5rem); }
  
  /* Smaller touch targets for very small screens */
  .btn {
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-sm);
    min-height: 40px;
  }
  
  .nav-link {
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-sm);
    min-height: 40px;
  }
  
  /* Compact cards */
  .card-body,
  .card-header,
  .card-footer {
    padding: var(--space-md);
  }
  
  .tender-row,
  .job-card,
  .org-card {
    padding: var(--space-md);
  }
  
  /* Compact forms */
  .form-control,
  .form-select,
  textarea {
    padding: var(--space-sm) var(--space-md);
  }
  
  /* Compact search */
  .search-input {
    padding: var(--space-sm) var(--space-md);
  }
  
  /* Compact pagination */
  .page-link {
    min-width: 36px;
    height: 36px;
    font-size: var(--font-size-xs);
  }
  
  /* Compact stats */
  .stat-card {
    padding: var(--space-md);
    min-height: 60px;
  }
  
  .stat-number {
    font-size: var(--font-size-xl);
  }
  
  .stat-label {
    font-size: var(--font-size-sm);
  }
}

/* ========================================
   HIGH CONTRAST MODE SUPPORT
   ======================================== */

@media (prefers-contrast: high) {
  :root {
    --color-gray-300: #999999;
    --color-gray-400: #777777;
    --color-gray-500: #555555;
  }
  
  .btn {
    border-width: 2px;
  }
  
  .card {
    border-width: 2px;
  }
  
  .form-control {
    border-width: 2px;
  }
}

/* ========================================
   TOUCH DEVICE OPTIMIZATIONS
   ======================================== */

@media (hover: none) and (pointer: coarse) {
  /* Larger touch targets for touch devices */
  .btn,
  .nav-link,
  .page-link,
  .form-control,
  .form-select {
    min-height: 44px;
  }
  
  /* Remove hover effects on touch devices */
  .btn:hover,
  .nav-link:hover,
  .page-link:hover {
    transform: none;
  }
  
  /* Enhanced focus states for touch */
  .btn:focus,
  .nav-link:focus,
  .page-link:focus {
    outline: 3px solid var(--color-primary);
    outline-offset: 2px;
  }
}

/* ========================================
   LANDSCAPE MOBILE OPTIMIZATIONS
   ======================================== */

@media (max-width: 768px) and (orientation: landscape) {
  main {
    padding: var(--space-md) !important;
  }
  
  .tender-list-header,
  .job-list-header {
    padding: var(--space-lg) var(--space-md);
  }
  
  .stats-container {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
  }
  
  .form-row {
    flex-direction: row;
    gap: var(--space-md);
  }
  
  .form-group {
    flex: 1;
  }
}

/* ========================================
   DARK MODE SUPPORT (Future Enhancement)
   ======================================== */

@media (prefers-color-scheme: dark) {
  /* Dark mode styles can be added here */
  /* This is a placeholder for future dark mode implementation */
}

/* ========================================
   PERFORMANCE OPTIMIZATIONS
   ======================================== */

/* Optimize animations for mobile */
@media (max-width: 768px) {
  .card-hover:hover {
    transform: none;
  }
  
  .btn:hover {
    transform: none;
  }
  
  /* Reduce animation complexity on mobile */
  .fade-in,
  .slide-up,
  .bounce-in {
    animation-duration: 0.3s;
  }
}

/* ========================================
   ACCESSIBILITY IMPROVEMENTS
   ======================================== */

/* Better focus indicators for mobile */
@media (max-width: 768px) {
  *:focus-visible {
    outline: 3px solid var(--color-primary);
    outline-offset: 3px;
    border-radius: var(--radius-sm);
  }
  
  /* Ensure sufficient color contrast */
  .text-muted {
    color: var(--color-gray-600) !important;
  }
  
  /* Better link underlines */
  a:hover {
    text-decoration-thickness: 2px;
    text-underline-offset: 2px;
  }
}

/* ========================================
   PRINT OPTIMIZATIONS
   ======================================== */

@media print {
  /* Hide mobile-specific elements */
  .mobile-menu,
  .mobile-menu-toggle {
    display: none !important;
  }
  
  /* Ensure good print layout */
  main {
    max-width: none !important;
    margin: 0 !important;
    padding: var(--space-md) !important;
    box-shadow: none !important;
    border-radius: 0 !important;
  }
  
  /* Optimize text for print */
  body {
    font-size: 12pt;
    line-height: 1.4;
  }
  
  h1, h2, h3, h4, h5, h6 {
    page-break-after: avoid;
  }
  
  .card,
  .tender-row,
  .job-card {
    page-break-inside: avoid;
    border: 1px solid #ccc !important;
    box-shadow: none !important;
  }
}

/* ========================================
   TENDER DETAIL PAGE LAYOUT
   ======================================== */

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 350px;
  gap: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

.detail-main {
  min-width: 0;
}

.detail-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 2rem;
  font-size: 0.9rem;
  color: #6b7280;
}

.breadcrumb-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #3b82f6;
  text-decoration: none;
  transition: color 0.2s;
}

.breadcrumb-link:hover {
  color: #1d4ed8;
}

.breadcrumb-separator {
  color: #9ca3af;
}

.breadcrumb-current {
  color: #374151;
  font-weight: 500;
}

/* Card Styles */
.card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.card-header {
  padding: 1.5rem;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
}

.card-content {
  padding: 1.5rem;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: #111827;
}

/* Tender Header */
.tender-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.tender-title-section {
  flex: 1;
  min-width: 0;
}

.tender-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: #111827;
  margin: 0 0 1rem 0;
  line-height: 1.3;
}

.badge-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-featured {
  background: #fbbf24;
  color: #92400e;
}

.badge-category {
  background: #dbeafe;
  color: #1e40af;
}

.badge-location {
  background: #f3f4f6;
  color: #374151;
}

.badge-active {
  background: #d1fae5;
  color: #065f46;
}

.badge-urgent {
  background: #fef3c7;
  color: #92400e;
}

.badge-expired {
  background: #fee2e2;
  color: #991b1b;
}

.action-buttons {
  display: flex;
  gap: 0.75rem;
  flex-shrink: 0;
}

/* Sections */
.section {
  margin-bottom: 2rem;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #111827;
  margin: 0 0 1rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tender-description {
  line-height: 1.6;
  color: #374151;
}

/* Organization Info */
.organization-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  background: #f9fafb;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}

.org-link {
  color: #3b82f6;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

.org-link:hover {
  color: #1d4ed8;
}

/* Info Grid */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.info-item {
  padding: 1rem;
  background: #f9fafb;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}

.info-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #6b7280;
  margin: 0 0 0.5rem 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.info-value {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #111827;
  font-weight: 500;
}

.categories-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Tender Info */
.tender-info {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.deadline-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  color: #111827;
}

.deadline-warning {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding: 0.5rem;
  background: #fef3c7;
  color: #92400e;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
}

.posted-date {
  margin: 0;
  color: #6b7280;
  font-size: 0.875rem;
}

/* Action Buttons */
.action-buttons-vertical {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s;
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
}

.btn-primary {
  background: #3b82f6;
  color: white;
}

.btn-primary:hover {
  background: #1d4ed8;
  color: white;
}

.btn-outline {
  background: transparent;
  color: #6b7280;
  border: 1px solid #d1d5db;
}

.btn-outline:hover {
  background: #f9fafb;
  color: #374151;
  border-color: #9ca3af;
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
}

.btn-lg {
  padding: 1rem 2rem;
  font-size: 1rem;
}

/* Contact Info */
.contact-info {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.contact-item {
  padding: 0.75rem 0;
  border-bottom: 1px solid #f3f4f6;
}

.contact-item:last-child {
  border-bottom: none;
}

.contact-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #6b7280;
  margin: 0 0 0.25rem 0;
}

.contact-value {
  margin: 0;
  color: #111827;
}

.contact-link a {
  color: #3b82f6;
  text-decoration: none;
  transition: color 0.2s;
}

.contact-link a:hover {
  color: #1d4ed8;
}

/* File Attachment */
.file-attachment-simple {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: #f9fafb;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}

.file-icon {
  font-size: 2rem;
  color: #6b7280;
}

.file-info {
  flex: 1;
  min-width: 0;
}

.file-name {
  font-weight: 500;
  color: #111827;
  margin-bottom: 0.25rem;
  word-break: break-all;
}

.file-size {
  font-size: 0.75rem;
  color: #6b7280;
}

/* Responsive Design */
@media (max-width: 1024px) {
  .detail-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  .detail-sidebar {
    order: -1;
  }
}

@media (max-width: 768px) {
  .detail-grid {
    padding: 1rem;
    gap: 1rem;
  }
  
  .tender-header {
    flex-direction: column;
    align-items: stretch;
  }
  
  .action-buttons {
    justify-content: stretch;
  }
  
  .info-grid {
    grid-template-columns: 1fr;
  }
}