/* Professional Samy Auto Admin Theme - Fixed Version */

/* CSS Variables for consistent theming */
:root {
    --samy-primary: #2563eb;
    --samy-secondary: #dc2626;
    --samy-success: #059669;
    --samy-warning: #d97706;
    --samy-danger: #dc2626;
    --samy-light: #f8fafc;
    --samy-dark: #1e293b;
    --samy-gray-100: #f3f4f6;
    --samy-gray-200: #e5e7eb;
    --samy-gray-300: #d1d5db;
    --samy-gray-400: #9ca3af;
    --samy-gray-500: #6b7280;
    --samy-gray-600: #4b5563;
    --samy-gray-700: #374151;
    --samy-gray-800: #1f2937;
    --samy-gray-900: #111827;
    --header-link-color: #374151 !important;
}

/* Global box-sizing fix */
*, *::before, *::after {
    box-sizing: border-box;
}

/* Base admin overrides */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f8fafc !important;
    color: var(--samy-gray-700);
    line-height: 1.6;
    margin: 0;
    padding: 0;
}

/* Header adjustments */
#header {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%) !important;
    border-bottom: 2px solid var(--samy-gray-200);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

#branding {
    padding: 16px 20px;
    border-bottom: 1px solid var(--samy-gray-200);
}

.theme-toggle {
        visibility: hidden;
}
#branding h1 {
    margin: 0;
    font-weight: 700;
    font-size: 24px;
}

#branding h1 a {
    color: var(--samy-gray-800) !important;
    text-decoration: none;
    display: flex;
    align-items: center;
}

#branding h1 a:hover {
    color: var(--samy-primary) !important;
}

/* User tools styling */
#user-tools {
    background: transparent;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

#user-tools .welcome {
    color: var(--samy-gray-700) !important;
    font-weight: 600 !important;
    margin-right: 8px;
}

#user-tools strong {
    color: var(--samy-gray-700) !important;
    font-weight: 700 !important;
}

#header #user-tools a,
#header #user-tools a:link,
#header #user-tools a:visited {
    color: var(--samy-gray-700) !important;
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-weight: 500;
    border: 1px solid transparent;
}
.submit-row {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 1000 !important;
    background: linear-gradient(135deg, #ffffff 0%, #dee9ff 100%) !important;
    padding: 15px 25px !important;
    margin: 0 !important;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4) !important;
}
.submit-row a.deletelink {
    display: block;
    background: var(--delete-button-bg);
    border-radius: 4px;
    padding: 15px;
    height: 0px; 
    line-height: 0px; 
    color: var(--button-fg);
}

#header #user-tools a:hover,
#header #user-tools a:focus {
    background: var(--samy-primary) !important;
    color: white !important;
    border-color: var(--samy-primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
}

#header #user-tools a[href*="logout"],
#header #user-tools a[href*="logout"]:link,
#header #user-tools a[href*="logout"]:visited,
#logout-form button {
    background: linear-gradient(135deg, var(--samy-danger), #b91c1c) !important;
    color: white !important;
    border: 1px !important;
    font-weight: 600 !important;
    border-radius: 20px;
    padding: 10px;
}

#header #user-tools a[href*="logout"]:hover,
#header #user-tools a[href*="logout"]:focus,
#logout-form button:hover {
    background: linear-gradient(135deg, #b91c1c, #991b1b) !important;
    color: white !important;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3) !important;
}

#header * {
    text-shadow: none !important;
}

/* Sidebar styling */
#nav-sidebar {
    background: #ffffff !important;
    border-right: 2px solid var(--samy-gray-200);
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.06);
}

#nav-sidebar .nav-sidebar-header {
    background: linear-gradient(135deg, var(--samy-primary), #1d4ed8);
    color: white;
    padding: 20px;
    font-weight: 600;
    font-size: 16px;
    border-bottom: 1px solid var(--samy-gray-200);
}

#nav-sidebar .nav-sidebar-content {
    padding: 20px 0;
}

.nav-sidebar a {
    display: block;
    padding: 12px 20px;
    color: var(--samy-gray-700) !important;
    text-decoration: none;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
}

