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

:root {
    --font-sans: "Inter var";

    --background: 0 0% 100%;
    --foreground: 240 10% 3.9%;
    --card: 0 0% 100%;
    --card-foreground: 240 10% 3.9%;
    --popover: 0 0% 100%;
    --popover-foreground: 240 10% 3.9%;
    --primary: 240 5.9% 10%;
    --primary-foreground: 0 0% 98%;
    --secondary: 240 4.8% 95.9%;
    --secondary-foreground: 240 5.9% 10%;
    --muted: 240 4.8% 95.9%;
    --muted-foreground: 240 3.8% 46.1%;
    --accent: 240 4.8% 95.9%;
    --accent-foreground: 240 5.9% 10%;
    --destructive: 0 84.2% 60.2%;
    --destructive-foreground: 0 0% 98%;
    --border: 240 5.9% 90%;
    --input: 240 5.9% 90%;
    --ring: 240 5% 64.9%;
    --radius: 0.5rem;

    --success: 132, 95.3%, 33.3%, 0.74;
    --success-foreground: 109 55% 28%;

    --info: 223 78% 42%;
    --info-foreground: 225 100% 50%;

    --attention: 45 90% 45%;
    --attention-foreground: 60 98.4% 48.8% 0.82;
}
@layer base {
    .dark {
        --background: 240 10% 3.9%;
        --foreground: 0 0% 98%;
        --card: 240 10% 3.9%;
        --card-foreground: 0 0% 98%;
        --popover: 240 10% 3.9%;
        --popover-foreground: 0 0% 98%;
        --primary: 0 0% 98%;
        --primary-foreground: 240 5.9% 10%;
        --secondary: 240 3.7% 15.9%;
        --secondary-foreground: 0 0% 98%;
        --muted: 240 3.7% 15.9%;
        --muted-foreground: 240 5% 64.9%;
        --accent: 240 3.7% 15.9%;
        --accent-foreground: 0 0% 98%;
        --destructive: 0 62.8% 30.6%;
        --destructive-foreground: 0 85.7% 97.3%;
        --border: 240 3.7% 15.9%;
        --input: 240 3.7% 15.9%;
        --ring: 240 4.9% 83.9%;
        --radius: 0.5rem;

        --success: 109 55% 28%;
        --success-foreground: 109 55% 28%;

        --attention: 45, 90%, 45%, 0.8;
        --attention-foreground: 60 98.4% 48.8% 0.82;
    }
}

@layer base {
    * {
        @apply border-border;
    }
    body {
        @apply bg-background text-foreground;
        font-feature-settings:
                "rlig" 1,
                "calt" 1;
    }

    .code-sample {
        @apply max-h-[650px] min-h-[350px] overflow-x-auto rounded-lg border bg-zinc-950 dark:bg-zinc-900;
    }

    .code-sample pre {
        @apply min-h-[350px];
    }

    .code-sample span {
        @apply bg-zinc-950;
    }
    input.error {
        @apply border-red-400;
    }

    label.error {
        @apply text-destructive;
    }

    input.error:focus-visible {
        @apply ring-destructive;
    }
}

