/* style.css - Main stylesheet for Link Directory application */

/* Color system tokens */
:root {
    --background: 220 20% 97%;
    --foreground: 222 47% 11%;
    --card: 0 0% 100%;
    --card-foreground: 222 47% 11%;
    --popover: 0 0% 100%;
    --popover-foreground: 222 47% 11%;
    --primary: 230 70% 55%;
    --primary-foreground: 0 0% 100%;
    --secondary: 220 14% 94%;
    --secondary-foreground: 222 47% 11%;
    --muted: 220 14% 96%;
    --muted-foreground: 220 9% 46%;
    --accent: 262 60% 55%;
    --accent-foreground: 0 0% 100%;
    --destructive: 0 72% 51%;
    --destructive-foreground: 0 0% 100%;
    --border: 220 13% 91%;
    --input: 220 13% 91%;
    --ring: 230 70% 55%;
    --radius: 0.75rem;
    --font-heading: 'Inter', ui-sans-serif, system-ui, sans-serif;
    --font-body: 'Inter', ui-sans-serif, system-ui, sans-serif;
}

.dark {
    --background: 224 30% 8%;
    --foreground: 210 20% 95%;
    --card: 224 25% 12%;
    --card-foreground: 210 20% 95%;
    --popover: 224 25% 12%;
    --popover-foreground: 210 20% 95%;
    --primary: 230 70% 60%;
    --primary-foreground: 0 0% 100%;
    --secondary: 224 20% 18%;
    --secondary-foreground: 210 20% 95%;
    --muted: 224 20% 16%;
    --muted-foreground: 218 11% 55%;
    --accent: 262 60% 60%;
    --accent-foreground: 0 0% 100%;
    --destructive: 0 72% 51%;
    --destructive-foreground: 0 0% 100%;
    --border: 224 15% 20%;
    --input: 224 15% 20%;
    --ring: 230 70% 60%;
}

/* Reset and base styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    border-color: hsl(var(--border));
}

body {
    background-color: hsl(var(--background));
    color: hsl(var(--foreground));
    font-family: var(--font-body);
    line-height: 1.5;
    overscroll-behavior: none;
    transition: background-color 0.3s, color 0.3s;
}

button, input, textarea, select {
    font-family: inherit;
}

/* Typography Utility */
.font-heading {
    font-family: var(--font-heading);
}

/* Layout & Sizing Utilities */
.min-h-screen { min-height: 100vh; min-height: 100dvh; }
.max-w-md { max-width: 28rem; }
.max-w-lg { max-width: 32rem; }
.max-w-xl { max-width: 36rem; }
.max-w-2xl { max-width: 42rem; }
.overflow-hidden { overflow: hidden; }

/* Positioning Utilities */
.relative { position: relative; }
.absolute { position: absolute; }
.top-2 { top: 0.5rem; }
.right-2 { right: 0.5rem; }
.left-2 { left: 0.5rem; }
.bottom-2 { bottom: 0.5rem; }
.top-4 { top: 1rem; }
.left-4 { left: 1rem; }
.right-4 { right: 1rem; }
.left-3 { left: 0.75rem; }
.left-3\.5 { left: 0.875rem; }
.right-3\.5 { right: 0.875rem; }
.top-1\/2 { top: 50%; }
.-translate-y-1\/2 { transform: translateY(-50%); }

/* Transition & Opacity Utilities */
.opacity-0 { opacity: 0; }
.group:hover .group-hover\:opacity-100 { opacity: 1; }
.transition-opacity { transition: opacity 0.2s ease-in-out; }
.transition-all { transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); }
.duration-300 { transition-duration: 300ms; }

/* Padding & Margin Extra Utilities */
.pl-10 { padding-left: 2.5rem; }
.pl-11 { padding-left: 2.75rem; }
.pr-4 { padding-right: 1rem; }
.pr-10 { padding-right: 2.5rem; }

/* Text Alignment Utilities */
.text-center { text-align: center; }

/* Font Size Extra Utilities */
.text-3xl { font-size: 1.875rem; }

/* Interactive & Hover State Utilities */
.hover\:bg-primary\/90:hover { background-color: hsla(var(--primary) / 0.9); }
.hover\:bg-muted:hover { background-color: hsl(var(--muted)); }
.hover\:text-foreground:hover { color: hsl(var(--foreground)); }
.hover\:text-destructive:hover { color: hsl(var(--destructive)); }
.hover\:bg-destructive\/10:hover { background-color: hsla(var(--destructive) / 0.1); }
.active\:scale-\[0\.98\]:active { transform: scale(0.98); }

