/* Import modern typography from Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  /* Style Guide & Palette from the user screenshots */
  --bg-card: #eef3f6;
  --bg-card-gradient: linear-gradient(135deg, #f5f9fc 0%, #eef3f6 100%);
  --border-card: #d3dbe0;
  
  --text-primary: #3d4d59;
  --text-secondary: #5e7280;
  --text-muted: #8e9fae;
  
  --bg-input: #e2e9ee;
  --border-input: #c8d3db;
  --focus-input: #aebcc7;
  
  --btn-primary-bg: #5c707d;
  --btn-primary-hover: #485964;
  --btn-primary-text: #ffffff;
  
  --btn-secondary-bg: rgba(255, 255, 255, 0.4);
  --btn-secondary-hover: rgba(255, 255, 255, 0.75);
  --btn-secondary-border: #bcc8d2;
  --btn-secondary-text: #4b5e6b;
  
  --item-bg: rgba(255, 255, 255, 0.65);
  --item-bg-hover: #ffffff;
  --item-border: #e1e7ec;
  --item-border-hover: #c9d4dc;
  
  --shadow-soft: 0 8px 30px rgba(61, 77, 89, 0.04), 0 1px 3px rgba(61, 77, 89, 0.02);
  --shadow-hover: 0 12px 35px rgba(61, 77, 89, 0.08), 0 2px 8px rgba(61, 77, 89, 0.04);
  --shadow-modal: 0 30px 70px rgba(0, 0, 0, 0.12), 0 4px 16px rgba(0, 0, 0, 0.04);
  
  --transition-speed: 0.25s;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  overflow-x: hidden;
  padding: 40px 20px;
}

body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: -1;
  background-image: url('Motif-complet_v+gradient.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transform: scale(1.4); /* Zoom in by 40% */
  pointer-events: none;
}

/* App Container - Centered and compact */
.app-container {
  width: 100%;
  max-width: 500px; /* Centered content, set to 500px */
  background: var(--bg-card-gradient);
  border: 1px solid var(--border-card);
  border-radius: 20px;
  box-shadow: var(--shadow-soft);
  padding: 32px;
  position: relative;
  transition: box-shadow var(--transition-speed) ease;
}

.app-container:hover {
  box-shadow: var(--shadow-hover);
}

/* Header Styles */
.app-header {
  margin-bottom: 24px;
}

.app-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}

.app-subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-weight: 400;
  line-height: 1.4;
}

/* Search Bar (Matches "Already update" styling) */
.search-container {
  position: relative;
  margin-bottom: 24px;
}

.search-input {
  width: 100%;
  padding: 14px 16px 14px 44px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: 12px;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text-primary);
  outline: none;
  transition: all var(--transition-speed) ease;
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-input:focus {
  border-color: var(--focus-input);
  background-color: #e5edf2;
  box-shadow: 0 0 0 3px rgba(174, 188, 199, 0.15);
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-icon svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* Links List */
.links-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 520px;
  overflow-y: auto;
  margin-right: -16px; /* Shifts the scrollbar to the right */
  padding-right: 16px; /* Keeps cards aligned and adds space before scrollbar */
  padding-top: 4px;    /* Prevents first item hover translation/shadow clipping */
  padding-bottom: 4px; /* Prevents last item hover translation/shadow clipping */
}

/* Custom Scrollbar for list */
.links-list::-webkit-scrollbar {
  width: 6px;
}

.links-list::-webkit-scrollbar-track {
  background: transparent;
}

.links-list::-webkit-scrollbar-thumb {
  background: var(--border-input);
  border-radius: 10px;
}

.links-list::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Link Card/Item - fully clickable */
.link-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background-color: var(--item-bg);
  border: 1px solid var(--item-border);
  border-radius: 14px;
  text-decoration: none;
  transition: all var(--transition-speed) cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.link-item:hover {
  background-color: var(--item-bg-hover);
  border-color: var(--item-border-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(61, 77, 89, 0.05);
}

.link-item:active {
  transform: translateY(0);
}

/* Left part: Logo & Info */
.link-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
}

