/* ============================================================
   DEPL ERP - Custom Admin Overrides
   Light + Dark Mode
   ============================================================ */

/* ------------------------------------------------------------
   FORM CONTROLS
   IMPORTANT:
   Do NOT force white backgrounds in dark mode.
   ------------------------------------------------------------ */

/* Light mode */
:root {
    --depl-input-bg: #ffffff;
    --depl-input-bg-hover: #f8fafc;
    --depl-input-border: #cbd5e1;
    --depl-input-border-hover: #94a3b8;
    --depl-input-text: #111827;
    --depl-input-placeholder: #64748b;
    --depl-focus: #4f46e5;
    --depl-table-header: #ffffff;
    --depl-table-hover: rgb(238 242 255 / 0.5);
}

/* Dark mode */
html.dark,
body.dark,
html[data-theme="dark"],
body[data-theme="dark"],
.dark {
    --depl-input-bg: #182235;
    --depl-input-bg-hover: #1e293b;
    --depl-input-border: #334155;
    --depl-input-border-hover: #475569;
    --depl-input-text: #f1f5f9;
    --depl-input-placeholder: #94a3b8;
    --depl-focus: #818cf8;
    --depl-table-header: #1f2937;
    --depl-table-hover: rgba(99, 102, 241, 0.10);
}

/* Text inputs, selects, textareas */
select,
textarea,
input[type="text"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="url"],
input[type="tel"],
input[type="password"],
input[type="datetime-local"],
input[type="time"] {
    color: var(--depl-input-text) !important;
    background-color: var(--depl-input-bg) !important;
    border: 1px solid var(--depl-input-border) !important;
    border-radius: 7px !important;
    box-shadow: none !important;
    color-scheme: light !important;
    min-height: 42px !important;
    box-sizing: border-box !important;
    transition:
        background-color 0.15s ease,
        border-color 0.15s ease,
        box-shadow 0.15s ease !important;
}

/* Dark browser controls */
html.dark select,
body.dark select,
html[data-theme="dark"] select,
body[data-theme="dark"] select,
.dark select,
html.dark textarea,
body.dark textarea,
html[data-theme="dark"] textarea,
body[data-theme="dark"] textarea,
.dark textarea,
html.dark input[type="text"],
body.dark input[type="text"],
html[data-theme="dark"] input[type="text"],
body[data-theme="dark"] input[type="text"],
.dark input[type="text"],
html.dark input[type="email"],
body.dark input[type="email"],
html[data-theme="dark"] input[type="email"],
body[data-theme="dark"] input[type="email"],
.dark input[type="email"],
html.dark input[type="number"],
body.dark input[type="number"],
html[data-theme="dark"] input[type="number"],
body[data-theme="dark"] input[type="number"],
.dark input[type="number"],
html.dark input[type="date"],
body.dark input[type="date"],
html[data-theme="dark"] input[type="date"],
body[data-theme="dark"] input[type="date"],
.dark input[type="date"],
html.dark input[type="url"],
body.dark input[type="url"],
html[data-theme="dark"] input[type="url"],
body[data-theme="dark"] input[type="url"],
.dark input[type="url"] {
    color-scheme: dark !important;
}

/* Dropdown options */
select option {
    color: var(--depl-input-text) !important;
    background-color: var(--depl-input-bg) !important;
}

/* Hover */
select:hover,
textarea:hover,
input[type="text"]:hover,
input[type="email"]:hover,
input[type="number"]:hover,
input[type="date"]:hover,
input[type="url"]:hover,
input[type="tel"]:hover,
input[type="password"]:hover,
input[type="datetime-local"]:hover,
input[type="time"]:hover {
    background-color: var(--depl-input-bg-hover) !important;
    border-color: var(--depl-input-border-hover) !important;
}

/* Focus */
select:focus,
textarea:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="url"]:focus,
input[type="tel"]:focus,
input[type="password"]:focus,
input[type="datetime-local"]:focus,
input[type="time"]:focus {
    color: var(--depl-input-text) !important;
    background-color: var(--depl-input-bg) !important;
    border-color: var(--depl-focus) !important;
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12) !important;
}

/* Placeholder */
input::placeholder,
textarea::placeholder {
    color: var(--depl-input-placeholder) !important;
    opacity: 1 !important;
}

/* Textarea */
textarea {
    min-height: 100px !important;
    resize: vertical !important;
}

/* Labels */
#content-main form label {
    font-size: 13px !important;
    font-weight: 600 !important;
}

/* Help text */
#content-main form .help,
#content-main form .helptext {
    color: var(--depl-input-placeholder) !important;
    font-size: 12px !important;
}

/* Full width content area */
main,
[class*="max-w-"] {
    max-width: 100% !important;
}

/* ------------------------------------------------------------
   LOGO AND HEADER
   ------------------------------------------------------------ */

header img,
[class*="branding"] img,
nav img {
    height: 84px !important;
    width: auto !important;
}

header h1,
[class*="branding"] h1,
[class*="site-header"] {
    font-size: 22px !important;
    font-weight: 700 !important;
    color: #4338ca !important;
}

/* ------------------------------------------------------------
   TABLE ROW POLISH
   ------------------------------------------------------------ */

table tbody tr:hover {
    background-color: var(--depl-table-hover) !important;
}

.shadow-sm {
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.08),
        0 1px 2px rgba(0, 0, 0, 0.04) !important;
}

/* ------------------------------------------------------------
   INLINE TABLE HEADERS
   ------------------------------------------------------------ */

.tabular table thead th,
.inline-related table thead th,
.inline-group table thead th {
    position: sticky;
    top: 56px;
    z-index: 15;
    background: var(--depl-table-header) !important;
}

/* ------------------------------------------------------------
   UNFOLD ADMIN ACTION RUN BUTTON
   ------------------------------------------------------------ */

#changelist-actions button[type="submit"][name="index"] {
    display: inline-flex !important;
}

/* ------------------------------------------------------------
   INLINE / RELATED WIDGETS
   ------------------------------------------------------------ */

.related-widget-wrapper {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    width: 100% !important;
}

.related-widget-wrapper > input,
.related-widget-wrapper > select {
    flex: 1 1 auto !important;
    min-width: 0 !important;
}

/* ------------------------------------------------------------
   CHECKBOX / RADIO
   ------------------------------------------------------------ */

input[type="checkbox"],
input[type="radio"] {
    accent-color: var(--depl-focus) !important;
    min-height: auto !important;
}

/* ------------------------------------------------------------
   READONLY / DISABLED
   ------------------------------------------------------------ */

input[readonly],
textarea[readonly] {
    background-color: var(--depl-input-bg-hover) !important;
    color: var(--depl-input-text) !important;
}

input:disabled,
select:disabled,
textarea:disabled {
    background-color: var(--depl-input-bg-hover) !important;
    color: var(--depl-input-placeholder) !important;
    opacity: 0.7 !important;
}

/* ------------------------------------------------------------
   FILE INPUT
   ------------------------------------------------------------ */

input[type="file"] {
    color: var(--depl-input-text) !important;
    background-color: var(--depl-input-bg) !important;
    border: 1px solid var(--depl-input-border) !important;
    border-radius: 7px !important;
    padding: 8px !important;
}

/* ------------------------------------------------------------
   SMALL SCREENS
   ------------------------------------------------------------ */

@media (max-width: 900px) {
    select,
    textarea,
    input[type="text"],
    input[type="email"],
    input[type="number"],
    input[type="date"],
    input[type="url"] {
        font-size: 14px !important;
        min-height: 40px !important;
    }
}