/* Shadows Extra Utilities */
.shadow-primary\/20 { box-shadow: 0 4px 6px -1px hsla(var(--primary) / 0.2), 0 2px 4px -2px hsla(var(--primary) / 0.2); }
.shadow-primary\/10 { box-shadow: 0 4px 6px -1px hsla(var(--primary) / 0.1), 0 2px 4px -2px hsla(var(--primary) / 0.1); }

/* Safe Area support */
.safe-top {
    padding-top: env(safe-area-inset-top);
}
.safe-bottom {
    padding-bottom: env(safe-area-inset-bottom);
}

/* Colors mapped */
.bg-background { background-color: hsl(var(--background)); }
.bg-card { background-color: hsl(var(--card)); }
.bg-primary { background-color: hsl(var(--primary)); }
.bg-primary\/10 { background-color: hsla(var(--primary) / 0.1); }
.bg-secondary { background-color: hsl(var(--secondary)); }
.bg-muted { background-color: hsl(var(--muted)); }
.bg-accent\/20 { background-color: hsla(var(--accent) / 0.2); }
.bg-destructive { background-color: hsl(var(--destructive)); }
.bg-destructive\/10 { background-color: hsla(var(--destructive) / 0.1); }

.text-foreground { color: hsl(var(--foreground)); }
.text-card-foreground { color: hsl(var(--card-foreground)); }
.text-primary-foreground { color: hsl(var(--primary-foreground)); }
.text-secondary-foreground { color: hsl(var(--secondary-foreground)); }
.text-muted-foreground { color: hsl(var(--muted-foreground)); }
.text-accent-foreground { color: hsl(var(--accent-foreground)); }
.text-destructive { color: hsl(var(--destructive)); }
.text-destructive-foreground { color: hsl(var(--destructive-foreground)); }

.border-border { border-color: hsl(var(--border)); }