.link-logo-container {
  width: 44px;
  height: 44px;
  border-radius: 50%; /* Make portrait circular */
  background-color: #ffffff;
  border: 1px solid var(--item-border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
}

.link-logo-letter {
    width: 40px;
    height: 40px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;

    color: white;
    font-weight: 800;
    font-size: 22px;
    line-height: 1;

    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.16);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
    letter-spacing: -0.03em;
}

.link-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  padding: 0; /* Remove padding for portraits to fill the container */
}

.link-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.link-name {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-url {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-item:hover .link-url {
  color: #4a86b0;
  text-decoration: underline;
}

/* Right part: Date & Time info */
.link-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  margin-left: 14px;
  text-align: right;
  flex-shrink: 0;
}

.link-date {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.link-time {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
}

/* Floating Delete Button on Hover */
.delete-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #ffffff;
  border: 1px solid var(--item-border);
  color: var(--text-muted);
  cursor: pointer;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  opacity: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  z-index: 10;
}

.link-item:hover .delete-btn {
  opacity: 1;
}

.delete-btn:hover {
  background-color: #fce8e6;
  border-color: #f5c2c2;
  color: #d93025;
  transform: scale(1.1);
}

.delete-btn svg {
  width: 10px;
  height: 10px;
  stroke: currentColor;
}

/* No results state */
.no-results {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-secondary);
}

.no-results svg {
  width: 48px;
  height: 48px;
  fill: var(--text-muted);
  margin-bottom: 12px;
}

.no-results-title {
  font-weight: 600;
  font-size: 1.1rem;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.no-results-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* Action Bar at the bottom */
.action-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid rgba(200, 211, 219, 0.4);
}

.link-count {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Buttons (Pill shaped as in screenshot) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: 30px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-speed) ease;
  text-decoration: none;
}

.btn-primary {
  background-color: var(--btn-primary-bg);
  border: none;
  color: var(--btn-primary-text);
  box-shadow: 0 2px 8px rgba(92, 112, 125, 0.15);
}

.btn-primary:hover {
  background-color: var(--btn-primary-hover);
  box-shadow: 0 4px 12px rgba(92, 112, 125, 0.25);
}

.btn-secondary {
  background-color: var(--btn-secondary-bg);
  border: 1px solid var(--btn-secondary-border);
  color: var(--btn-secondary-text);
}

.btn-secondary:hover {
  background-color: var(--btn-secondary-hover);
}

/* CSS-Only Modal System using :target (Matches "Add to favorites" modal screenshot) */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(61, 77, 89, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay:target {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: 100%;
  max-width: 400px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 18px;
  box-shadow: var(--shadow-modal);
  padding: 24px;
  transform: translateY(20px);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay:target .modal-card {
  transform: translateY(0);
}

.modal-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.modal-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 20px;
}

/* Modal Form Styles */
.form-group {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-input {
  width: 100%;
  padding: 10px 12px;
  background-color: #ffffff;
  border: 1px solid var(--border-input);
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition-speed);
}

.form-input:focus {
  border-color: var(--focus-input);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

/* Responsive adjustments */
@media (max-width: 480px) {
  body {
    padding: 20px 12px;
  }
  
  .app-container {
    padding: 20px 16px;
  }
  
  .link-item {
    padding: 12px;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .link-right {
    align-items: flex-start;
    margin-left: 58px;
    border-top: 1px solid rgba(200, 211, 219, 0.3);
    padding-top: 8px;
    width: calc(100% - 58px);
    flex-direction: row;
    justify-content: space-between;
  }
  
  .link-logo-container {
    width: 40px;
    height: 40px;
  }
  
  .link-name {
    font-size: 0.98rem;
  }
  
  .action-bar {
    flex-direction: column;
    gap: 16px;
    align-items: stretch;
    text-align: center;
  }
  
  .btn {
    width: 100%;
  }
}
