/* ---------------------------------------------------------------------------
 * Refined UI foundation (Linear/Vercel-inspired): typography, depth, motion.
 * ------------------------------------------------------------------------- */
html { -webkit-text-size-adjust: 100%; }
body {
    /* Nicer Inter letterforms + crisp rendering, on a soft cool canvas with
       a faint top highlight for depth. */
    font-feature-settings: "cv02", "cv03", "cv04", "cv11", "ss01";
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background-color: #f6f8fb;
    background-image:
        radial-gradient(1200px 480px at 50% -10%, rgba(99, 102, 241, 0.06), transparent 70%);
    background-attachment: fixed;
    color: #1e293b;
}
h1, h2, h3, h4 { letter-spacing: -0.014em; }
h1 { letter-spacing: -0.02em; }

/* Tasteful default motion on interactive chrome (not form fields). */
a, button { transition: color .15s ease, background-color .15s ease, border-color .15s ease, box-shadow .15s ease, transform .15s ease; }

/* Reusable surfaces / buttons — used by the chrome and key pages. */
.card {
    background: #fff;
    border: 1px solid #e7ebf0;
    border-radius: 0.875rem;
    box-shadow: 0 1px 2px rgb(15 23 42 / 0.04), 0 4px 16px -6px rgb(15 23 42 / 0.08);
}
.card-hover { transition: box-shadow .2s ease, transform .2s ease, border-color .2s ease; }
.card-hover:hover {
    box-shadow: 0 2px 4px rgb(15 23 42 / 0.05), 0 12px 28px -10px rgb(15 23 42 / 0.14);
    border-color: #cdd5df;
    transform: translateY(-1px);
}
.btn-primary {
    background-image: linear-gradient(180deg, #6366f1, #4f46e5);
    color: #fff;
    box-shadow: 0 1px 2px rgb(79 70 229 / 0.35), inset 0 1px 0 rgb(255 255 255 / 0.12);
}
.btn-primary:hover { background-image: linear-gradient(180deg, #5b5bef, #4338ca); }
.btn-primary:active { transform: translateY(0.5px); }

/* App-wide cohesion: many pages use the default `bg-blue-600` for primary
   buttons while the brand accent is indigo. Recolor button-like elements to
   the brand accent (links/text keep their own colors). Specificity + !important
   beats the `hover:bg-blue-700` utility. */
a.bg-blue-600, button.bg-blue-600,
[type="submit"].bg-blue-600, [type="button"].bg-blue-600 {
    background-color: #4f46e5 !important;
}
a.bg-blue-600:hover, button.bg-blue-600:hover,
[type="submit"].bg-blue-600:hover, [type="button"].bg-blue-600:hover {
    background-color: #4338ca !important;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 7px;
    height: 7px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #cdd5df;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Hide scrollbar until hover */
.hover-scrollbar {
    scrollbar-width: none;
}
.hover-scrollbar::-webkit-scrollbar {
    display: none;
}
.hover-scrollbar:hover {
    scrollbar-width: thin;
}
.hover-scrollbar:hover::-webkit-scrollbar {
    display: block;
}

/* Alpine.js cloak */
[x-cloak] { display: none !important; }

/* Smooth transitions */
.sidebar-transition {
    transition: width 200ms ease-in-out;
}

/* Keyboard shortcut keys */
kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    padding: 0 0.375rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.6875rem;
    font-weight: 500;
    line-height: 1;
    color: #6b7280;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 0.25rem;
    box-shadow: 0 1px 0 #e5e7eb;
}

/* Drag and drop states */
.dragging {
    opacity: 0.5;
}
.drag-over {
    border-top: 2px solid #6366f1 !important;
}

/* Focus ring utility */
.focus-ring {
    outline: none;
}
.focus-ring:focus-visible {
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #6366f1;
    border-radius: 0.375rem;
}

/* Pulse animation for notification dot */
@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
.animate-pulse-dot {
    animation: pulse-dot 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Subtle gradient bg for auth pages */
.auth-gradient {
    background: linear-gradient(135deg, #f8fafc 0%, #eef2ff 50%, #faf5ff 100%);
}

/* ---------------------------------------------------------------------------
 * Tom Select: brand override so the searchable dropdown / tag-chip multi
 * matches the rest of the form (rounded-xl, brand focus ring) and reads as
 * a dropdown at a glance (chevron, lighter gray fill, hover affordance).
 * ------------------------------------------------------------------------- */
/* Tom Select copies the source <select>'s classes (form-input, border,
 * rounded-lg, padding, bg from INPUT_CSS) onto its outer .ts-wrapper div,
 * which renders a second border around .ts-control. Strip the wrapper
 * down to a positioning container so only the inner control shows
 * the field's visible chrome. */
.ts-wrapper {
    background: transparent !important;
    border: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    border-radius: 0 !important;
}
.ts-wrapper.single .ts-control,
.ts-wrapper.multi .ts-control {
    border-radius: 0.625rem;         /* slightly less round to differ from text inputs */
    border: 1px solid #e5e7eb;       /* gray-200 */
    background: #f9fafb;             /* gray-50 — distinguishes selects from white inputs */
    min-height: 40px;
    padding: 6px 12px;
    font-size: 0.875rem;
    color: #111827;
    box-shadow: none;
    transition: border-color 120ms, background 120ms, box-shadow 120ms;
}
.ts-wrapper.single .ts-control:hover,
.ts-wrapper.multi .ts-control:hover {
    border-color: #cbd5e1;
    background: #fff;
}
.ts-wrapper.focus .ts-control {
    border-color: #93c5fd;
    background: #fff;
    box-shadow: 0 0 0 3px #dbeafe;
}
.ts-wrapper.disabled .ts-control,
.ts-wrapper.disabled .ts-control:hover { background: #f3f4f6; color: #9ca3af; }
.ts-wrapper .ts-control input { font-size: 0.875rem; color: #111827; }
.ts-wrapper .ts-control input::placeholder { color: #9ca3af; }
/* Single-select chevron: signals the field is a dropdown without
   relying on color alone. Multi-selects have a different affordance
   (the remove buttons on chips). */
.ts-wrapper.single .ts-control {
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.875rem center;
    background-size: 12px 12px;
    padding-right: 2.25rem;
}
.ts-wrapper.multi .ts-control > .item {
    background: #eff6ff;             /* brand-50 */
    color: #1d4ed8;                  /* brand-700 */
    border: 1px solid #bfdbfe;       /* brand-200 */
    border-radius: 9999px;
    padding: 2px 9px;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.25;
}
.ts-wrapper.multi .ts-control > .item .remove {
    color: #1d4ed8;
    border: none;
    margin-left: 4px;
    padding: 0 2px;
    text-decoration: none;
}
/* clear_button plugin: the CDN's flex layout on .ts-control can drop the
 * clear button inline at the start. Force it back to the right gutter
 * (left of the chevron) with higher specificity than the CDN rules. */
.ts-wrapper .ts-control { position: relative; }
.ts-wrapper.plugin-clear_button .clear-button,
.ts-wrapper.plugin-clear_button.single .clear-button,
.ts-wrapper.plugin-clear_button.focus .clear-button {
    position: absolute !important;
    top: 50% !important;
    right: 30px !important;          /* leave room for the chevron */
    left: auto !important;
    transform: translateY(-50%) !important;
    margin: 0 !important;
    padding: 0 4px !important;
    background: transparent !important;
    color: #9ca3af !important;
    font-size: 1rem !important;
    line-height: 1 !important;
    cursor: pointer !important;
    z-index: 2 !important;
    flex: 0 0 auto !important;
}
.ts-wrapper.plugin-clear_button .clear-button:hover { color: #4b5563 !important; }
.ts-dropdown {
    border-radius: 0.625rem;
    border: 1px solid #e5e7eb;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    margin-top: 4px;
    overflow: hidden;
}
.ts-dropdown .option { font-size: 0.875rem; padding: 8px 12px; color: #1f2937; }
.ts-dropdown .active { background: #eff6ff; color: #1d4ed8; }
.ts-dropdown .option:hover { background: #f3f4f6; }

/* ---------------------------------------------------------------------------
 * Form input shell: gives every text/number/date field a subtle gray-50
 * fill so it visually pairs with selects (instead of looking like flat
 * white labels). Only applied via the .form-input utility so we don't
 * affect global Django admin or random inputs.
 * ------------------------------------------------------------------------- */
.form-input,
input.form-input,
textarea.form-input,
input[type="text"].form-input,
input[type="number"].form-input,
input[type="date"].form-input,
input[type="email"].form-input,
input[type="url"].form-input {
    background-color: #f9fafb;
    transition: background 120ms, border-color 120ms, box-shadow 120ms;
}
.form-input:hover { background-color: #fff; border-color: #cbd5e1; }
.form-input:focus { background-color: #fff; }
/* Native date input: surface the calendar icon a bit so the affordance
   is obvious (Chrome hides it by default unless hovered). */
input[type="date"].form-input::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.6;
    filter: invert(0.3);
}
input[type="date"].form-input:hover::-webkit-calendar-picker-indicator {
    opacity: 1;
}

/* Toast UI Editor: tighten the chrome so it blends with our form shell. */
.wysiwyg-wrapper .toastui-editor-defaultUI {
    border-radius: 0.75rem;
    border-color: #e5e7eb;
}
.wysiwyg-wrapper .toastui-editor-defaultUI-toolbar {
    border-top-left-radius: 0.75rem;
    border-top-right-radius: 0.75rem;
}

