/**
 * Admin Styles
 */

@primary-color: #0073aa;
@text-color: #23282d;
@border-radius: 4px;
@error-color: #dc3232;
@success-color: #46b450;

.websamurai-admin {
  max-width: 1200px;

  .websamurai-admin-header {
    margin-bottom: 30px;

    h2 {
      margin-bottom: 10px;
    }

    p {
      color: #666;
      margin: 0;
    }
  }

  .loading {
    padding: 20px;
    text-align: center;
    color: #666;
  }

  // Tabs Styles
  .websamurai-tabs {
    .tab-navigation {
      border-bottom: 1px solid #ccd0d4;
      margin-bottom: 25px;
      display: flex;
      gap: 0;

      .tab-button {
        background: transparent;
        border: none;
        border-bottom: 3px solid transparent;
        padding: 12px 20px;
        font-size: 14px;
        font-weight: 600;
        color: #555d66;
        cursor: pointer;
        transition: all 0.2s ease;
        position: relative;
        margin-bottom: -1px;

        &:hover {
          color: @primary-color;
        }

        &.active {
          color: @primary-color;
          border-bottom-color: @primary-color;
        }
      }
    }

    .tab-content {
      animation: fadeIn 0.3s ease;
    }
  }

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

  .notice {
    padding: 10px 15px;
    margin: 20px 0;
    border-left: 4px solid;
    background: #fff;

    &.notice-error {
      border-left-color: @error-color;
    }

    &.notice-success {
      border-left-color: @success-color;
    }

    p {
      margin: 0.5em 0;
    }
  }

  .api-key-manager {
    .generate-key-form {
      background: #fff;
      padding: 20px;
      margin-bottom: 30px;
      border: 1px solid #ccd0d4;
      box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);

      h3 {
        margin-top: 0;
      }

      .form-group {
        margin-bottom: 15px;

        label {
          display: block;
          margin-bottom: 5px;
          font-weight: 600;
        }

        input {
          width: 100%;
          max-width: 400px;
        }
      }
    }

    .generated-key-modal {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: rgba(0, 0, 0, 0.7);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 100000;

      .generated-key-content {
        background: #fff;
        padding: 30px;
        border-radius: @border-radius;
        max-width: 600px;
        width: 90%;
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);

        h3 {
          margin-top: 0;
          color: @success-color;
        }

        .warning-text {
          color: @error-color;
          font-weight: 600;
          margin: 15px 0;
        }

        .key-display {
          background: #f0f0f1;
          padding: 15px;
          border-radius: @border-radius;
          margin: 20px 0;
          display: flex;
          gap: 10px;
          align-items: center;

          code {
            flex: 1;
            word-break: break-all;
            font-size: 14px;
            background: none;
            padding: 0;
          }
        }

        .key-info {
          margin: 20px 0;
          padding: 15px;
          background: #f9f9f9;
          border-radius: @border-radius;

          p {
            margin: 5px 0;
          }
        }
      }
    }

    .api-keys-list {
      background: #fff;
      padding: 20px;
      border: 1px solid #ccd0d4;
      box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
      margin-bottom: 30px;

      h3 {
        margin-top: 0;
      }

      table {
        margin-top: 15px;

        code {
          background: #f0f0f1;
          padding: 3px 6px;
          border-radius: 3px;
          font-size: 12px;
        }
      }
    }

    .mcp-server-info {
      background: #f0f6fc;
      padding: 20px;
      border: 1px solid #c3d9ed;
      border-radius: @border-radius;
      margin-bottom: 20px;

      h3 {
        margin-top: 0;
        color: @primary-color;
      }

      code {
        background: #fff;
        padding: 3px 6px;
        border-radius: 3px;
        border: 1px solid #c3d9ed;
      }

      ul {
        margin: 10px 0;
        padding-left: 25px;

        li {
          margin: 5px 0;
        }
      }
    }

    .mcp-setup-help {
      background: #fffbf0;
      padding: 20px;
      border: 1px solid #f0d9a0;
      border-radius: @border-radius;
      border-left: 4px solid #f7c938;

      h3 {
        margin-top: 0;
        margin-bottom: 12px;
        color: @text-color;
      }

      p {
        margin: 0;
        line-height: 1.6;
        color: @text-color;
      }

      .setup-guide-link {
        color: @primary-color;
        font-weight: 600;
        text-decoration: none;
        display: inline-flex;
        align-items: center;
        transition: color 0.2s ease;

        &:hover {
          color: darken(@primary-color, 10%);
          text-decoration: underline;
        }

        &:focus {
          outline: 2px solid @primary-color;
          outline-offset: 2px;
        }
      }
    }
  }

  // OAuth Connect Styles
  .oauth-connect {
    background: #fff;
    padding: 25px;
    border: 1px solid #ccd0d4;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
    border-radius: @border-radius;

    .oauth-header {
      margin-bottom: 25px;

      h3 {
        margin-top: 0;
        margin-bottom: 10px;
        color: @text-color;
      }

      p {
        color: #666;
        margin: 0;
      }
    }

    .oauth-error {
      background: #fef2f2;
      border-left: 4px solid @error-color;
      padding: 12px 15px;
      margin-bottom: 20px;
      border-radius: @border-radius;

      strong {
        color: @error-color;
      }
    }

    .status-badge {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      padding: 10px 20px;
      border-radius: 20px;
      font-weight: 600;
      font-size: 14px;
      margin-bottom: 20px;

      .status-icon {
        font-size: 18px;
      }

      &.connected {
        background: #ecfdf5;
        color: #10b981;
        border: 1px solid #a7f3d0;

        .status-icon {
          color: #10b981;
        }
      }

      &.disconnected {
        background: #f3f4f6;
        color: #6b7280;
        border: 1px solid #d1d5db;

        .status-icon {
          color: #9ca3af;
        }
      }
    }

    .connection-info {
      background: #f9fafb;
      padding: 20px;
      border-radius: @border-radius;
      border: 1px solid #e5e7eb;
      margin-bottom: 20px;

      .connection-info-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 15px;

        h4 {
          margin: 0;
          color: @text-color;
        }

        .oauth-refresh {
          font-size: 13px;
          padding: 4px 10px;
          height: auto;
          line-height: 1.4;
          cursor: pointer;

          &:hover {
            background: #f0f0f1;
          }

          &:disabled {
            opacity: 0.5;
            cursor: not-allowed;
          }
        }
      }

      h4 {
        margin-top: 0;
        margin-bottom: 15px;
        color: @text-color;
      }

      dl {
        display: grid;
        grid-template-columns: 120px 1fr;
        gap: 10px 20px;
        margin: 0;

        dt {
          font-weight: 600;
          color: #6b7280;
        }

        dd {
          margin: 0;
          color: @text-color;
        }
      }
    }

    .oauth-benefits {
      background: #eff6ff;
      padding: 20px;
      border-radius: @border-radius;
      border: 1px solid #bfdbfe;
      margin-bottom: 20px;

      h4 {
        margin-top: 0;
        margin-bottom: 12px;
        color: @primary-color;
      }

      ul {
        margin: 0;
        padding-left: 25px;

        li {
          margin: 8px 0;
          color: @text-color;
        }
      }
    }

    .oauth-connect-btn,
    .oauth-disconnect {
      margin-top: 10px;
      font-size: 14px;
    }

    .oauth-privacy {
      margin-top: 15px;
      font-size: 13px;
      color: #6b7280;
      font-style: italic;
    }
  }
}

