/* ============================================================
   ADMIN SITE STYLESHEET - Django Admin Customization
   Services Publics - Modern Professional Theme
   ============================================================ */

:root {
  --primary: #0d6efd;
  --primary-dark: #0a58ca;
  --primary-light: #e7f1ff;
  --secondary: #6c757d;
  --success: #198754;
  --success-light: #d1e7dd;
  --danger: #dc3545;
  --danger-light: #f8d7da;
  --warning: #ffc107;
  --warning-light: #fff3cd;
  --info: #0dcaf0;
  --info-light: #cfe2ff;
  --light: #f8f9fa;
  --dark: #212529;
  --muted: #6c757d;
  --border: #dee2e6;
  --card-bg: #ffffff;
  --shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
  --shadow-md: 0 0.5rem 1rem rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 1rem 3rem rgba(0, 0, 0, 0.175);
}

/* ============================================================
   BASE STYLES
   ============================================================ */

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================================
   FORMS & INPUTS
   ============================================================ */

input[type="text"],
input[type="password"],
input[type="email"],
input[type="url"],
input[type="number"],
input[type="tel"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="month"],
input[type="week"],
input[type="color"],
textarea,
select {
  background-color: #ffffff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.95rem;
  transition: all 0.2s ease;
  font-family: inherit;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="url"]:focus,
input[type="number"]:focus,
input[type="tel"]:focus,
input[type="date"]:focus,
input[type="time"]:focus,
input[type="datetime-local"]:focus,
input[type="month"]:focus,
input[type="week"]:focus,
input[type="color"]:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.1);
  background-color: #ffffff;
}

textarea {
  resize: vertical;
  min-height: 120px;
  font-family: 'Segoe UI Mono', 'Courier New', monospace;
}

select {
  cursor: pointer;
}

input[type="checkbox"],
input[type="radio"] {
  cursor: pointer;
  margin-right: 0.5rem;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.button, 
input[type="submit"],
input[type="button"],
button {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-block;
  text-decoration: none;
  text-align: center;
}

.button:hover,
input[type="submit"]:hover,
input[type="button"]:hover,
button:hover {
  background: linear-gradient(135deg, var(--primary-dark) 0%, #003b9d 100%);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.button:active,
input[type="submit"]:active,
input[type="button"]:active,
button:active {
  transform: translateY(0);
}

.button:disabled,
input[type="submit"]:disabled,
input[type="button"]:disabled,
button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Button variants */
.delete-button {
  background: linear-gradient(135deg, var(--danger) 0%, #a71d2a 100%);
}

.delete-button:hover {
  background: linear-gradient(135deg, #a71d2a 0%, #8b0000 100%);
}

.submit-line {
  padding: 1rem;
  margin-top: 1rem;
  text-align: center;
  border-top: 1px solid var(--border);
  background-color: var(--light);
  border-radius: 0 0 6px 6px;
}

.submit-line button {
  margin: 0 0.25rem;
}

/* ============================================================
   FORMS LAYOUT
   ============================================================ */

fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  background-color: var(--card-bg);
}

fieldset > legend {
  padding: 0 0.75rem;
  margin-left: -0.75rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary);
}

.form-row {
  margin-bottom: 1rem;
  display: flex;
  gap: 1rem;
}

.form-row > div {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.form-row label {
  font-weight: 500;
  margin-bottom: 0.25rem;
  display: block;
}

label {
  color: var(--dark);
  font-weight: 500;
  margin-bottom: 0.5rem;
  display: block;
}

.errornote {
  background-color: var(--danger-light);
  border: 1px solid #f5c2c7;
  border-radius: 6px;
  color: #842029;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-weight: 500;
}

.errorlist {
  color: var(--danger);
  list-style: none;
  padding: 0;
  margin: 0.25rem 0;
  font-size: 0.875rem;
}

.errorlist li {
  padding: 0.25rem 0;
}

.errorlist li:before {
  content: "• ";
  margin-right: 0.25rem;
}

/* ============================================================
   MESSAGES
   ============================================================ */

.messagelist {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem 0;
}

.messagelist li {
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  border-left: 4px solid;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 500;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.messagelist .success {
  background-color: var(--success-light);
  border-left-color: var(--success);
  color: #0f5132;
}

.messagelist .warning {
  background-color: var(--warning-light);
  border-left-color: var(--warning);
  color: #664d03;
}

.messagelist .error {
  background-color: var(--danger-light);
  border-left-color: var(--danger);
  color: #842029;
}

/* ============================================================
   TABLES
   ============================================================ */

table {
  width: 100%;
  border-collapse: collapse;
  background-color: var(--card-bg);
}

table thead {
  background-color: var(--light);
  border-bottom: 2px solid var(--border);
}

table thead th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--dark);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

table tbody td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table tbody tr:hover {
  background-color: rgba(13, 110, 253, 0.03);
}

table tbody tr:last-child td {
  border-bottom: none;
}

/* ============================================================
   LINKS & ACTIONS
   ============================================================ */

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

a:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 3px;
}

/* Action checkboxes */
.action-checkbox {
  margin-right: 0.5rem;
}

/* ============================================================
   BREADCRUMBS
   ============================================================ */

.breadcrumbs {
  background-color: var(--light);
  padding: 0.75rem 1rem;
  border-radius: 6px 6px 0 0;
  margin-bottom: 0;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
}

.breadcrumbs a {
  color: var(--primary);
}

.breadcrumbs a:hover {
  color: var(--primary-dark);
}

.breadcrumbs span {
  padding: 0 0.5rem;
  color: var(--muted);
}

/* ============================================================
   RELATED OBJECTS
   ============================================================ */

.related-widget-wrapper {
  margin-bottom: 1rem;
}

.add-row, .remove-row {
  display: inline-block;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  margin-left: 0.5rem;
  background-color: var(--light);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.add-row:hover {
  background-color: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.remove-row:hover {
  background-color: var(--danger-light);
  border-color: var(--danger);
  color: var(--danger);
}

/* ============================================================
   SEARCH & FILTERS
   ============================================================ */

#searchbar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

#searchbar input {
  flex: 1;
  border-radius: 6px;
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
}

#searchbar input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.1);
}

#searchbar button {
  padding: 0.5rem 1rem;
  border-radius: 6px;
}

/* Filters */
#changelist-filter {
  width: 240px;
  float: right;
  margin: 0 0 1rem 1rem;
  padding: 0;
  background-color: transparent;
  border: none;
}

#changelist-filter h2 {
  margin-top: 0;
}

