/* Admin login + 2FA pages: soft background, top-aligned bordered card */
body.login #page,
body.tfa #page { background: #cbd5e1 !important; }
html.dark body.login #page,
html.dark body.tfa #page { background: #0f172a !important; }
body.login #page > div,
body.tfa #page > div { align-items: flex-start !important; padding-top: 60px !important; }
#content-main.login-card {
    max-width: 440px !important;
    margin: 0 auto !important;
    padding: 36px 36px 28px !important;
    border: 1px solid rgba(148, 163, 184, 0.35) !important;
    border-radius: 14px !important;
    background: #1e293b !important;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35) !important;
}
.login-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}
.login-logo img { height: 48px; width: auto; }
#content-main.login-card label,
#content-main.login-card .form-row label {
    color: #e2e8f0 !important;
}

/* AdminImageWidget: style the native file input as a real button */
.admin-image-widget input[type="file"] {
    font-size: 12px;
    color: transparent;
    width: 130px;
}
.admin-image-widget.no-image input[type="file"] {
    color: inherit;
    width: auto;
}
.admin-image-widget input[type="file"]::file-selector-button {
    padding: 6px 14px;
    margin-right: 8px;
    background: #4f46e5;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s;
}
.admin-image-widget input[type="file"]::file-selector-button:hover {
    background: #4338ca;
}

/* Status colors (colored badges) */
.colored-status { font-weight: bold; }
.cleaning-colored-status, .new-colored-status, .pending-colored-status { color: #3b82f6; }
.active-colored-status, .applied-colored-status, .completed-colored-status,
.signed-colored-status, .vacancy-colored-status { color: #22c55e; }
.received-colored-status { color: #a855f7; }
.draft-colored-status { color: #eab308; }
.unsigned-colored-status, .processing-colored-status,
.refunded-colored-status, .reserved-colored-status { color: #f97316; }
.cancelled-colored-status, .failed-colored-status, .rented-colored-status { color: #ef4444; }
.archived-colored-status, .expired-colored-status, .not_available-colored-status { color: #6b7280; }
.pending_manual_refund-colored-status { color: #d97706; }

/* Form field sizes */
.add-rent-form input:not([type="checkbox"]):not(.vDateField) { min-width: 250px; }
.add-rent-form select { min-width: 263.6px; }
.add-rent-form textarea { min-width: 500px; }

/* Raw ID fields */
.vForeignKeyRawIdAdminField { width: auto !important; }

/* Readonly label padding */
.aligned label + div.readonly { padding: 4px 10px 0 0 !important; }

/* Filter select */
.filter-select { margin: 5px 15px 20px; width: calc(100% - 30px); }

/* Inline formset styling */
.inline-group .tabular tr.has_original.has_no_show_original td { padding-top: 8px !important; }

/* Login and 2FA pages — the overridden templates render Django's default
   widgets which come unstyled under Unfold. Add borders so fields/buttons
   are visible. */
#login-form input[type="text"],
#login-form input[type="password"],
#login-form input[type="email"],
#tfa-form input[type="text"] {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    color: #111827;
    font-size: 14px;
    line-height: 1.5;
}
#login-form input[type="text"]:focus,
#login-form input[type="password"]:focus,
#login-form input[type="email"]:focus,
#tfa-form input[type="text"]:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.15);
}
#login-form input[type="submit"],
#tfa-form button.submit-button {
    border: 1px solid #4f46e5;
    background: #4f46e5;
    color: #fff;
    padding: 10px 18px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
}
#login-form input[type="submit"]:hover,
#tfa-form button.submit-button:hover {
    background: #4338ca;
    border-color: #4338ca;
}
#tfa-form button.resend-code-button {
    border: 1px solid #d1d5db;
    background: #fff;
    color: #111827;
    padding: 10px 18px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
}
#tfa-form button.resend-code-button:hover:not(:disabled) {
    background: #f3f4f6;
}
#tfa-form button.resend-code-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
#login-form .form-row { margin-bottom: 12px; }
#login-form label, #tfa-form label {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
}

@media (prefers-color-scheme: dark) {
    #login-form input[type="text"],
    #login-form input[type="password"],
    #login-form input[type="email"],
    #tfa-form input[type="text"] {
        background: #1f2937;
        color: #f3f4f6;
        border-color: #374151;
    }
    #tfa-form button.resend-code-button {
        background: #1f2937;
        color: #f3f4f6;
        border-color: #374151;
    }
    #login-form label, #tfa-form label { color: #d1d5db; }
}