.nav-sidebar a:hover,
.nav-sidebar a:focus {
    background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
    color: var(--samy-primary) !important;
    border-left-color: var(--samy-primary);
}

.nav-sidebar .current-app a {
    background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
    color: var(--samy-primary) !important;
    border-left-color: var(--samy-primary);
    font-weight: 600;
}

.nav-sidebar .app-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--samy-gray-500);
    padding: 16px 20px 8px 20px;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--samy-gray-200);
    margin-bottom: 8px;
}

/* Model links with icons */
.nav-sidebar .model-car a:before { content: '🚗 '; }
.nav-sidebar .model-tagfr a:before { content: '🏷️ '; }
.nav-sidebar .model-tagar a:before { content: '🏷️ '; }
.nav-sidebar .model-user a:before { content: '👥 '; }
.nav-sidebar .model-group a:before { content: '👨‍👩‍👧‍👦 '; }

/* Breadcrumbs */
.breadcrumbs {
    background: #ffffff;
    border: 1px solid var(--samy-gray-200);
    border-radius: 8px;
    margin: 20px 0;
    padding: 12px 16px;
    font-size: 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.breadcrumbs a {
    color: var(--samy-primary);
    text-decoration: none;
}

.breadcrumbs a:hover {
    text-decoration: underline;
}

/* Module styling */
.module {
    background: #ffffff;
    border: 1px solid var(--samy-gray-200);
    border-radius: 8px;
    margin-bottom: 20px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.module h2,
.module caption {
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    border-bottom: 1px solid var(--samy-gray-200);
    color: var(--samy-gray-800);
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    padding: 16px 20px;
    text-transform: none;
}

.module h3 {
    color: var(--samy-gray-700);
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 10px 0;
    padding: 12px 20px;
    background: var(--samy-gray-100);
}

/* Table styling */
.results {
    overflow-x: auto;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

#result_list {
    border: none;
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    background: #ffffff;
}

#result_list thead th {
    background: linear-gradient(135deg, var(--samy-gray-100), var(--samy-gray-200));
    border-bottom: 2px solid var(--samy-gray-300);
    color: var(--samy-gray-700);
    font-weight: 600;
    padding: 16px 12px;
    text-align: left;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#result_list thead th:first-child {
    border-top-left-radius: 8px;
}

#result_list thead th:last-child {
    border-top-right-radius: 8px;
}

#result_list tbody tr {
    border-bottom: 1px solid var(--samy-gray-200);
    transition: background-color 0.2s ease;
}

#result_list tbody tr:hover {
    background-color: #f0f9ff;
}

#result_list tbody tr:nth-child(even) {
    background-color: #fafbfc;
}

#result_list tbody tr:nth-child(even):hover {
    background-color: #f0f9ff;
}

#result_list tbody td {
    padding: 14px 12px;
    border-right: 1px solid var(--samy-gray-200);
    vertical-align: middle;
}

#result_list tbody td:last-child {
    border-right: none;
}