/* Grid / Flex Layouts */
.max-w-7xl { max-width: 80rem; }
.mx-auto { margin-left: auto; margin-right: auto; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.flex-1 { flex: 1 1 0%; }
.flex-shrink-0 { flex-shrink: 0; }

.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-5 { gap: 1.25rem; }
.gap-6 { gap: 1.5rem; }



/* Padding & Margin Utility */
.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-2\.5 { padding: 0.625rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.p-8 { padding: 2rem; }
.px-1 { padding-left: 0.25rem; padding-right: 0.25rem; }
.px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.px-3\.5 { padding-left: 0.875rem; padding-right: 0.875rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.py-1.5 { padding-top: 0.375rem; padding-bottom: 0.375rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.py-6 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.py-8 { padding-top: 2rem; padding-bottom: 2rem; }
.py-20 { padding-top: 5rem; padding-bottom: 5rem; }
.pb-2 { padding-bottom: 0.5rem; }
.pb-3 { padding-bottom: 0.75rem; }
.pb-24 { padding-bottom: 6rem; }
.pt-2 { padding-top: 0.5rem; }
.pt-4 { padding-top: 1rem; }
.pt-6 { padding-top: 1.5rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-5 { margin-bottom: 1.25rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-6 { margin-top: 1.5rem; }
.mx-2 { margin-left: 0.5rem; margin-right: 0.5rem; }
.-ml-2 { margin-left: -0.5rem; }
.space-y-1\.5 > * + * { margin-top: 0.375rem; }
.space-y-2 > * + * { margin-top: 0.5rem; }
.space-y-3 > * + * { margin-top: 0.75rem; }
.space-y-4 > * + * { margin-top: 1rem; }
.space-y-5 > * + * { margin-top: 1.25rem; }
.space-y-6 > * + * { margin-top: 1.5rem; }
.mr-1 { margin-right: 0.25rem; }
.mr-2 { margin-right: 0.5rem; }

/* Borders and Shadows */
.border { border: 1px solid hsl(var(--border)); }
.border-b { border-bottom: 1px solid hsl(var(--border)); }
.border-t { border-top: 1px solid hsl(var(--border)); }
.rounded-lg { border-radius: calc(var(--radius) - 0.25rem); }
.rounded-xl { border-radius: calc(var(--radius) - 0.125rem); }
.rounded-2xl { border-radius: var(--radius); }
.rounded-full { border-radius: 9999px; }
.shadow-sm { box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); }
.shadow-md { box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1); }
.shadow-lg { box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1); }
.shadow-2xl { box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); }

/* Header and Navigation */
header {
    background-color: hsla(var(--card) / 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}
.sticky {
    position: -webkit-sticky;
    position: sticky;
}
.top-0 { top: 0; }
.z-50 { z-index: 50; }

/* Buttons & Inputs */
button {
    cursor: pointer;
    border: none;
    background: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.h-9 { height: 2.25rem; }
.h-10 { height: 2.5rem; }
.h-11 { height: 2.75rem; }
.h-12 { height: 3rem; }
.w-3 { width: 0.75rem !important; }
.h-3 { height: 0.75rem !important; }
.w-3\.5 { width: 0.875rem !important; }
.h-3\.5 { height: 0.875rem !important; }
.w-4 { width: 1rem !important; }
.h-4 { height: 1rem !important; }
.w-5 { width: 1.25rem !important; }
.h-5 { height: 1.25rem !important; }
.w-6 { width: 1.5rem !important; }
.h-6 { height: 1.5rem !important; }
.w-8 { width: 2rem !important; }
.h-8 { height: 2rem !important; }
.w-9 { width: 2.25rem; }
.w-10 { width: 2.5rem; }
.w-12 { width: 3rem; }
.w-14 { width: 3.5rem; }
.w-16 { width: 4rem; }
.w-full { width: 100%; }

.input-focus, input:focus, textarea:focus, select:focus {
    outline: none;
    box-shadow: 0 0 0 2px hsla(var(--ring) / 0.3);
    border-color: hsl(var(--primary));
}

/* Cards & Badges */
.card-hover:hover {
    border-color: hsla(var(--primary) / 0.3);
    box-shadow: 0 10px 15px -3px hsla(var(--primary) / 0.05), 0 4px 6px -4px hsla(var(--primary) / 0.05);
}

/* Category Chips */
.category-chip {
    transition: all 0.2s ease-in-out;
}
.category-chip:hover {
    background-color: hsl(var(--secondary));
    color: hsl(var(--foreground));
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: hsl(var(--muted));
    border: 1px solid hsl(var(--border));
    transition: .3s;
}
.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: hsl(var(--card-foreground));
    transition: .3s;
}
input:checked + .slider {
    background-color: hsl(var(--primary));
}
input:checked + .slider:before {
    transform: translateX(20px);
    background-color: hsl(var(--primary-foreground));
}
.slider.round {
    border-radius: 34px;
}
.slider.round:before {
    border-radius: 50%;
}

/* Modals & Dialogs (Native HTML5 Dialog Backdrop Styling) */
dialog.modal-dialog {
    margin: auto;
    border: 1px solid hsl(var(--border));
    background: hsl(var(--card));
    box-shadow: var(--shadow-2xl);
    outline: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

dialog::backdrop {
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

dialog[open] {
    animation: modalShow 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes modalShow {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Drag & Drop Reordering Indicators */
.cursor-grab {
    cursor: -webkit-grab;
    cursor: grab;
}
.cursor-grabbing {
    cursor: -webkit-grabbing;
    cursor: grabbing;
}
.sortable-ghost {
    opacity: 0.3;
    border: 2px dashed hsl(var(--primary));
    background-color: hsla(var(--primary) / 0.05);
}

/* Spinners & Loaders */
.animate-spin {
    animation: spin 1s linear infinite;
}
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Custom switch for display none vs block dark elements */
.dark .dark\:block { display: block !important; }
.dark .dark\:hidden { display: none !important; }

/* Text utils */
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.font-mono { font-family: var(--font-mono); }
.hidden { display: none; }

/* Toast Notifications */
#toast-container {
    pointer-events: none;
}
#toast-container > div {
    pointer-events: auto;
}

/* Media queries moved to bottom to resolve cascade specificity override */
@media (min-width: 640px) {
    .sm\:flex-row { flex-direction: row; }
    .sm\:items-center { align-items: center; }
    .sm\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .sm\:block { display: block; }
}
@media (min-width: 768px) {
    .md\:flex { display: flex; }
    .md\:hidden { display: none; }
    .md\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .md\:px-8 { padding-left: 2rem; padding-right: 2rem; }
    .md\:pb-8 { padding-bottom: 2rem; }
}
@media (min-width: 1024px) {
    .lg\:grid-cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
