@tailwind base;
@tailwind components;
@tailwind utilities;

/* RTL Support for Arabic */
.rtl {
  direction: rtl;
}

.ltr {
  direction: ltr;
}

/* RTL-specific utilities */
@layer utilities {
  .rtl .text-left {
    text-align: right;
  }
  
  .rtl .text-right {
    text-align: left;
  }
  
  .rtl .ml-auto {
    margin-left: 0;
    margin-right: auto;
  }
  
  .rtl .mr-auto {
    margin-right: 0;
    margin-left: auto;
  }
  
  .rtl .border-l-2 {
    border-left-width: 0;
    border-right-width: 2px;
  }
  
  .rtl .border-r-2 {
    border-right-width: 0;
    border-left-width: 2px;
  }
  
  .rtl .pl-3 {
    padding-left: 0;
    padding-right: 0.75rem;
  }
  
  .rtl .pr-3 {
    padding-right: 0;
    padding-left: 0.75rem;
  }
}

/* Amazon-style Design System - Clean, Functional, Minimal
All colors MUST be HSL. Focus on usability over decoration.
*/

@layer base {
:root {
    /* Amazon-style Base Colors - Clean and Minimal */
    --background: 0 0% 100%;
    --foreground: 0 0% 15%;

    /* Clean Card System */
    --card: 0 0% 100%;
    --card-foreground: 0 0% 15%;
    --card-border: 0 0% 90%;

    /* Popover & Modal System */
    --popover: 0 0% 100%;
    --popover-foreground: 0 0% 15%;
    
    /* Amazon-style Orange Primary */
    --primary: 36 100% 50%; /* Amazon Orange */
    --primary-foreground: 0 0% 100%;
    --primary-hover: 36 100% 45%;

    /* Clean Secondary Colors */
    --secondary: 0 0% 96%;
    --secondary-foreground: 0 0% 15%;
    --secondary-hover: 0 0% 94%;
    
    /* Amazon-style Blue Accent */
    --accent: 211 100% 50%; /* Amazon Blue */
    --accent-foreground: 0 0% 100%;
    --accent-hover: 211 100% 45%;

    /* Minimal Status Colors */
    --success: 120 60% 35%;
    --success-foreground: 0 0% 100%;
    --warning: 45 100% 50%;
    --warning-foreground: 0 0% 15%;
    --destructive: 0 75% 50%;
    --destructive-foreground: 0 0% 100%;
    --info: 211 100% 50%;
    --info-foreground: 0 0% 100%;

    /* Clean UI Colors */
    --muted: 0 0% 96%;
    --muted-foreground: 0 0% 45%;

    /* Clean Border System */
    --border: 0 0% 90%;
    --border-light: 0 0% 95%;
    --input: 0 0% 90%;
    --input-focus: 211 100% 50%;
    --ring: 211 100% 50%;

    /* Amazon-style Shadows - Minimal */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    --shadow-lg: 0 4px 6px -1px rgb(0 0 0 / 0.1);

    /* Simple Border Radius */
    --radius: 0.25rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;

    --sidebar-background: 0 0% 98%;

    --sidebar-foreground: 240 5.3% 26.1%;

    --sidebar-primary: 240 5.9% 10%;

    --sidebar-primary-foreground: 0 0% 98%;

    --sidebar-accent: 240 4.8% 95.9%;

    --sidebar-accent-foreground: 240 5.9% 10%;

    --sidebar-border: 220 13% 91%;

    --sidebar-ring: 217.2 91.2% 59.8%;
  }

  .dark {
    /* Amazon-style Dark Mode (Optional) */
    --background: 0 0% 9%;
    --foreground: 0 0% 95%;

    --card: 0 0% 9%;
    --card-foreground: 0 0% 95%;
    --card-border: 0 0% 15%;

    --popover: 0 0% 9%;
    --popover-foreground: 0 0% 95%;

    --primary: 36 100% 50%;
    --primary-foreground: 0 0% 15%;
    --primary-hover: 36 100% 55%;

    --secondary: 0 0% 15%;
    --secondary-foreground: 0 0% 95%;
    --secondary-hover: 0 0% 20%;

    --accent: 211 100% 60%;
    --accent-foreground: 0 0% 9%;
    --accent-hover: 211 100% 65%;

    --muted: 0 0% 15%;
    --muted-foreground: 0 0% 65%;

    --border: 0 0% 15%;
    --border-light: 0 0% 20%;
    --input: 0 0% 15%;
    --input-focus: 211 100% 60%;
    --ring: 211 100% 60%;
    --sidebar-background: 240 5.9% 10%;
    --sidebar-foreground: 240 4.8% 95.9%;
    --sidebar-primary: 224.3 76.3% 48%;
    --sidebar-primary-foreground: 0 0% 100%;
    --sidebar-accent: 240 3.7% 15.9%;
    --sidebar-accent-foreground: 240 4.8% 95.9%;
    --sidebar-border: 240 3.7% 15.9%;
    --sidebar-ring: 217.2 91.2% 59.8%;
  }
}