/* Action row styling */
.actions {
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    border: 1px solid var(--samy-gray-200);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.actions select {
    padding: 8px 12px !important;
    border: 1px solid var(--samy-gray-300) !important;
    border-radius: 6px !important;
    background: #ffffff !important;
    color: var(--samy-gray-700) !important;
    font-size: 14px !important;
    min-height: 38px !important;
}

.actions button {
    background: linear-gradient(135deg, var(--samy-primary), #1d4ed8);
    border: none;
    border-radius: 6px;
    color: white;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    padding: 8px 16px;
    transition: all 0.2s ease;
}

.actions button:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

/* Form styling */
.form-row {
    margin-bottom: 20px;
}

.form-row label {
    color: var(--samy-gray-700);
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 14px;
}

.form-row input:not([type="checkbox"]):not([type="radio"]),
.form-row textarea {
    background: #ffffff;
    border: 1px solid var(--samy-gray-300);
    border-radius: 6px;
    color: var(--samy-gray-700);
    font-size: 14px;
    padding: 10px 12px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    width: 100%;
    box-sizing: border-box;
}

/* Regular select fields (NOT in selector widgets) */
.form-row select:not(.selector select):not(.selector-available):not(.selector-chosen) {
    background: #ffffff;
    border: 1px solid var(--samy-gray-300);
    border-radius: 6px;
    color: var(--samy-gray-700);
    font-size: 14px;
    padding: 10px 12px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    width: 100%;
    box-sizing: border-box;
    cursor: pointer;
    line-height: 1.5;
    min-height: 38px;
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
    border-color: var(--samy-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    outline: none;
}

/* Django FilteredSelectMultiple widget (permissions, groups) */
.selector {
    width: 100% !important;
    display: flex !important;
    gap: 15px !important;
    align-items: stretch !important;
    margin: 10px 0 !important;
    clear: both !important;
}

/* Force show both selector boxes */
.selector .selector-available,
.selector .selector-chosen {
    visibility: visible !important;
    display: block !important;
    opacity: 1 !important;
}

.selector-available,
.selector-chosen {
    width: 40% !important;
    display: block !important;
}

.selector-available h2,
.selector-chosen h2 {
    font-size: 14px !important;
    font-weight: 600 !important;
    color: var(--samy-gray-700) !important;
    margin: 0 0 8px 0 !important;
    padding: 8px 12px !important;
    background: var(--samy-gray-100) !important;
    border-radius: 4px !important;
}

.selector select {
    width: 100% !important;
    height: 200px !important;
    display: block !important;
    background: #ffffff !important;
    border: 1px solid var(--samy-gray-300) !important;
    border-radius: 6px !important;
    color: var(--samy-gray-700) !important;
    font-size: 13px !important;
    padding: 8px !important;
}

.selector select:focus {
    border-color: var(--samy-primary) !important;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1) !important;
    outline: none !important;
}

.selector-chooser {
    width: 20% !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 8px !important;
}

.selector-chooser a {
    display: block !important;
    width: 40px !important;
    height: 40px !important;
    line-height: 40px !important;
    text-align: center !important;
    background: var(--samy-primary) !important;
    color: white !important;
    text-decoration: none !important;
    border-radius: 6px !important;
    font-size: 10px !important;
    font-weight: bold !important;
    transition: all 0.2s ease !important;
    text-indent: 0px;
    opacity: 0.9;
}

.selector-chooser a:hover {
    background: var(--samy-secondary) !important;
    transform: scale(1.05) !important;
}

.selector-filter {
    margin: 5px 0 !important;
}

.selector-filter label {
    font-size: 12px !important;
    font-weight: 500 !important;
    color: var(--samy-gray-600) !important;
    margin-bottom: 4px !important;
}

.selector-filter input {
    width: 100% !important;
    padding: 6px 8px !important;
    border: 1px solid var(--samy-gray-300) !important;
    border-radius: 4px !important;
    font-size: 12px !important;
}

/* Fieldsets */
fieldset {
    background: #ffffff;
    border: 1px solid var(--samy-gray-200);
    border-radius: 8px;
    margin-bottom: 20px;
    padding: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

fieldset h2 {
    background: linear-gradient(135deg, var(--samy-gray-100), var(--samy-gray-200));
    border-bottom: 1px solid var(--samy-gray-200);
    color: var(--samy-gray-800);
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    padding: 16px 20px;
    border-radius: 8px 8px 0 0;
}

.field-box {
    padding: 20px;
}

/* Button styling */
input[type="submit"],
.button,
.btn {
    background: linear-gradient(135deg, var(--samy-primary), #1d4ed8);
    border: none;
    border-radius: 6px;
    color: white !important;
    cursor: pointer;
    display: inline-block;
    font-size: 14px;
    font-weight: 500;
    padding: 12px 20px;
    text-decoration: none;
    transition: all 0.2s ease;
    margin-right: 10px;
    margin-bottom: 10px;
}

input[type="submit"]:hover,
.button:hover,
.btn:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    color: white !important;
}

.button.default,
input[type="submit"].default {
    background: linear-gradient(135deg, var(--samy-success), #047857);
}

.button.default:hover,
input[type="submit"].default:hover {
    background: linear-gradient(135deg, #047857, #065f46);
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
}

.deletelink,
.button[class*="danger"] {
    background: linear-gradient(135deg, var(--samy-danger), #b91c1c) !important;
}

.deletelink:hover,
.button[class*="danger"]:hover {
    background: linear-gradient(135deg, #b91c1c, #991b1b) !important;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

/* Add Car button styling */
.addlink {
    background: linear-gradient(135deg, var(--samy-success), #047857) !important;
    border-radius: 6px !important;
    color: white !important;
    font-weight: 500 !important;
    padding: 10px 16px !important;
    text-decoration: none !important;
    transition: all 0.2s ease !important;
    display: inline-flex !important;
    align-items: center !important;
    margin-bottom: 15px !important;
}

.addlink:before {
    content: '+ ';
    margin-right: 4px;
}

.addlink:hover {
    background: linear-gradient(135deg, #047857, #065f46) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3) !important;
}

/* Pagination styling */
.paginator {
    background: #ffffff;
    border: 1px solid var(--samy-gray-200);
    border-radius: 8px;
    margin: 20px 0;
    padding: 16px 20px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.paginator a {
    background: var(--samy-gray-100);
    border-radius: 6px;
    color: var(--samy-gray-700);
    display: inline-block;
    margin: 0 4px;
    padding: 8px 12px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.paginator a:hover {
    background: var(--samy-primary);
    color: white;
}

.paginator .this-page {
    background: var(--samy-primary);
    color: white;
    display: inline-block;
    font-weight: 600;
    margin: 0 4px;
    padding: 8px 12px;
    border-radius: 6px;
}

/* Filter sidebar styling */
#changelist-filter {
    background: #ffffff;
    border: 1px solid var(--samy-gray-200);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

#changelist-filter h2 {
    color: var(--samy-gray-800);
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 16px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--samy-gray-200);
}

#changelist-filter h3 {
    color: var(--samy-gray-700);
    font-size: 14px;
    font-weight: 600;
    margin: 20px 0 8px 0;
}

#changelist-filter ul {
    list-style: none;
    padding: 0;
    margin: 0 0 16px 0;
}

#changelist-filter li {
    margin-bottom: 4px;
}

#changelist-filter a {
    color: var(--samy-gray-600);
    display: block;
    padding: 6px 0;
    text-decoration: none;
    transition: color 0.2s ease;
}

#changelist-filter a:hover {
    color: var(--samy-primary);
}

#changelist-filter .selected {
    color: var(--samy-primary) !important;
    font-weight: 600;
}

#changelist-filter select {
    width: 100%;
    margin-bottom: 10px;
    padding: 6px 10px;
    border: 1px solid var(--samy-gray-300);
    border-radius: 4px;
    background: #ffffff;
    font-size: 13px;
}

/* Search box styling */
#toolbar {
    background: #ffffff;
    border: 1px solid var(--samy-gray-200);
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

#toolbar form {
    display: flex;
    align-items: center;
    gap: 12px;
}

#toolbar input[type="text"] {
    flex: 1;
    max-width: 400px;
}

#toolbar input[type="submit"] {
    margin: 0;
}

/* Messages */
.messagelist {
    margin: 0 0 20px 0;
    padding: 0;
    list-style: none;
}

.messagelist li {
    background: #ffffff;
    border: 1px solid var(--samy-gray-200);
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 10px;
    padding: 16px 20px;
    position: relative;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.messagelist .info {
    border-left: 4px solid var(--samy-primary);
    background: #f0f9ff;
}

.messagelist .success {
    border-left: 4px solid var(--samy-success);
    background: #ecfdf5;
}

.messagelist .warning {
    border-left: 4px solid var(--samy-warning);
    background: #fffbeb;
}

.messagelist .error {
    border-left: 4px solid var(--samy-danger);
    background: #fef2f2;
}

/* Responsive design for selector widget */
@media (max-width: 768px) {
    .selector {
        flex-direction: column !important;
        gap: 20px !important;
    }
    
    .selector-available,
    .selector-chosen {
        width: 100% !important;
    }
    
    .selector-chooser {
        width: 100% !important;
        flex-direction: row !important;
        justify-content: center !important;
    }
}