* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: #0f172a;
  color: #f8fafc;
  overflow-x: hidden;
}

/* MENU FLOTTANT */
.floating-menu {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100;
}

.menu-toggle {
  width: 52px;
  height: 52px;
  border: none;
  border-radius: 18px;
  background: #2563eb;
  color: white;
  font-size: 26px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(0,0,0,0.35);
}

.menu-toggle:hover {
  background: #1d4ed8;
}

.menu-panel {
  margin-top: 10px;
  padding: 12px;
  background: #020617;
  border: 1px solid #334155;
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 150px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.45);
}

.menu-panel .btn {
  width: 100%;
  text-align: center;
}

/* BUTTONS */
.btn {
  border: none;
  background: #334155;
  color: white;
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: bold;
}

.btn:hover {
  background: #475569;
}

.btn-primary {
  background: #2563eb;
}

.btn-primary:hover {
  background: #1d4ed8;
}

.btn-danger {
  background: #dc2626;
}

.btn-danger:hover {
  background: #b91c1c;
}

.hidden {
  display: none !important;
}

/* DASHBOARD GRID */
.dashboard {
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  grid-auto-rows: 150px;
  gap: 18px;
  grid-auto-flow: dense;
}

/* AIDE EDITION */
.edit-help {
  grid-column: 1 / -1;
  background: rgba(37, 99, 235, 0.15);
  border: 1px solid #2563eb;
  color: #bfdbfe;
  padding: 12px 16px;
  border-radius: 16px;
}

/* WIDGET */
.widget {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  position: relative;
  transition: transform 0.15s ease, border 0.15s ease;
  display: flex;
  flex-direction: column;
}

.widget.editing {
  border: 2px dashed #38bdf8;
}

.widget.dragging {
  opacity: 0.45;
  transform: scale(0.98);
}

.widget.drag-over {
  border: 2px solid #22c55e;
}

.widget-header {
  padding: 12px 14px;
  background: #111827;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: default;
  user-select: none;
  min-height: 46px;
}

.widget.editing .widget-header {
  cursor: grab;
}

.widget-header h2 {
  margin: 0;
  font-size: 18px;
}

.widget-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.edit-widget {
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 10px;
  padding: 6px 9px;
  cursor: pointer;
  font-weight: bold;
}

.edit-widget:hover {
  background: #1d4ed8;
}

.delete-widget {
  background: #dc2626;
  color: white;
  border: none;
  border-radius: 10px;
  padding: 6px 9px;
  cursor: pointer;
  font-weight: bold;
}

.delete-widget:hover {
  background: #b91c1c;
}