// Media Library AI Image Generation Styles

.websamurai-generate-header {
  h2 {
    margin: 0 0 10px 0;
    font-size: 22px;
  }

  p {
    color: #666;
    margin: 0 0 20px 0;
  }
}

.websamurai-input-group {
  margin-bottom: 20px;

  label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
  }
}

.websamurai-textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  resize: vertical;
}

.websamurai-status {
  margin: 15px 0;
  padding: 12px;
  background-color: #f0f0f0;
  border-radius: 4px;

  p {
    margin: 0;
  }
}

.websamurai-preview {
  margin: 15px 0;
  text-align: center;

  img {
    max-width: 100%;
    height: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
  }
}

.websamurai-actions {
  margin-top: 20px;

  button {
    margin-right: 10px;
  }
}

// Modal Overlay
.websamurai-modal {
  display: none;
  position: fixed;
  z-index: 160000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);

  &.show {
    display: block;
  }
}

// Modal Content
.websamurai-modal-content {
  background-color: #fff;
  margin: 10% auto;
  padding: 20px;
  border: 1px solid #888;
  width: 80%;
  max-width: 600px;
  border-radius: 4px;
  max-height: calc(90vh - 150px);
  overflow: auto;
}

// Modal Header
.websamurai-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;

  h2 {
    margin: 0;
  }
}

.websamurai-modal-close {
  font-size: 28px;
  font-weight: bold;
  color: #aaa;
  cursor: pointer;

  &:hover {
    color: #000;
  }
}

// Modal Body
.websamurai-modal-body {
  margin-bottom: 20px;

  textarea {
    width: 100%;
    min-height: 100px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
  }
}

// Modal Footer
.websamurai-modal-footer {
  text-align: right;
}

// Status Message
.websamurai-status-message {
  margin: 15px 0;
  padding: 10px;
  background-color: #f0f0f0;
  border-radius: 4px;
}

// Image Preview
.websamurai-image-preview {
  margin: 15px 0;
  text-align: center;

  img {
    max-width: 100%;
    height: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
  }
}



  // Media Library Button
.websamurai-generate-image-btn {
  margin-left: 10px;
  padding: 6px 12px;
  border-color: #3582c4;
  box-shadow: 0 0 0 1px #3582c4;
  outline: 2px solid transparent;
}

#websamurai-ai-image-modal-trigger {
  position: fixed;
  left: 0px;
  top: 0px;
  right: 0px;
  bottom: 0px;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 160000;

  .websamurai-generate-container {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: #f9f9f9;
    padding: 20px;
    max-width: 800px;
    margin: 0 auto;
  }

  .websamurai-generate-body {
    background: #fff;
  }
}