#changelist-filter ul {
  padding: 0;
  margin: 0 0 1.5rem 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background-color: var(--card-bg);
  overflow: hidden;
}

#changelist-filter li {
  border-bottom: 1px solid var(--border);
  list-style: none;
  margin: 0;
  padding: 0;
}

#changelist-filter li:last-child {
  border-bottom: none;
}

#changelist-filter a {
  display: block;
  padding: 0.75rem 1rem;
  text-decoration: none;
  color: var(--primary);
  transition: all 0.2s ease;
}

#changelist-filter a:hover {
  background-color: var(--primary-light);
  text-decoration: none;
}

#changelist-filter .selected a {
  font-weight: 600;
  color: var(--primary-dark);
  background-color: var(--primary-light);
}

/* ============================================================
   WIDGET BOXES / CARDS
   ============================================================ */

.module {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background-color: var(--card-bg);
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
  transition: all 0.2s ease;
}

.module:hover {
  box-shadow: var(--shadow-md);
}

.module h2 {
  background: linear-gradient(135deg, rgba(13, 110, 253, 0.05), transparent);
  margin: 0;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 1rem;
  color: var(--primary);
  font-weight: 600;
}

.module h3 {
  padding: 0.75rem 1rem;
  margin: 0;
  background: linear-gradient(135deg, rgba(13, 110, 253, 0.03), transparent);
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
  color: var(--dark);
}

/* ============================================================
   LOGIN FORM
   ============================================================ */

.login {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.login #content {
  width: 100%;
  max-width: 420px;
  background-color: var(--card-bg);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  padding: 2rem;
}

.login h1 {
  text-align: center;
  margin-bottom: 2rem;
  color: var(--dark);
}

.login .form-row {
  margin-bottom: 1rem;
}

.login input[type="text"],
.login input[type="password"] {
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
  .form-row {
    flex-direction: column;
  }
  
  .form-row > div {
    width: 100%;
  }
  
  #changelist-filter {
    width: 100%;
    float: none;
    margin: 0 0 1.5rem 0;
  }
}

/* ============================================================
   ACCESSIBILITY
   ============================================================ */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Focus visible for keyboard navigation */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ============================================================
   PRINT STYLES
   ============================================================ */

@media print {
  .submit-line,
  .delete-button,
  a.historylink,
  a.viewsitelink {
    display: none !important;
  }
  
  body {
    background: white;
  }
  
  .module {
    page-break-inside: avoid;
  }
}

/* ============================================================
   ANIMATIONS
   ============================================================ */

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.module {
  animation: fadeIn 0.3s ease-out;
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */

.hidden {
  display: none !important;
}

.help-text {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.required:after {
  content: " *";
  color: var(--danger);
}

/* Loading state */
.loading {
  opacity: 0.6;
  pointer-events: none;
}

.loading:after {
  content: " (chargement...)";
  color: var(--muted);
}
