/* ==========================================================================
   DevShield WP — Custom styles
   Layered on top of Tailwind CSS (loaded via CDN).
   ========================================================================== */

/* ---------- Base ---------- */
* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
        'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.6;
    background-color: hsl(var(--background));
    color: hsl(var(--foreground));
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* ---------- Custom scrollbar ---------- */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: hsl(var(--muted));
}

::-webkit-scrollbar-thumb {
    background: hsl(var(--muted-foreground) / 0.4);
    border-radius: 6px;
    border: 2px solid hsl(var(--muted));
}

::-webkit-scrollbar-thumb:hover {
    background: hsl(var(--muted-foreground) / 0.6);
}

* {
    scrollbar-width: thin;
    scrollbar-color: hsl(var(--muted-foreground) / 0.4) hsl(var(--muted));
}

/* Long-list scroll container (used in admin tables) */
.scroll-area {
    max-height: 24rem;
    overflow-y: auto;
    scrollbar-width: thin;
}

/* ---------- Selection ---------- */
::selection {
    background: hsl(158 64% 51% / 0.25);
    color: hsl(var(--foreground));
}

/* ---------- Focus ring ---------- */
:focus-visible {
    outline: 2px solid hsl(158 64% 51% / 0.6);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ---------- Line clamp utilities ---------- */
.line-clamp-1 {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ---------- Gradient text helper ---------- */
.gradient-text {
    background: linear-gradient(to right, #059669, #14b8a6);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

.gradient-text-rose {
    background: linear-gradient(to right, #e11d48, #dc2626);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

/* ---------- Card hover effects ---------- */
.card-hover {
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}
.card-hover:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px -8px rgba(5, 150, 105, 0.15);
}

/* ---------- Animation keyframes ---------- */
@keyframes ds-shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-6px); }
    20%, 40%, 60%, 80% { transform: translateX(6px); }
}
.animate-shake { animation: ds-shake 0.6s ease-in-out infinite; }

@keyframes ds-flash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
.animate-flash { animation: ds-flash 0.8s ease-in-out infinite; }

@keyframes ds-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.04); opacity: 0.92; }
}
.animate-pulse-strong { animation: ds-pulse 1.2s ease-in-out infinite; }

@keyframes ds-glitch {
    0%, 100% { transform: translate(0); filter: hue-rotate(0deg); }
    20% { transform: translate(-2px, 1px); filter: hue-rotate(45deg); }
    40% { transform: translate(2px, -1px); filter: hue-rotate(-45deg); }
    60% { transform: translate(-1px, 2px); filter: hue-rotate(90deg); }
    80% { transform: translate(1px, -2px); filter: hue-rotate(-90deg); }
}
.animate-glitch { animation: ds-glitch 0.5s steps(2) infinite; }