@layer components {
    .h1 {
        @apply text-4xl font-bold tracking-tight;
    }

    .h2 {
        @apply text-2xl font-semibold tracking-tight;
    }

    .h3 {
        @apply text-lg font-bold;
    }

    .h4 {
        @apply text-base font-semibold;
    }

    .select-ghost {
        @apply
        bg-transparent
        border border-transparent
        rounded-md
        px-3 py-2
        text-sm
        text-gray-800
        hover:bg-secondary
        focus:outline-none
        focus:bg-white
        focus:border-primary
        transition;
    }

    .trix-content {
        @apply text-muted-foreground leading-relaxed max-w-full overflow-hidden;
    }

    .trix-content > *:first-child {
        @apply mt-0;
    }

    .trix-content > *:last-child {
        @apply mb-0;
    }

    .trix-content h1 {
        @apply text-2xl font-bold tracking-tight text-foreground mt-8 mb-4;
    }

    .trix-content h2 {
        @apply text-xl font-semibold tracking-tight text-foreground mt-6 mb-3;
    }

    .trix-content h3 {
        @apply text-lg font-semibold text-foreground mt-5 mb-2;
    }

    .trix-content h4 {
        @apply text-base font-semibold text-foreground mt-4 mb-2;
    }

    .trix-content p {
        @apply my-3;
    }

    .trix-content a {
        @apply text-primary underline underline-offset-4 hover:opacity-80;
    }

    .trix-content strong {
        @apply font-semibold text-foreground;
    }

    .trix-content ul {
        @apply my-3 ml-5 list-disc marker:text-muted-foreground;
    }

    .trix-content ol {
        @apply my-3 ml-5 list-decimal marker:text-muted-foreground;
    }

    .trix-content ul ul,
    .trix-content ul ol,
    .trix-content ol ul,
    .trix-content ol ol {
        @apply my-1 ml-5;
    }

    .trix-content li {
        @apply my-1 pl-1;
    }

    .trix-content blockquote {
        @apply my-4 border-l-4 border-border pl-4 italic;
    }

    .trix-content pre {
        @apply my-4 overflow-x-auto rounded-lg bg-muted p-4 text-sm leading-relaxed;
    }

    .trix-content code {
        @apply rounded bg-muted px-1.5 py-0.5 text-sm;
    }

    .trix-content pre code {
        @apply bg-transparent p-0;
    }

    .trix-content img {
        @apply max-w-full h-auto rounded-md;
    }

    .trix-content hr {
        @apply my-6 border-border;
    }

    .trix-content figure {
        @apply my-4;
    }

    .trix-content figcaption {
        @apply mt-2 text-center text-sm text-muted-foreground;
    }

    trix-editor {
        @apply rounded-md border border-input px-3 py-2 focus-visible:ring-2 focus-visible:ring-ring max-w-full;
    }

    /* Le contenu du Trix editor doit se replier et non déborder horizontalement */
    trix-editor {
        overflow-wrap: break-word;
    }

    trix-editor *,
    trix-editor {
        word-break: break-word;
    }

    dialog {
        max-width: calc(100% - 1.5rem);
    }

    fieldset {
        @apply border border-border rounded-lg p-6;
    }

    legend {
        @apply text-sm font-semibold text-foreground px-2 bg-primary/5 rounded-md uppercase tracking-wider;
    }
}

input[type="range"] {
    display: inline-block;
    vertical-align: middle;
    font-size: 1em;
    font-family: Arial, sans-serif;
}

/* input[type="range"]:focus,
input[type="number"]:focus {
  box-shadow: 0 0 3px 1px #4b81dd;
  outline: none;
} */

input[type="range"] {
    -webkit-appearance: none;
    margin-right: 15px;
    min-width: 200px;
    height: 7px;
    background: #f4f4f5;
    border-radius: 5px;
    background-image: linear-gradient(#000, #000);
    background-repeat: no-repeat;
}

/* Input Thumb */
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background: #fff;
    cursor: ew-resize;
    box-shadow: 0 0 2px 0 #000;
    transition: background 0.3s ease-in-out;
}

input[type="range"]::-moz-range-thumb {
    -webkit-appearance: none;
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background: #fff;
    cursor: ew-resize;
    box-shadow: 0 0 2px 0 #000;
    transition: background 0.3s ease-in-out;
}

input[type="range"]::-ms-thumb {
    -webkit-appearance: none;
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background: #fff;
    cursor: ew-resize;
    box-shadow: 0 0 2px 0 #000;
    transition: background 0.3s ease-in-out;
}

/* input[type="range"]::-webkit-slider-thumb:hover {
  background: #a1a1aa;
}

input[type="range"]::-moz-range-thumb:hover {
  background: #a1a1aa;
}

input[type="range"]::-ms-thumb:hover {
  background: #a1a1aa;
} */

input[type="range"]::-moz-range-track {
    -webkit-appearance: none;
    box-shadow: none;
    border: none;
    background: transparent;
}

input[type="range"]::-ms-track {
    -webkit-appearance: none;
    box-shadow: none;
    border: none;
    background: transparent;
}

.st-accordion .st-accordion__icon:before {
    content: "▼";
    display: inline-block;
    margin-right: 5px;
    font-size: 80%;
    text-decoration: none;
    transform: rotate(-90deg);
}
.st-accordion .st-accordion__icon--opened:before {
    transform: rotate(0deg);
}