/* Unfold uses a class-based dark mode (html.dark) — mirror the dark styles there
   so labels stay readable regardless of OS preference. */
html.dark #login-form input[type="text"],
html.dark #login-form input[type="password"],
html.dark #login-form input[type="email"],
html.dark #tfa-form input[type="text"] {
    background: #1f2937;
    color: #f3f4f6;
    border-color: #374151;
}
html.dark #tfa-form button.resend-code-button {
    background: #1f2937;
    color: #f3f4f6;
    border-color: #374151;
}
html.dark #login-form label,
html.dark #tfa-form label { color: #e5e7eb; }

/* Admin list table — make clickable links visually distinct */
#result_list td a {
    color: #818cf8;
    text-decoration: none;
}
#result_list td a:hover {
    text-decoration: underline;
}

/* Point 8: Editable form fields — visible borders in dark mode
   Uses specific selectors for Django's default form widgets that Unfold
   doesn't style (manual rental form, content localizations, customer forms). */
html.dark .aligned input[type="text"],
html.dark .aligned input[type="email"],
html.dark .aligned input[type="url"],
html.dark .aligned input[type="number"],
html.dark .aligned textarea,
html.dark .aligned select,
html.dark .manual-rental-form input[type="text"],
html.dark .manual-rental-form input[type="date"],
html.dark .manual-rental-form select {
    border: 1px solid #374151;
    background: #1f2937;
    color: #f3f4f6;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    line-height: 1.5;
}
html.dark .aligned input:focus,
html.dark .aligned textarea:focus,
html.dark .aligned select:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

/* Point 7: Gate device phone panel — dark mode fixes */
html.dark .customer-info strong { color: #f3f4f6 !important; }
html.dark .customer-row:hover { background: #1e293b !important; }
html.dark .phone-checkbox-item .phone-number { color: #e2e8f0; }
html.dark #phone-management-panel .search-bar { background: #1e293b !important; }
html.dark #phone-management-panel .search-bar input {
    background: #1f2937 !important;
    color: #f3f4f6 !important;
    border-color: #374151 !important;
}
html.dark .save-bar { background: #1e293b !important; }
html.dark .standalone-section { border-color: #374151 !important; }

/* Point 9: Phone number widget — dark mode */
html.dark .phone-number-widget {
    border-color: #374151;
}
html.dark .country-select-display {
    background: #1f2937 !important;
}
html.dark .country-select-dropdown {
    background: #1f2937 !important;
    border-color: #374151 !important;
}
html.dark .country-select-dropdown li:hover {
    background: #374151 !important;
}
html.dark .phone-number-widget input {
    background: #1f2937 !important;
    color: #f3f4f6 !important;
}
.phone-number-widget input {
    padding: 5px 6px !important;
    font-size: 14px;
}

/* Point 10: Email/SMS logs — message preview dark mode */
html.dark .report-table td .message-preview,
html.dark .report-table td .message-preview span,
html.dark .report-table td .message-preview p,
html.dark .report-table td .message-preview td,
html.dark .report-table td .message-preview th,
html.dark .report-table td .message-preview li,
html.dark .report-table td .message-preview b,
html.dark .report-table td .message-preview strong {
    background: #1e293b !important;
    color: #e2e8f0 !important;
    border-color: #374151 !important;
}
html.dark .report-table td .message-preview table {
    background: #1e293b !important;
}
html.dark .report-table td .message-preview a {
    color: #818cf8;
}