@keyframes ds-zoom-in {
    0% { transform: scale(0.6); opacity: 0; }
    60% { transform: scale(1.08); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}
.animate-zoom-in { animation: ds-zoom-in 0.5s ease-out; }

@keyframes ds-slide-down {
    0% { transform: translateY(-100%); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}
.animate-slide-down { animation: ds-slide-down 0.4s ease-out; }

@keyframes ds-slide-up {
    0% { transform: translateY(20px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}
.animate-slide-up { animation: ds-slide-up 0.4s ease-out; }

@keyframes ds-fade-in {
    0% { opacity: 0; }
    100% { opacity: 1; }
}
.animate-fade-in { animation: ds-fade-in 0.3s ease-out; }

@keyframes ds-spin {
    to { transform: rotate(360deg); }
}
.ds-spin {
    animation: ds-spin 0.7s linear infinite;
}

/* ---------- Toast notifications ---------- */
.ds-toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: 0.75rem;
    background-color: hsl(var(--card));
    color: hsl(var(--card-foreground));
    border: 1px solid hsl(var(--border));
    box-shadow: 0 10px 30px -10px rgba(0,0,0,0.25);
    font-size: 0.875rem;
    min-width: 18rem;
    max-width: 22rem;
    animation: ds-slide-down 0.25s ease-out;
}

.ds-toast-success { border-color: hsl(158 64% 51% / 0.4); }
.ds-toast-success .ds-toast-icon { color: #059669; }
.ds-toast-error   { border-color: hsl(0 84% 60% / 0.4); }
.ds-toast-error   .ds-toast-icon { color: #dc2626; }
.ds-toast-info    { border-color: hsl(199 89% 48% / 0.4); }
.ds-toast-info    .ds-toast-icon { color: #0284c7; }
.ds-toast-warning { border-color: hsl(38 92% 50% / 0.4); }
.ds-toast-warning .ds-toast-icon { color: #f59e0b; }

.ds-toast-leaving {
    animation: ds-fade-out 0.25s ease-in forwards;
}
@keyframes ds-fade-out {
    to { opacity: 0; transform: translateY(-8px); }
}

.ds-toast-icon {
    flex-shrink: 0;
    width: 1.25rem;
    height: 1.25rem;
}
.ds-toast-body {
    flex: 1;
    min-width: 0;
}
.ds-toast-title {
    font-weight: 600;
    margin-bottom: 0.125rem;
}
.ds-toast-message {
    color: hsl(var(--muted-foreground));
    font-size: 0.8125rem;
}
.ds-toast-close {
    background: transparent;
    border: none;
    color: hsl(var(--muted-foreground));
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

/* ---------- Buttons (shadcn-style helpers) ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
    line-height: 1.25rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s, border-color 0.15s, opacity 0.15s, transform 0.05s;
    user-select: none;
    white-space: nowrap;
}
.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}
.btn:active:not(:disabled) {
    transform: translateY(1px);
}

.btn-primary {
    background-image: linear-gradient(to right, #059669, #0d9488);
    color: white;
}
.btn-primary:hover:not(:disabled) {
    background-image: linear-gradient(to right, #047857, #0f766e);
}
.btn-rose {
    background-image: linear-gradient(to right, #e11d48, #dc2626);
    color: white;
}
.btn-rose:hover:not(:disabled) {
    background-image: linear-gradient(to right, #be123c, #b91c1c);
}

.btn-outline {
    background: transparent;
    border-color: hsl(var(--border));
    color: hsl(var(--foreground));
}
.btn-outline:hover:not(:disabled) {
    background: hsl(var(--muted));
}

.btn-ghost {
    background: transparent;
    color: hsl(var(--foreground));
}
.btn-ghost:hover:not(:disabled) {
    background: hsl(var(--muted));
}

.btn-secondary {
    background: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
}
.btn-secondary:hover:not(:disabled) {
    background: hsl(var(--muted));
}

.btn-destructive {
    background: hsl(var(--destructive));
    color: hsl(var(--destructive-foreground));
}
.btn-destructive:hover:not(:disabled) {
    background: hsl(0 72% 50%);
}

.btn-sm  { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }
.btn-lg  { padding: 0.75rem 1.5rem; font-size: 1rem; }
.btn-icon { padding: 0.5rem; }

/* ---------- Cards ---------- */
.card {
    background-color: hsl(var(--card));
    color: hsl(var(--card-foreground));
    border: 1px solid hsl(var(--border));
    border-radius: 0.75rem;
}
.card-header {
    padding: 1.5rem;
    border-bottom: 1px solid hsl(var(--border));
}
.card-body, .card-content {
    padding: 1.5rem;
}

/* ---------- Inputs ---------- */
.input, .textarea, .select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid hsl(var(--input));
    border-radius: 0.5rem;
    background: transparent;
    color: hsl(var(--foreground));
    font-size: 0.875rem;
    line-height: 1.25rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, .textarea:focus, .select:focus {
    outline: none;
    border-color: hsl(158 64% 51% / 0.6);
    box-shadow: 0 0 0 3px hsl(158 64% 51% / 0.15);
}
.input:disabled, .textarea:disabled, .select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.textarea {
    min-height: 6rem;
    resize: vertical;
    font-family: inherit;
}

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1;
    border: 1px solid transparent;
    white-space: nowrap;
}
.badge-default   { background: hsl(var(--primary)); color: white; }
.badge-secondary { background: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); }
.badge-outline   { border-color: hsl(var(--border)); color: hsl(var(--foreground)); }
.badge-success   { background: hsl(158 64% 51% / 0.15); color: #059669; border-color: hsl(158 64% 51% / 0.3); }
.badge-warning   { background: hsl(38 92% 50% / 0.15); color: #d97706; border-color: hsl(38 92% 50% / 0.3); }
.badge-danger    { background: hsl(0 84% 60% / 0.15); color: #dc2626; border-color: hsl(0 84% 60% / 0.3); }
.badge-info      { background: hsl(199 89% 48% / 0.15); color: #0284c7; border-color: hsl(199 89% 48% / 0.3); }

/* ---------- Sticky footer ---------- */
.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.app-shell > main {
    flex: 1 1 auto;
}
footer.sticky-footer {
    margin-top: auto;
}

/* ---------- Admin sidebar helpers ---------- */
.admin-sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    transition: background 0.15s, color 0.15s;
    cursor: pointer;
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
}
.admin-sidebar-link:hover {
    color: hsl(var(--foreground));
    background: hsl(var(--muted));
}
.admin-sidebar-link.active {
    background: hsl(158 64% 51% / 0.1);
    color: #059669;
}

/* ---------- Tables ---------- */
.ds-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.ds-table th,
.ds-table td {
    padding: 0.625rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid hsl(var(--border));
}
.ds-table th {
    background: hsl(var(--muted));
    font-weight: 600;
    color: hsl(var(--muted-foreground));
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.ds-table tbody tr:hover {
    background: hsl(var(--muted) / 0.5);
}

/* ---------- Skeleton loader ---------- */
.skeleton {
    background: linear-gradient(90deg,
        hsl(var(--muted)) 0%,
        hsl(var(--muted) / 0.5) 50%,
        hsl(var(--muted)) 100%);
    background-size: 200% 100%;
    animation: ds-skeleton 1.4s ease-in-out infinite;
    border-radius: 0.5rem;
}
@keyframes ds-skeleton {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ---------- Misc ---------- */
.icon-xs { width: 0.75rem; height: 0.75rem; }
.icon-sm { width: 1rem; height: 1rem; }
.icon-md { width: 1.25rem; height: 1.25rem; }
.icon-lg { width: 1.5rem; height: 1.5rem; }
.icon-xl { width: 2rem; height: 2rem; }

/* Hide elements that depend on JS being ready */
.no-js-only { display: none; }
html.no-js .no-js-only { display: block; }

/* Accordion */
.accordion-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 1rem;
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: left;
    font-weight: 500;
    color: hsl(var(--foreground));
    font-size: 0.875rem;
}
.accordion-trigger:hover { text-decoration: none; }
.accordion-content {
    padding: 0 1rem 1rem 1rem;
    color: hsl(var(--muted-foreground));
    font-size: 0.875rem;
    line-height: 1.6;
}
.accordion-item {
    border: 1px solid hsl(var(--border));
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.accordion-item.open {
    border-color: hsl(158 64% 51% / 0.3);
    box-shadow: 0 1px 4px hsl(158 64% 51% / 0.06);
}
.accordion-chevron {
    transition: transform 0.2s;
}
.accordion-item.open .accordion-chevron {
    transform: rotate(180deg);
}

/* Tabs */
.tabs-list {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem;
    background: hsl(var(--muted));
    border-radius: 0.5rem;
}
.tabs-trigger {
    padding: 0.375rem 0.875rem;
    border-radius: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.tabs-trigger:hover {
    color: hsl(var(--foreground));
}
.tabs-trigger.active {
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* Modal / dialog */
.ds-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(2px);
    z-index: 90;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 2rem 1rem;
    overflow-y: auto;
}
.ds-modal {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: 0.75rem;
    box-shadow: 0 20px 50px -10px rgba(0,0,0,0.4);
    width: 100%;
    max-width: 32rem;
    margin: auto;
    animation: ds-zoom-in 0.2s ease-out;
}
.ds-modal-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid hsl(var(--border));
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.ds-modal-body {
    padding: 1.25rem;
    max-height: 70vh;
    overflow-y: auto;
}
.ds-modal-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid hsl(var(--border));
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* Mobile helpers */
@media (max-width: 640px) {
    .ds-toast {
        min-width: 16rem;
        max-width: calc(100vw - 2rem);
    }
}

/* Reduced motion */
@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;
    }
}

/* Print-friendly */
@media print {
    header, footer, .no-print { display: none !important; }
    body { background: white !important; color: black !important; }
}