@layer base {
  * {
    @apply border-border;
  }

  body {
    @apply bg-background text-foreground;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  /* Amazon-style Typography */
  h1 { @apply text-3xl font-semibold text-foreground; }
  h2 { @apply text-2xl font-semibold text-foreground; }
  h3 { @apply text-xl font-semibold text-foreground; }
  h4 { @apply text-lg font-medium text-foreground; }
  h5 { @apply text-base font-medium text-foreground; }
  h6 { @apply text-sm font-medium text-foreground; }

  /* Amazon-style Links */
  a {
    @apply text-accent hover:text-accent-hover hover:underline transition-colors duration-150;
  }

  /* Clean Amazon-style Cards */
  .amazon-card {
    @apply bg-card border border-card-border rounded-md p-4 shadow-sm hover:shadow-md transition-shadow duration-150;
  }

  /* Amazon-style Buttons */
  .amazon-button-primary {
    @apply bg-primary hover:bg-primary-hover text-primary-foreground font-medium px-4 py-2 rounded-md transition-colors duration-150;
  }

  .amazon-button-secondary {
    @apply bg-secondary hover:bg-secondary-hover text-secondary-foreground border border-border font-medium px-4 py-2 rounded-md transition-colors duration-150;
  }

  /* Enhanced RTL Support */
  [dir="rtl"] {
    text-align: right;
  }

  /* Logical margin classes */
  .ltr\:mr-1 {
    margin-inline-end: 0.25rem;
  }
  
  .ltr\:mr-2 {
    margin-inline-end: 0.5rem;
  }
  
  .ltr\:mr-3 {
    margin-inline-end: 0.75rem;
  }
  
  .ltr\:mr-4 {
    margin-inline-end: 1rem;
  }
  
  .ltr\:ml-2 {
    margin-inline-start: 0.5rem;
  }
  
  .ltr\:ml-3 {
    margin-inline-start: 0.75rem;
  }
  
  .ltr\:ml-4 {
    margin-inline-start: 1rem;
  }
  
  .ltr\:ml-auto {
    margin-inline-start: auto;
  }
  
  .ltr\:mr-auto {
    margin-inline-end: auto;
  }
  
  .rtl\:mr-2 {
    margin-inline-end: 0.5rem;
  }
  
  .rtl\:ml-2 {
    margin-inline-start: 0.5rem;
  }
  
  .rtl\:ml-auto {
    margin-inline-start: auto;
  }
  
  .rtl\:mr-auto {
    margin-inline-end: auto;
  }

  /* Enhanced spacing for RTL */
  [dir="rtl"] .space-x-1 > :not([hidden]) ~ :not([hidden]) {
    --tw-space-x-reverse: 1;
    margin-right: calc(0.25rem * var(--tw-space-x-reverse));
    margin-left: calc(0.25rem * calc(1 - var(--tw-space-x-reverse)));
  }
  
  [dir="rtl"] .space-x-2 > :not([hidden]) ~ :not([hidden]) {
    --tw-space-x-reverse: 1;
    margin-right: calc(0.5rem * var(--tw-space-x-reverse));
    margin-left: calc(0.5rem * calc(1 - var(--tw-space-x-reverse)));
  }
  
  [dir="rtl"] .space-x-3 > :not([hidden]) ~ :not([hidden]) {
    --tw-space-x-reverse: 1;
    margin-right: calc(0.75rem * var(--tw-space-x-reverse));
    margin-left: calc(0.75rem * calc(1 - var(--tw-space-x-reverse)));
  }

  /* Enhanced Arabic typography */
  [dir="rtl"] body {
    font-family: 'Noto Sans Arabic', 'Segoe UI', 'Tahoma', 'Arial', sans-serif;
    line-height: 1.6;
  }
  
  [dir="rtl"] h1, [dir="rtl"] h2, [dir="rtl"] h3, [dir="rtl"] h4, [dir="rtl"] h5, [dir="rtl"] h6 {
    font-weight: 600;
    line-height: 1.4;
  }

  /* Enhanced form elements RTL */
  [dir="rtl"] input,
  [dir="rtl"] textarea,
  [dir="rtl"] select {
    text-align: right;
    padding-left: 0.75rem;
    padding-right: 1rem;
  }
  
  [dir="rtl"] input[type="search"] {
    direction: rtl;
  }

  /* Icon mirroring for RTL */
  [dir="rtl"] .rtl\:rotate-180 {
    transform: rotate(180deg);
  }
  
  [dir="rtl"] .rtl\:scale-x-flip {
    transform: scaleX(-1);
  }

  /* Enhanced button and flex layouts */
  [dir="rtl"] .flex-row-reverse {
    flex-direction: row-reverse;
  }
  
  [dir="rtl"] .justify-end {
    justify-content: flex-start;
  }
  
  [dir="rtl"] .justify-start {
    justify-content: flex-end;
  }

  /* Navigation improvements for RTL */
  [dir="rtl"] .sidebar-nav a {
    padding-left: 1.5rem;
    padding-right: 1rem;
  }
  
  [dir="rtl"] .breadcrumb-separator {
    transform: rotate(180deg);
  }
}