.widget-body {
  padding: 14px;
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

/* ALIGNEMENT HORIZONTAL */
.align-h-left {
  justify-content: flex-start;
}

.align-h-center {
  justify-content: center;
}

.align-h-right {
  justify-content: flex-end;
}

.align-h-stretch {
  justify-content: stretch;
}

/* ALIGNEMENT VERTICAL */
.align-v-top {
  align-items: flex-start;
}

.align-v-center {
  align-items: center;
}

.align-v-bottom {
  align-items: flex-end;
}

.align-v-stretch {
  align-items: stretch;
}

/* IFRAME */
.widget iframe {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 14px;
  background: white;
}

/* HTML WIDGET */
.html-content {
  max-width: 100%;
  max-height: 100%;
  overflow: auto;
}

.align-h-stretch .html-content {
  width: 100%;
}

.align-v-stretch .html-content {
  height: 100%;
}

/* TITRE SIMPLE */
.title-widget {
  font-size: 32px;
  font-weight: bold;
  color: #f8fafc;
  text-align: center;
  padding: 10px;
  width: 100%;
}

/* SPACER */
.spacer-widget {
  width: 100%;
  height: 100%;
  opacity: 0.2;
  border: 1px dashed #64748b;
  border-radius: 14px;
}

.widget.spacer-clean {
  background: transparent;
  border: none;
  box-shadow: none;
}

.widget.spacer-clean .widget-header {
  display: none;
}

.widget.spacer-clean .widget-body {
  padding: 0;
}

/* HORLOGE */
.big-clock {
  font-size: 54px;
  font-weight: bold;
  color: #38bdf8;
  text-align: center;
}

.small-date {
  text-align: center;
  color: #cbd5e1;
  margin-top: 8px;
}

.clock-widget-content {
  width: 100%;
  text-align: center;
}

/* WIDGET MUSIQUE */
.music-card {
  width: 100%;
  height: 100%;
  border-radius: 18px;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  text-decoration: none;
  position: relative;
  overflow: hidden;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.music-card:hover {
  transform: scale(1.02);
  filter: brightness(1.08);
}

.music-card::after {
  content: "Cliquer pour ouvrir";
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  font-weight: bold;
  opacity: 0.75;
  background: rgba(0,0,0,0.35);
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
}

.music-logo {
  width: 210%;
  height: 210%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.music-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.music-logo-fallback {
  font-size: 70px;
  line-height: 1;
}

.music-youtube {
  background: linear-gradient(135deg, #991b1b, #ef4444);
}

.music-spotify {
  background: linear-gradient(135deg, #14532d, #22c55e);
}

.music-deezer {
  background: linear-gradient(135deg, #581c87, #ec4899);
}

.music-apple {
  background: linear-gradient(135deg, #111827, #6b7280);
}

.music-amazon {
  background: linear-gradient(135deg, #0f172a, #0ea5e9);
}

.music-soundcloud {
  background: linear-gradient(135deg, #c2410c, #fb923c);
}

.music-other {
  background: linear-gradient(135deg, #1e293b, #64748b);
}

/* WIDGET RACCOURCI */
.shortcut-card {
  width: 100%;
  height: 100%;
  border-radius: 18px;
  padding: 18px;
  background: linear-gradient(135deg, #1e293b, #334155);
  color: white;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.shortcut-card:hover {
  transform: scale(1.02);
  filter: brightness(1.08);
}

.shortcut-icon {
  font-size: 48px;
  line-height: 1;
}

.shortcut-title {
  font-size: 20px;
  font-weight: bold;
}

.shortcut-url {
  font-size: 12px;
  color: #cbd5e1;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* WIDGET CAMERA */
.camera-content {
  width: 100%;
  height: 100%;
  border-radius: 14px;
  overflow: hidden;
  background: #020617;
}

.camera-content iframe,
.camera-content img {
  width: 100%;
  height: 100%;
  border: none;
  object-fit: cover;
  display: block;
}

/* MODAL */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.70);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99;
}

.modal-content {
  width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 22px;
  padding: 24px;
}

.modal-content h2 {
  margin-top: 0;
}

.modal-content label {
  display: block;
  margin-top: 14px;
  margin-bottom: 6px;
  color: #cbd5e1;
}

.modal-content input,
.modal-content select,
.modal-content textarea {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid #475569;
  background: #0f172a;
  color: white;
}

.modal-content textarea {
  min-height: 150px;
  resize: vertical;
  font-family: Consolas, monospace;
  font-size: 13px;
}

.two-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.modal-actions {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* TABLETTE */
@media screen and (max-width: 900px) {
  .dashboard {
    grid-template-columns: repeat(4, minmax(100px, 1fr));
    grid-auto-rows: 140px;
    gap: 14px;
  }
}

/* MOBILE / PETITE TABLETTE */
@media screen and (max-width: 700px) {
  .floating-menu {
    top: 10px;
    right: 10px;
  }

  .menu-toggle {
    width: 48px;
    height: 48px;
    border-radius: 16px;
  }

  .dashboard {
    padding: 14px;
    grid-template-columns: repeat(2, minmax(120px, 1fr));
    grid-auto-rows: 140px;
    gap: 14px;
  }

  .modal-content {
    width: calc(100% - 30px);
  }

  .two-cols {
    grid-template-columns: 1fr;
  }

  .title-widget {
    font-size: 26px;
  }

  .big-clock {
    font-size: 44px;
  }

  .music-card::after {
    font-size: 11px;
  }

  .shortcut-icon {
    font-size: 42px;
  }
}

/* POPUP RACCOURCI */
.shortcut-popup {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.shortcut-popup-content {
  width: 98vw;
  height: 95vh;
  background: #020617;
  border: 1px solid #334155;
  border-radius: 24px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.55);
}

.shortcut-popup-header {
  height: 62px;
  padding: 12px 16px;
  background: #111827;
  border-bottom: 1px solid #334155;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.shortcut-popup-header h2 {
  margin: 0;
  font-size: 20px;
}

.shortcut-popup-close {
  border: none;
  background: #dc2626;
  color: white;
  padding: 9px 14px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: bold;
}

.shortcut-popup-close:hover {
  background: #b91c1c;
}

.shortcut-popup iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: white;
}

@media screen and (max-width: 700px) {
  .shortcut-popup {
    padding: 6px;
  }

  .shortcut-popup-content {
    width: 99vw;
    height: 98vh;
    border-radius: 16px;
  }

  .shortcut-popup-header h2 {
    font-size: 16px;
  }
}

/* CAMERA CARD CLIQUABLE */
.camera-card {
  width: 100%;
  height: 100%;
  border-radius: 18px;
  overflow: hidden;
  background: #020617;
  position: relative;
  cursor: pointer;
}

.camera-card iframe,
.camera-card img {
  width: 100%;
  height: 100%;
  border: none;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.camera-card::after {
  content: "Cliquer pour ouvrir";
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  font-weight: bold;
  opacity: 0.85;
  background: rgba(0,0,0,0.55);
  color: white;
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
}

/* POPUP CAMÉRA */
.camera-popup {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.78);
  z-index: 220;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

.camera-popup-content {
  width: 99vw;
  height: 98vh;
  background: #020617;
  border: 1px solid #334155;
  border-radius: 18px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.60);
}

.camera-popup-header {
  height: 58px;
  padding: 10px 16px;
  background: #111827;
  border-bottom: 1px solid #334155;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.camera-popup-header h2 {
  margin: 0;
  font-size: 20px;
  text-align: center;
  flex: 1;
}

.camera-popup-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.camera-nav-btn {
  border: none;
  background: #2563eb;
  color: white;
  padding: 10px 16px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: bold;
  font-size: 18px;
}

.camera-nav-btn:hover {
  background: #1d4ed8;
}

.camera-popup-close {
  border: none;
  background: #dc2626;
  color: white;
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: bold;
}

.camera-popup-close:hover {
  background: #b91c1c;
}

.camera-popup-viewer {
  flex: 1;
  padding: 10px;
  background: #020617;
}

.camera-popup-viewer iframe,
.camera-popup-viewer img {
  width: 100%;
  height: 100%;
  border: none;
  object-fit: contain;
  background: black;
  display: block;
  border-radius: 14px;
}

@media screen and (max-width: 700px) {
  .camera-popup-content {
    width: 100%;
    height: 96vh;
    border-radius: 16px;
  }

  .camera-popup-header h2 {
    font-size: 15px;
  }

  .camera-nav-btn,
  .camera-popup-close {
    padding: 8px 10px;
    font-size: 14px;
  }
}

/* AIDE CHAMPS */
.field-help {
  margin: 10px 0;
  color: #94a3b8;
  font-size: 13px;
}

/* ÉDITEUR ACTIONS HTTP */
.http-actions-editor {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.http-action-editor {
  border: 1px solid #334155;
  background: #0f172a;
  border-radius: 16px;
  padding: 14px;
}

.http-action-editor h3 {
  margin: 0 0 10px;
  font-size: 16px;
  color: #bfdbfe;
}

/* WIDGET HTTP MULTI-ACTIONS */
.http-card {
  width: 100%;
  height: 100%;
  border-radius: 18px;
  padding: 14px;
  background: linear-gradient(135deg, #0f172a, #2563eb);
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
  text-align: center;
}

.http-card-title {
  text-align: center;
  font-weight: bold;
  font-size: 18px;
  color: white;
}

.http-actions-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.http-action-button {
  border: none;
  background: rgba(255,255,255,0.95);
  color: #1d4ed8;
  font-weight: bold;
  border-radius: 16px;
  padding: 10px;
  cursor: pointer;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
}

.http-action-button:hover {
  background: #dbeafe;
}

.http-action-icon {
  font-size: 20px;
}

.http-status {
  font-size: 13px;
  color: #bfdbfe;
  min-height: 18px;
  text-align: center;
}

/* SMARTTHINGS STATUS */
.smartthings-card.smartthings-on {
  background: linear-gradient(135deg, #14532d, #22c55e);
}

.smartthings-card.smartthings-off {
  background: linear-gradient(135deg, #111827, #334155);
}

.smartthings-card .http-status {
  background: rgba(0,0,0,0.25);
  padding: 6px 10px;
  border-radius: 999px;
  color: white;
  font-weight: bold;
}