.st-accordion .st-accordion__content:not(.st-accordion__content--visible) {
    height: 0;
    opacity: 0;
    visibility: hidden;
    overflow: hidden;
    transition: all 0.2s;
}
.st-accordion .st-accordion__content.st-accordion__content--visible {
    opacity: 1;
    visibility: visible;
    overflow: hidden;
    transition: all 0.2s;
}

/* Media Library */
.media-library {
    @apply flex flex-col gap-4;
}

.media-toolbar {
    @apply flex items-center justify-between gap-3 pb-3 border-b border-border;
}

.media-toolbar-search {
    @apply relative flex-1 max-w-xs;
}

.media-toolbar-search input {
    @apply w-full pl-9 pr-3 py-2 text-sm border border-input rounded-lg bg-background focus:ring-2 focus:ring-ring focus:border-ring;
}

.media-toolbar-search svg {
    @apply absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground pointer-events-none;
}

.media-toolbar-actions {
    @apply flex items-center gap-2;
}

.media-grid {
    @apply grid grid-cols-4 sm:grid-cols-5 md:grid-cols-6 gap-2;
}

.media-card {
    @apply relative rounded-lg overflow-hidden border-2 border-transparent bg-secondary transition-all duration-150;
    aspect-ratio: 1 / 1;
}

.media-card:hover {
    @apply border-primary/40 ring-1 ring-primary/20;
}

.media-card.selected {
    @apply border-primary ring-2 ring-primary/30;
}

.media-card > label {
    @apply block w-full h-full;
}

.media-card-thumbnail {
    @apply w-full h-full object-cover block;
}

.media-card-thumbnail-placeholder {
    @apply w-full h-full flex items-center justify-center bg-secondary text-muted-foreground;
}

.media-card-overlay {
    @apply absolute inset-0 bg-gradient-to-t from-black/60 via-transparent to-transparent opacity-0 transition-opacity duration-150 pointer-events-none;
}

.media-card:hover .media-card-overlay {
    @apply opacity-100;
}

.media-card.selected .media-card-overlay {
    @apply opacity-100;
}

.media-card.uploading .media-card-overlay {
    @apply opacity-100;
}

.media-card.uploading .progress-ring-container {
    @apply absolute inset-0 z-10 flex items-center justify-center pointer-events-none;
}

.media-card.uploading .progress-ring {
    @apply -rotate-90;
}

.media-card.uploading .progress-ring-circle {
    transition: stroke-dashoffset 0.3s ease;
}

.media-card.uploading .progress-ring-text {
    @apply absolute text-xs font-semibold text-white;
}

.media-card.uploading .status {
    @apply text-xs text-center mt-1;
}

.media-card-filename {
    @apply absolute bottom-0 left-0 right-0 px-2 py-1.5 text-xs text-white truncate;
}

.media-card-checkbox {
    @apply absolute top-2 left-2 w-5 h-5 rounded border-2 border-white bg-black/30 backdrop-blur-sm flex items-center justify-center transition-all duration-150;
}

.media-card.selected .media-card-checkbox {
    @apply bg-primary border-primary;
}

.media-card-checkbox svg {
    @apply w-3 h-3 text-white opacity-0 transition-opacity duration-150;
}

.media-card.selected .media-card-checkbox svg {
    @apply opacity-100;
}

.media-card-dropdown {
    @apply absolute top-1 right-1 z-10 opacity-0 transition-opacity duration-150;
}

.media-card:hover .media-card-dropdown {
    @apply opacity-100;
}

/* Upload Zone */
.upload-zone {
    @apply relative border-2 border-dashed border-border rounded-lg p-8 text-center transition-all duration-200;
}

.upload-zone:hover {
    @apply border-primary/50 bg-primary/5;
}

.upload-zone.dragover {
    @apply border-primary bg-primary/10 scale-[1.01];
}

.upload-zone-icon {
    @apply mx-auto w-12 h-12 text-muted-foreground mb-3;
}

.upload-zone-text {
    @apply text-sm text-muted-foreground;
}

.upload-zone-text strong {
    @apply text-foreground font-medium;
}

.upload-zone-hint {
    @apply text-xs text-muted-foreground/70 mt-2;
}

/* Media selection footer */
.media-selection-footer {
    @apply flex items-center justify-between pt-3 border-t border-border;
}

.media-selection-count {
    @apply text-sm text-muted-foreground;
}